Blender V2.61 - r43446

BKE_screen.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 #ifndef BKE_SCREEN_H
00028 #define BKE_SCREEN_H
00029 
00036 struct ARegion;
00037 struct Header;
00038 struct ListBase;
00039 struct Menu;
00040 struct Panel;
00041 struct Scene;
00042 struct ScrArea;
00043 struct SpaceType;
00044 struct View3D;
00045 struct bContext;
00046 struct bContextDataResult;
00047 struct bScreen;
00048 struct uiLayout;
00049 struct uiMenuItem;
00050 struct wmKeyConfig;
00051 struct wmNotifier;
00052 struct wmWindow;
00053 struct wmWindowManager;
00054 
00055 #include "RNA_types.h"
00056 
00057 /* spacetype has everything stored to get an editor working, it gets initialized via 
00058    ED_spacetypes_init() in editors/area/spacetypes.c   */
00059 /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
00060 
00061 #define BKE_ST_MAXNAME  64
00062 
00063 typedef struct SpaceType {
00064     struct SpaceType *next, *prev;
00065     
00066     char            name[BKE_ST_MAXNAME];       /* for menus */
00067     int             spaceid;                    /* unique space identifier */
00068     int             iconid;                     /* icon lookup for menus */
00069     
00070     /* initial allocation, after this WM will call init() too */
00071     struct SpaceLink    *(*new)(const struct bContext *C);
00072     /* not free spacelink itself */
00073     void        (*free)(struct SpaceLink *);
00074     
00075     /* init is to cope with file load, screen (size) changes, check handlers */
00076     void        (*init)(struct wmWindowManager *, struct ScrArea *);
00077     /* Listeners can react to bContext changes */
00078     void        (*listener)(struct ScrArea *, struct wmNotifier *);
00079     
00080     /* refresh context, called after filereads, ED_area_tag_refresh() */
00081     void        (*refresh)(const struct bContext *, struct ScrArea *);
00082     
00083     /* after a spacedata copy, an init should result in exact same situation */
00084     struct SpaceLink    *(*duplicate)(struct SpaceLink *);
00085 
00086     /* register operator types on startup */
00087     void        (*operatortypes)(void);
00088     /* add default items to WM keymap */
00089     void        (*keymap)(struct wmKeyConfig *);
00090     /* on startup, define dropboxes for spacetype+regions */
00091     void        (*dropboxes)(void);
00092 
00093     /* return context data */
00094     int         (*context)(const struct bContext *, const char*, struct bContextDataResult *);
00095 
00096     /* region type definitions */
00097     ListBase    regiontypes;
00098     
00099     /* tool shelf definitions */
00100     ListBase toolshelf;
00101         
00102     /* read and write... */
00103     
00104     /* default keymaps to add */
00105     int         keymapflag;
00106     
00107 } SpaceType;
00108 
00109 /* region types are also defined using spacetypes_init, via a callback */
00110 
00111 typedef struct ARegionType {
00112     struct ARegionType *next, *prev;
00113     
00114     int         regionid;   /* unique identifier within this space, defines RGN_TYPE_xxxx */
00115     
00116     /* add handlers, stuff you only do once or on area/region type/size changes */
00117     void        (*init)(struct wmWindowManager *, struct ARegion *);
00118     /* draw entirely, view changes should be handled here */
00119     void        (*draw)(const struct bContext *, struct ARegion *); 
00120     /* contextual changes should be handled here */
00121     void        (*listener)(struct ARegion *, struct wmNotifier *);
00122     
00123     void        (*free)(struct ARegion *);
00124 
00125     /* split region, copy data optionally */
00126     void        *(*duplicate)(void *);
00127 
00128     
00129     /* register operator types on startup */
00130     void        (*operatortypes)(void);
00131     /* add own items to keymap */
00132     void        (*keymap)(struct wmKeyConfig *);
00133     /* allows default cursor per region */
00134     void        (*cursor)(struct wmWindow *, struct ScrArea *, struct ARegion *ar);
00135 
00136     /* return context data */
00137     int         (*context)(const struct bContext *, const char *, struct bContextDataResult *);
00138 
00139     /* custom drawing callbacks */
00140     ListBase    drawcalls;
00141 
00142     /* panels type definitions */
00143     ListBase paneltypes;
00144 
00145     /* header type definitions */
00146     ListBase headertypes;
00147     
00148     /* hardcoded constraints, smaller than these values region is not visible */
00149     int         minsizex, minsizey;
00150     /* when new region opens (region prefsizex/y are zero then */
00151     int         prefsizex, prefsizey;
00152     /* default keymaps to add */
00153     int         keymapflag;
00154     /* return without drawing. lock is set by region definition, and copied to do_lock by render. can become flag */
00155     short       do_lock, lock;
00156 } ARegionType;
00157 
00158 /* panel types */
00159 
00160 typedef struct PanelType {
00161     struct PanelType *next, *prev;
00162     
00163     char        idname[BKE_ST_MAXNAME];     /* unique name */
00164     char        label[BKE_ST_MAXNAME];      /* for panel header */
00165     char        context[BKE_ST_MAXNAME];    /* for buttons window */
00166     int         space_type;
00167     int         region_type;
00168 
00169     int         flag;
00170 
00171     /* verify if the panel should draw or not */
00172     int         (*poll)(const struct bContext *, struct PanelType *);
00173     /* draw header (optional) */
00174     void        (*draw_header)(const struct bContext *, struct Panel *);    
00175     /* draw entirely, view changes should be handled here */
00176     void        (*draw)(const struct bContext *, struct Panel *);   
00177 
00178     /* RNA integration */
00179     ExtensionRNA ext;
00180 } PanelType;
00181 
00182 /* header types */
00183 
00184 typedef struct HeaderType {
00185     struct HeaderType *next, *prev;
00186 
00187     char        idname[BKE_ST_MAXNAME]; /* unique name */
00188     int         space_type;
00189 
00190     /* draw entirely, view changes should be handled here */
00191     void        (*draw)(const struct bContext *, struct Header *);  
00192 
00193     /* RNA integration */
00194     ExtensionRNA ext;
00195 } HeaderType;
00196 
00197 typedef struct Header {
00198     struct HeaderType *type;    /* runtime */
00199     struct uiLayout *layout;    /* runtime for drawing */
00200 } Header;
00201 
00202 
00203 /* menu types */
00204 
00205 typedef struct MenuType {
00206     struct MenuType *next, *prev;
00207 
00208     char        idname[BKE_ST_MAXNAME]; /* unique name */
00209     char        label[BKE_ST_MAXNAME];  /* for button text */
00210     char       *description;
00211 
00212     /* verify if the menu should draw or not */
00213     int         (*poll)(const struct bContext *, struct MenuType *);
00214     /* draw entirely, view changes should be handled here */
00215     void        (*draw)(const struct bContext *, struct Menu *);    
00216 
00217     /* RNA integration */
00218     ExtensionRNA ext;
00219 } MenuType;
00220 
00221 typedef struct Menu {
00222     struct MenuType *type;      /* runtime */
00223     struct uiLayout *layout;    /* runtime for drawing */
00224 } Menu;
00225 
00226 /* spacetypes */
00227 struct SpaceType *BKE_spacetype_from_id(int spaceid);
00228 struct ARegionType *BKE_regiontype_from_id(struct SpaceType *st, int regionid);
00229 const struct ListBase *BKE_spacetypes_list(void);
00230 void BKE_spacetype_register(struct SpaceType *st);
00231 void BKE_spacetypes_free(void); /* only for quitting blender */
00232 
00233 /* spacedata */
00234 void BKE_spacedata_freelist(ListBase *lb);
00235 void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2);
00236 void BKE_spacedata_draw_locks(int set);
00237 
00238 /* area/regions */
00239 struct ARegion *BKE_area_region_copy(struct SpaceType *st, struct ARegion *ar);
00240 void    BKE_area_region_free(struct SpaceType *st, struct ARegion *ar);
00241 void    BKE_screen_area_free(struct ScrArea *sa);
00242 
00243 struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
00244 struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min);
00245 
00246 void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);
00247 void BKE_screen_view3d_scene_sync(struct bScreen *sc);
00248 void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene);
00249 
00250 /* zoom factor conversion */
00251 float BKE_screen_view3d_zoom_to_fac(float camzoom);
00252 float BKE_screen_view3d_zoom_from_fac(float zoomfac);
00253 
00254 /* screen */
00255 void free_screen(struct bScreen *sc); 
00256 unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene);
00257 
00258 #endif
00259