diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-09 18:59:43 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-09 18:59:43 +0300 |
commit | b205ec4f18b704edc63f914cefc2d16b2784803a (patch) | |
tree | 11eff09eb1eeebf2e18e8fde759b1b673f00948c /source/blender | |
parent | b9e04c67dce1e808c06f67ec3ae43e763f67d46b (diff) |
2.5
Area Manager: revised how an area subdivision gets managed. Originally
the 'spacedata' would store regiondata too, but this already became
impractical (like having view2d data in region is useful). So I left
that part how it is. See new diagram:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/AreaManager
This means that regions in an Area define location/size or constraints
for how they get arranged. The "RegionType" which is linked to this
defines its functionality.
For fun, test, and code validation: two temporary hotkeys added.
SKEY: splits current region horizontally
SHIFT+S: splits vertically
Note - in outliner - that "context" sticks to the Area as whole, the region
here only defines view. That's the purpose. :) For two outliners with different
context you open 2 areas.
Also note that dragging screen-edges shows the region-alignment type (split
with percentage).
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 55 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 70 | ||||
-rw-r--r-- | source/blender/editors/screen/spacetypes.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_time/space_time.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 26 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 28 |
10 files changed, 145 insertions, 61 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 2c86b5076b0..fe832baf7c9 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -46,6 +46,7 @@ void ED_region_do_draw(struct bContext *C, ARegion *ar); void ED_region_do_refresh(struct bContext *C, ARegion *ar); void ED_region_exit(struct bContext *C, ARegion *ar); void ED_region_pixelspace(const struct bContext *C, ARegion *ar); +ARegion *ED_region_copy(ARegion *ar); /* spaces */ void ED_spacetypes_init(void); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index a4f29e37e34..2a5c934ce42 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -341,7 +341,7 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname); void uiTestRegion(const struct bContext *C); /* XXX 2.50 temporary test */ void UI_keymap(struct wmWindowManager *wm); - +void UI_operatortypes(void); void UI_init(void); void UI_init_userdef(void); void UI_exit(void); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index a256a207e70..f214fa89cd8 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -3503,7 +3503,7 @@ void ED_UI_OT_menu_block_handle(wmOperatorType *ot) /* ************************** registration **********************************/ -void ui_operatortypes(void) +void UI_operatortypes(void) { WM_operatortype_append(ED_UI_OT_button_activate); WM_operatortype_append(ED_UI_OT_menu_block_handle); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7a5fa0cb727..54bfdcf4d65 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -166,9 +166,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar) fac= BLI_frand(); glColor3f(fac, fac, fac); glRecti(20, 2, 30, 12); - - region_draw_emboss(ar); } + region_draw_emboss(ar); /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */ ED_region_pixelspace(C, ar); @@ -193,7 +192,7 @@ void ED_region_do_refresh(bContext *C, ARegion *ar) /* *************************************************************** */ - +/* dir is direction to check, not the splitting edge direction! */ static int rct_fits(rcti *rect, char dir, int size) { if(dir=='h') { @@ -209,8 +208,10 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder) if(ar==NULL) return; - /* clear state flag first */ + /* clear state flags first */ ar->flag &= ~RGN_FLAG_TOO_SMALL; + if(ar->next==NULL) + ar->alignment= RGN_ALIGN_NONE; if(ar->size<ar->minsize) ar->size= ar->minsize; @@ -220,7 +221,7 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder) /* XXX floating area region, not handled yet here */ else if(ar->alignment == RGN_ALIGN_FLOAT); /* remainder is too small for any usage */ - else if( rct_fits(remainder, 'v', 1)==0 || rct_fits(remainder, 'h', 1) < 0 ) { + else if( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) { ar->flag |= RGN_FLAG_TOO_SMALL; } else if(ar->alignment==RGN_ALIGN_NONE) { @@ -279,12 +280,22 @@ static void region_rect_recursive(ARegion *ar, rcti *remainder) ar->winrct= *remainder; if(ar->alignment==RGN_ALIGN_HSPLIT) { - ar->winrct.xmax= (remainder->xmin+remainder->xmax)/2; - remainder->xmin= ar->winrct.xmax+1; + if( rct_fits(remainder, 'h', ar->size) > 4) { + ar->winrct.xmax= (remainder->xmin+remainder->xmax)/2; + remainder->xmin= ar->winrct.xmax+1; + } + else { + BLI_init_rcti(remainder, 0, 0, 0, 0); + } } else { - ar->winrct.ymax= (remainder->ymin+remainder->ymax)/2; - remainder->ymin= ar->winrct.ymax+1; + if( rct_fits(remainder, 'v', ar->size) > 4) { + ar->winrct.ymax= (remainder->ymin+remainder->ymax)/2; + remainder->ymin= ar->winrct.ymax+1; + } + else { + BLI_init_rcti(remainder, 0, 0, 0, 0); + } } } @@ -387,9 +398,24 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) area_azone_initialize(sa); } + +ARegion *ED_region_copy(ARegion *ar) +{ + ARegion *newar= MEM_dupallocN(ar); + + newar->handlers.first= newar->handlers.last= NULL; + newar->uiblocks.first= newar->uiblocks.last= NULL; + newar->swinid= 0; + + /* XXX regiondata */ + if(ar->regiondata) + newar->regiondata= MEM_dupallocN(ar->regiondata); + + return newar; +} + /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */ /* area vertices were set */ - void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) { Panel *pa1, *pa2, *patab; @@ -429,11 +455,10 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) /* regions */ BLI_freelistN(&sa1->regionbase); - BLI_duplicatelist(&sa1->regionbase, &sa2->regionbase); - for(ar= sa1->regionbase.first; ar; ar= ar->next) { - ar->handlers.first= ar->handlers.last= NULL; - ar->uiblocks.first= ar->uiblocks.last= NULL; - ar->swinid= 0; + + for(ar= sa2->regionbase.first; ar; ar= ar->next) { + ARegion *newar= ED_region_copy(ar); + BLI_addtail(&sa1->regionbase, newar); } #ifndef DISABLE_PYTHON diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index e78beec3488..8e49da0420a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -911,13 +911,14 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_RUNNING_MODAL; } +static EnumPropertyItem prop_direction_items[] = { + {'h', "HORIZONTAL", "Horizontal", ""}, + {'v', "VERTICAL", "Vertical", ""}, + {0, NULL, NULL, NULL}}; + void ED_SCR_OT_area_split(wmOperatorType *ot) { PropertyRNA *prop; - static EnumPropertyItem prop_direction_items[] = { - {'h', "HORIZONTAL", "Horizontal", ""}, - {'v', "VERTICAL", "Vertical", ""}, - {0, NULL, NULL, NULL}}; ot->name = "Split area"; ot->idname = "ED_SCR_OT_area_split"; @@ -1245,6 +1246,61 @@ void ED_SCR_OT_repeat_last(wmOperatorType *ot) } +/* ************** region split operator ***************************** */ + +/* insert a region in the area region list */ +static int region_split_exec(bContext *C, wmOperator *op) +{ + ARegion *newar= ED_region_copy(C->region); + int dir= RNA_enum_get(op->ptr, "dir"); + + BLI_insertlinkafter(&C->area->regionbase, C->region, newar); + + newar->alignment= C->region->alignment; + + if(dir=='h') + C->region->alignment= RGN_ALIGN_HSPLIT; + else + C->region->alignment= RGN_ALIGN_VSPLIT; + + WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL); + + return OPERATOR_FINISHED; +} + +static int region_split_invoke(bContext *C, wmOperator *op, wmEvent *evt) +{ + + /* can't do menu, so event is checked manually */ + if(evt->shift) + RNA_enum_set(op->ptr, "dir", 'v'); + else + RNA_enum_set(op->ptr, "dir", 'h'); + + return region_split_exec(C, op); +} + + +void ED_SCR_OT_region_split(wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Split Region"; + ot->idname= "ED_SCR_OT_region_split"; + + /* api callbacks */ + ot->exec= region_split_exec; + ot->invoke= region_split_invoke; + + ot->poll= ED_operator_areaactive; + + prop= RNA_def_property(ot->srna, "dir", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_direction_items); + RNA_def_property_enum_default(prop, 'h'); +} + + /* ************** border select operator (template) ***************************** */ /* operator state vars used: (added by default WM callbacks) @@ -1318,7 +1374,8 @@ void ED_operatortypes_screen(void) WM_operatortype_append(ED_SCR_OT_area_split); WM_operatortype_append(ED_SCR_OT_area_join); WM_operatortype_append(ED_SCR_OT_area_rip); - + WM_operatortype_append(ED_SCR_OT_region_split); + /* tools shared by more space types */ ED_marker_operatortypes(); @@ -1337,6 +1394,9 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_verify_item(keymap, "ED_SCR_OT_area_join", EVT_ACTIONZONE, 0, 0, 0); /* action tria */ WM_keymap_verify_item(keymap, "ED_SCR_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 0); + /* tests */ + WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "ED_SCR_OT_repeat_last", F4KEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/screen/spacetypes.c b/source/blender/editors/screen/spacetypes.c index bafb8aef94f..ec348882acb 100644 --- a/source/blender/editors/screen/spacetypes.c +++ b/source/blender/editors/screen/spacetypes.c @@ -71,7 +71,7 @@ void ED_spacetypes_init(void) /* register operator types for screen and all spaces */ ED_operatortypes_screen(); - ui_operatortypes(); + UI_operatortypes(); ui_view2d_operatortypes(); spacetypes = BKE_spacetypes_list(); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 399a7f08205..4ec64a5328d 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -496,16 +496,10 @@ static void outliner_init(wmWindowManager *wm, ScrArea *sa) { ARegion *ar; - /* link area to SpaceXXX struct */ - sa->type= BKE_spacetype_from_id(SPACE_OOPS); - - /* add handlers to area */ - /* define how many regions, the order and types */ - /* add types to regions, check handlers */ for(ar= sa->regionbase.first; ar; ar= ar->next) { - ar->type= ED_regiontype_from_id(sa->type, ar->regiontype); /* XXX fix type and id */ + ar->type= ED_regiontype_from_id(sa->type, ar->regiontype); if(ar->handlers.first==NULL) { ListBase *keymap; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index fd802d44fb4..71446531cbb 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -230,22 +230,16 @@ static void time_free(SpaceLink *sl) } -/* spacetype; init callback */ +/* spacetype; init callback in ED_area_initialize() */ /* init is called to (re)initialize an existing editor (file read, screen changes) */ static void time_init(wmWindowManager *wm, ScrArea *sa) { ARegion *ar; - /* link area to SpaceXXX struct */ - sa->type= BKE_spacetype_from_id(SPACE_TIME); - - /* add handlers to area */ - /* define how many regions, the order and types */ - /* add types to regions, check handlers */ for(ar= sa->regionbase.first; ar; ar= ar->next) { - ar->type= ED_regiontype_from_id(sa->type, ar->regiontype); /* XXX fix type and id */ + ar->type= ED_regiontype_from_id(sa->type, ar->regiontype); if(ar->handlers.first==NULL) { ListBase *keymap; @@ -255,10 +249,10 @@ static void time_init(wmWindowManager *wm, ScrArea *sa) keymap= WM_keymap_listbase(wm, "Interface", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - /* own keymap */ keymap= WM_keymap_listbase(wm, "View2D", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); + /* own keymap */ keymap= WM_keymap_listbase(wm, "TimeLine", sa->spacetype, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 81911a510ae..a9e3a382fbe 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -45,6 +45,7 @@ #include "BKE_screen.h" #include "ED_area.h" +#include "ED_screen.h" #include "BIF_gl.h" @@ -122,16 +123,9 @@ static void view3d_init(struct wmWindowManager *wm, ScrArea *sa) { ARegion *ar; - /* link area to SpaceXXX struct */ - - /* define how many regions, the order and types */ - - /* add types to regions */ + /* add types to regions, handlers */ for(ar= sa->regionbase.first; ar; ar= ar->next) { - static ARegionType art={NULL, NULL, NULL, NULL, NULL}; - - /* for time being; register 1 type */ - ar->type= &art; + ar->type= ED_regiontype_from_id(sa->type, ar->regiontype); } } @@ -186,6 +180,7 @@ void view3d_keymap(struct wmWindowManager *wm) void ED_spacetype_view3d(void) { SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + ARegionType *art; st->spaceid= SPACE_VIEW3D; @@ -197,6 +192,19 @@ void ED_spacetype_view3d(void) st->operatortypes= view3d_operatortypes; st->keymap= view3d_keymap; + /* regions: main window */ + art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art->regionid = RGN_TYPE_WINDOW; + + BLI_addhead(&st->regiontypes, art); + + /* regions: header */ + art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art->regionid = RGN_TYPE_HEADER; + + BLI_addhead(&st->regiontypes, art); + + BKE_spacetype_register(st); } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 9fd4770c977..d2bb480b109 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -61,8 +61,8 @@ struct bGPdata; typedef struct SpaceLink { struct SpaceLink *next, *prev; int spacetype; - float blockscale; - short blockhandler[8]; + float blockscale; /* XXX depricate this */ + short blockhandler[8]; /* XXX depricate this */ } SpaceLink; typedef struct SpaceInfo { @@ -81,7 +81,7 @@ typedef struct SpaceIpo { short blockhandler[8]; unsigned int rowbut, pad2; - View2D v2d; + View2D v2d; /* depricated, copied to region */ void *editipo; ListBase ipokey; @@ -110,7 +110,7 @@ typedef struct SpaceButs { short cursens, curact; short align, tabo; /* align for panels, tab is old tab */ - View2D v2d; + View2D v2d; /* depricated, copied to region */ short mainb, menunr; /* texnr and menunr have to remain shorts */ short pin, mainbo; @@ -138,7 +138,7 @@ typedef struct SpaceSeq { short blockhandler[8]; - View2D v2d; + View2D v2d; /* depricated, copied to region */ float xof, yof; /* offset for drawing the image preview */ short mainb, pad; @@ -191,7 +191,7 @@ typedef struct SpaceOops { short blockhandler[8]; - View2D v2d; + View2D v2d; /* depricated, copied to region */ ListBase oops; short pin, visiflag, flag, rt; @@ -220,7 +220,7 @@ typedef struct SpaceImage { short blockhandler[8]; - View2D v2d; + View2D v2d; /* depricated, copied to region */ struct Image *image; struct ImageUser iuser; @@ -256,7 +256,7 @@ typedef struct SpaceNla { short autosnap; /* this uses the same settings as autosnap for Action Editor */ short flag; - View2D v2d; + View2D v2d; /* depricated, copied to region */ } SpaceNla; typedef struct SpaceText { @@ -323,7 +323,7 @@ typedef struct SpaceTime { int spacetype; float blockscale; - View2D v2d; + View2D v2d; /* depricated, copied to region */ int flag, redraws; @@ -336,7 +336,7 @@ typedef struct SpaceNode { short blockhandler[8]; - View2D v2d; + View2D v2d; /* depricated, copied to region */ struct ID *id, *from; /* context, no need to save in file? well... pinning... */ short flag, menunr; /* menunr: browse id block in header */ @@ -363,7 +363,7 @@ typedef struct SpaceImaSel { short blockhandler[8]; - View2D v2d; + View2D v2d; /* depricated, copied to region */ struct FileList *files; @@ -415,10 +415,12 @@ typedef struct SpaceImaSel { } SpaceImaSel; -/* **************** SPACE ********************* */ +/* view3d Now in DNA_view3d_types.h */ + -/* view3d Now in DNA_view3d_types.h */ +/* **************** SPACE DEFINES ********************* */ + /* button defines in BIF_butspace.h */ |