Blender  V2.59
DNA_windowmanager_types.h
Go to the documentation of this file.
00001 /*
00002  * $Id: DNA_windowmanager_types.h 39084 2011-08-05 20:45:26Z blendix $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2007 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * 
00024  * Contributor(s): Blender Foundation
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 #ifndef DNA_WINDOWMANAGER_TYPES_H
00029 #define DNA_WINDOWMANAGER_TYPES_H
00030 
00035 #include "DNA_listBase.h"
00036 #include "DNA_vec_types.h"
00037 
00038 #include "DNA_ID.h"
00039 
00040 /* defined here: */
00041 struct wmWindowManager;
00042 struct wmWindow;
00043 
00044 struct wmEvent;
00045 struct wmGesture;
00046 struct wmOperatorType;
00047 struct wmOperator;
00048 struct wmKeyMap;
00049 struct wmKeyConfig;
00050 
00051 /* forwards */
00052 struct bContext;
00053 struct wmLocal;
00054 struct bScreen;
00055 struct uiBlock;
00056 struct wmSubWindow;
00057 struct wmTimer;
00058 struct StructRNA;
00059 struct PointerRNA;
00060 struct ReportList;
00061 struct Report;
00062 struct uiLayout;
00063 
00064 #define OP_MAX_TYPENAME 64
00065 #define KMAP_MAX_NAME   64
00066 
00067 /* keep in sync with 'wm_report_items' in wm_rna.c */
00068 typedef enum ReportType {
00069         RPT_DEBUG                                       = 1<<0,
00070         RPT_INFO                                        = 1<<1,
00071         RPT_OPERATOR                            = 1<<2,
00072         RPT_WARNING                                     = 1<<3,
00073         RPT_ERROR                                       = 1<<4,
00074         RPT_ERROR_INVALID_INPUT         = 1<<5,
00075         RPT_ERROR_INVALID_CONTEXT       = 1<<6,
00076         RPT_ERROR_OUT_OF_MEMORY         = 1<<7
00077 } ReportType;
00078 
00079 #define RPT_DEBUG_ALL           (RPT_DEBUG)
00080 #define RPT_INFO_ALL            (RPT_INFO)
00081 #define RPT_OPERATOR_ALL        (RPT_OPERATOR)
00082 #define RPT_WARNING_ALL         (RPT_WARNING)
00083 #define RPT_ERROR_ALL           (RPT_ERROR|RPT_ERROR_INVALID_INPUT|RPT_ERROR_INVALID_CONTEXT|RPT_ERROR_OUT_OF_MEMORY)
00084 
00085 enum ReportListFlags {
00086         RPT_PRINT = 1,
00087         RPT_STORE = 2,
00088         RPT_FREE = 4,
00089         RPT_OP_HOLD = 8 /* dont move them into the operator global list (caller will use) */
00090 };
00091 #
00092 #
00093 typedef struct Report {
00094         struct Report *next, *prev;
00095         short type; /* ReportType */
00096         short flag;
00097         int len; /* strlen(message), saves some time calculating the word wrap  */
00098         const char *typestr;
00099         const char *message;
00100 } Report;
00101 
00102 /* saved in the wm, dont remove */
00103 typedef struct ReportList {
00104         ListBase list;
00105         int printlevel; /* ReportType */
00106         int storelevel; /* ReportType */
00107         int flag, pad;
00108         struct wmTimer *reporttimer;
00109 } ReportList;
00110 
00111 /* timer customdata to control reports display */
00112 #
00113 #
00114 typedef struct ReportTimerInfo {
00115         float col[3];
00116         float greyscale;
00117         float widthfac;
00118 } ReportTimerInfo;
00119 
00120 /* reports need to be before wmWindowManager */
00121 
00122 
00123 /* windowmanager is saved, tag WMAN */
00124 typedef struct wmWindowManager {
00125         ID id;
00126         
00127         struct wmWindow *windrawable, *winactive;               /* separate active from drawable */
00128         ListBase windows;
00129         
00130         int initialized;                /* set on file read */
00131         short file_saved;               /* indicator whether data was saved */
00132         short op_undo_depth;    /* operator stack depth to avoid nested undo pushes */
00133         
00134         ListBase operators;             /* operator registry */
00135         
00136         ListBase queue;                 /* refresh/redraw wmNotifier structs */
00137         
00138         struct ReportList reports;      /* information and error reports */
00139         
00140         ListBase jobs;                  /* threaded jobs manager */
00141         
00142         ListBase paintcursors;  /* extra overlay cursors to draw, like circles */
00143         
00144         ListBase drags;                 /* active dragged items */
00145         
00146         ListBase keyconfigs;                            /* known key configurations */
00147         struct wmKeyConfig *defaultconf;        /* default configuration */
00148         struct wmKeyConfig *addonconf;          /* addon configuration */
00149         struct wmKeyConfig *userconf;           /* user configuration */
00150 
00151         ListBase timers;                                        /* active timers */
00152         struct wmTimer *autosavetimer;          /* timer for auto save */
00153 } wmWindowManager;
00154 
00155 /* wmWindowManager.initialized */
00156 #define WM_INIT_WINDOW          (1<<0)
00157 #define WM_INIT_KEYMAP          (1<<1)
00158 
00159 /* the savable part, rest of data is local in ghostwinlay */
00160 typedef struct wmWindow {
00161         struct wmWindow *next, *prev;
00162         
00163         void *ghostwin;         /* dont want to include ghost.h stuff */
00164         
00165         int winid;              /* winid also in screens, is for retrieving this window after read */
00166 
00167         short grabcursor; /* cursor grab mode */
00168         short pad;
00169         
00170         struct bScreen *screen;         /* active screen */
00171         struct bScreen *newscreen;      /* temporary when switching */
00172         char screenname[32];    /* MAX_ID_NAME for matching window with active screen after file read */
00173         
00174         short posx, posy, sizex, sizey; /* window coords */
00175         short windowstate;      /* borderless, full */
00176         short monitor;          /* multiscreen... no idea how to store yet */
00177         short active;           /* set to 1 if an active window, for quick rejects */
00178         short cursor;           /* current mouse cursor type */
00179         short lastcursor;       /* previous cursor when setting modal one */
00180         short modalcursor;      /* the current modal cursor */
00181         short addmousemove;     /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
00182         short pad2;
00183 
00184         struct wmEvent *eventstate;     /* storage for event system */
00185         
00186         struct wmSubWindow *curswin;    /* internal for wm_subwindow.c only */
00187 
00188         struct wmGesture *tweak;        /* internal for wm_operators.c */
00189         
00190         int drawmethod, drawfail;       /* internal for wm_draw.c only */
00191         void *drawdata;                         /* internal for wm_draw.c only */
00192         
00193         ListBase queue;                         /* all events (ghost level events were handled) */
00194         ListBase handlers;                      /* window+screen handlers, handled last */
00195         ListBase modalhandlers;         /* priority handlers, handled first */
00196         
00197         ListBase subwindows;    /* opengl stuff for sub windows, see notes in wm_subwindow.c */
00198         ListBase gesture;               /* gesture stuff */
00199 } wmWindow;
00200 
00201 /* should be somthing like DNA_EXCLUDE 
00202  * but the preprocessor first removes all comments, spaces etc */
00203 
00204 #
00205 #
00206 typedef struct wmOperatorTypeMacro {
00207         struct wmOperatorTypeMacro *next, *prev;
00208 
00209         /* operator id */
00210         char idname[64];
00211         /* rna pointer to access properties, like keymap */
00212         struct IDProperty *properties;  /* operator properties, assigned to ptr->data and can be written to a file */
00213         struct PointerRNA *ptr;
00214 
00215 } wmOperatorTypeMacro;
00216 
00217 /* partial copy of the event, for matching by eventhandler */
00218 typedef struct wmKeyMapItem {
00219         struct wmKeyMapItem *next, *prev;
00220         
00221         /* operator */
00222         char idname[64];        /* used to retrieve operator type pointer */
00223         IDProperty *properties;                 /* operator properties, assigned to ptr->data and can be written to a file */
00224         
00225         /* modal */
00226         short propvalue;                                /* if used, the item is from modal map */
00227 
00228         /* event */
00229         short type;                                             /* event code itself */
00230         short val;                                              /* KM_ANY, KM_PRESS, KM_NOTHING etc */
00231         short shift, ctrl, alt, oskey;  /* oskey is apple or windowskey, value denotes order of pressed */
00232         short keymodifier;                              /* rawkey modifier */
00233         
00234         /* flag: inactive, expanded */
00235         short flag;
00236 
00237         /* runtime */
00238         short maptype;                                  /* keymap editor */
00239         short id;                                               /* unique identifier. Positive for kmi that override builtins, negative otherwise */
00240         short pad;
00241         struct PointerRNA *ptr;                 /* rna pointer to access properties */
00242 } wmKeyMapItem;
00243 
00244 /* used instead of wmKeyMapItem for diff keymaps */
00245 typedef struct wmKeyMapDiffItem {
00246         struct wmKeyMapDiffItem *next, *prev;
00247 
00248         wmKeyMapItem *remove_item;
00249         wmKeyMapItem *add_item;
00250 } wmKeyMapDiffItem;
00251 
00252 /* wmKeyMapItem.flag */
00253 #define KMI_INACTIVE            1
00254 #define KMI_EXPANDED            2
00255 #define KMI_USER_MODIFIED       4
00256 #define KMI_UPDATE                      8
00257 
00258 /* stored in WM, the actively used keymaps */
00259 typedef struct wmKeyMap {
00260         struct wmKeyMap *next, *prev;
00261         
00262         ListBase items;
00263         ListBase diff_items;
00264         
00265         char idname[64];        /* global editor keymaps, or for more per space/region */
00266         short spaceid;          /* same IDs as in DNA_space_types.h */
00267         short regionid;         /* see above */
00268         
00269         short flag;                     /* general flags */
00270         short kmi_id;           /* last kmi id */
00271         
00272         /* runtime */
00273         int (*poll)(struct bContext *); /* verify if enabled in the current context */
00274         void *modal_items;                              /* for modal, EnumPropertyItem for now */
00275 } wmKeyMap;
00276 
00277 /* wmKeyMap.flag */
00278 #define KEYMAP_MODAL                            1       /* modal map, not using operatornames */
00279 #define KEYMAP_USER                                     2       /* user keymap */
00280 #define KEYMAP_EXPANDED                         4
00281 #define KEYMAP_CHILDREN_EXPANDED        8
00282 #define KEYMAP_DIFF                                     16      /* diff keymap for user preferences */
00283 #define KEYMAP_USER_MODIFIED            32      /* keymap has user modifications */
00284 #define KEYMAP_UPDATE                           64
00285 
00286 typedef struct wmKeyConfig {
00287         struct wmKeyConfig *next, *prev;
00288 
00289         char idname[64];                /* unique name */
00290         char basename[64];              /* idname of configuration this is derives from, "" if none */
00291         
00292         ListBase keymaps;
00293         int actkeymap, flag;
00294 } wmKeyConfig;
00295 
00296 /* wmKeyConfig.flag */
00297 #define KEYCONF_USER                    (1 << 1)
00298 
00299 /* this one is the operator itself, stored in files for macros etc */
00300 /* operator + operatortype should be able to redo entirely, but for different contextes */
00301 typedef struct wmOperator {
00302         struct wmOperator *next, *prev;
00303 
00304         /* saved */
00305         char idname[64];/* used to retrieve type pointer */
00306         IDProperty *properties;         /* saved, user-settable properties */
00307 
00308         /* runtime */
00309         struct wmOperatorType *type;/* operator type definition from idname */
00310         void *customdata;                       /* custom storage, only while operator runs */
00311         void *py_instance;                      /* python stores the class instance here */
00312 
00313         struct PointerRNA *ptr;         /* rna pointer to access properties */
00314         struct ReportList *reports;     /* errors and warnings storage */
00315 
00316         ListBase macro;                         /* list of operators, can be a tree */
00317         struct wmOperator *opm;         /* current running macro, not saved */
00318         struct uiLayout *layout;        /* runtime for drawing */
00319         short flag, pad[3];
00320 
00321 } wmOperator;
00322 
00323 /* operator type exec(), invoke() modal(), return values */
00324 #define OPERATOR_RUNNING_MODAL  1
00325 #define OPERATOR_CANCELLED              2
00326 #define OPERATOR_FINISHED               4
00327 /* add this flag if the event should pass through */
00328 #define OPERATOR_PASS_THROUGH   8
00329 /* in case operator got executed outside WM code... like via fileselect */
00330 #define OPERATOR_HANDLED                16
00331 
00332 /* wmOperator flag */
00333 #define OP_GRAB_POINTER                 1
00334 
00335 #endif /* DNA_WINDOWMANAGER_TYPES_H */