diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-17 22:40:19 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-17 22:40:19 +0300 |
commit | 7a5186c53f12c772abb692e831d15baebe958445 (patch) | |
tree | c1f8b1e357a01765b0172cad6b7e48273667316e | |
parent | 6634ed9a872ac7f5417ba9d6472a4a568f64d68d (diff) |
2.5
Added operator for moving area to 'full screen'.
This is instable with tooltips on... fishy stuff then goes on,
which Brecht will first look at. :)
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 6 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 80 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 29 |
5 files changed, 113 insertions, 8 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 2c0101f3542..7b4dd41e4a8 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -72,7 +72,6 @@ void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note); bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc); void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event); void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen); -void ED_screen_set(struct bContext *C, struct bScreen *sc); void ED_operatortypes_screen(void); void ED_keymap_screen(struct wmWindowManager *wm); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 5fe8d5e315c..35b7f21910a 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -490,6 +490,7 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) sa1->headertype= sa2->headertype; sa1->spacetype= sa2->spacetype; + sa1->butspacetype= sa2->butspacetype; if(swap_space) { SWAP(ListBase, sa1->spacedata, sa2->spacedata); @@ -539,7 +540,7 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) /* *********** Space switching code, local now *********** */ /* XXX make operator for this */ -static void area_newspace(bContext *C, ScrArea *sa, int type) +void area_newspace(bContext *C, ScrArea *sa, int type) { if(sa->spacetype != type) { SpaceType *st; @@ -585,7 +586,8 @@ static void area_newspace(bContext *C, ScrArea *sa, int type) BLI_addhead(&sa->spacedata, sl); /* swap regions */ - slold->regionbase= sa->regionbase; + if(slold) + slold->regionbase= sa->regionbase; sa->regionbase= sl->regionbase; sl->regionbase.first= sl->regionbase.last= NULL; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index b325bb8e5d8..3fc582a901b 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -419,7 +419,7 @@ bScreen *screen_add(wmWindow *win, char *name) screen_addedge(sc, sv4, sv1); /* dummy type, no spacedata */ - screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_INFO); + screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY); return sc; } @@ -1042,6 +1042,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) ARegion *ar; C->window= window; + for(ar= screen->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); @@ -1155,7 +1156,7 @@ int ED_screen_area_active(const bContext *C) /* operator call, WM + Window + screen already existed before */ /* Do NOT call in area/region queues! */ -void ED_screen_set(bContext *C, bScreen *sc) +void ed_screen_set(bContext *C, bScreen *sc) { if(sc->full) { /* find associated full */ @@ -1167,7 +1168,7 @@ void ED_screen_set(bContext *C, bScreen *sc) break; } } - if(sc1==NULL) printf("setscreen error\n"); + if(sc1==NULL) printf("set screen error\n"); } if (C->screen != sc) { @@ -1180,3 +1181,76 @@ void ED_screen_set(bContext *C, bScreen *sc) } } +/* this function toggles: if area is full then the parent will be restored */ +void ed_screen_fullarea(bContext *C) +{ + bScreen *sc, *oldscreen; + ScrArea *newa, *old; + short fulltype; + + if(C->area->full) { + sc= C->area->full; /* the old screen to restore */ + oldscreen= C->screen; /* the one disappearing */ + + fulltype = sc->full; + + /* refuse to go out of SCREENAUTOPLAY as long as G_FLAGS_AUTOPLAY + is set */ + + if (fulltype != SCREENAUTOPLAY || (G.flags & G_FILE_AUTOPLAY) == 0) { + sc->full= 0; + + /* find old area */ + for(old= sc->areabase.first; old; old= old->next) + if(old->full) break; + if(old==NULL) { + printf("something wrong in areafullscreen\n"); + return; + } + // old feature described below (ton) + // in autoplay screens the headers are disabled by + // default. So use the old headertype instead + + area_copy_data(old, C->area, 1); /* 1 = swap spacelist */ + + old->full= NULL; + + ed_screen_set(C, sc); + + free_screen(oldscreen); + free_libblock(&G.main->screen, oldscreen); + } + } + else { + /* is there only 1 area? */ + if(C->screen->areabase.first==C->screen->areabase.last) return; + if(C->area->spacetype==SPACE_INFO) return; + + C->screen->full = SCREENFULL; + + oldscreen= C->screen; + sc= screen_add(C->window, "temp"); /* sets C->window->screen! */ + + /* returns the top small area */ + newa= area_split(C->window, sc, (ScrArea *)sc->areabase.first, 'h', 0.99f); + area_newspace(C, newa, SPACE_INFO); + + /* copy area */ + newa= newa->prev; + area_copy_data(newa, C->area, 1); /* 1 = swap spacelist */ + + C->area->full= oldscreen; + newa->full= oldscreen; + newa->next->full= oldscreen; + + C->screen= oldscreen; + ed_screen_set(C, sc); + } + + /* XXX bad code: setscreen() ends with first area active. fullscreen render assumes this too */ + C->area= sc->areabase.first; + + /* XXX retopo_force_update(); */ + +} + diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 855fe7c9b50..3ccf3991236 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -33,6 +33,7 @@ struct wmWindow; /* area.c */ void area_copy_data (ScrArea *sa1, ScrArea *sa2, int swap_space); +void area_newspace(bContext *C, ScrArea *sa, int type); /* screen_edit.c */ bScreen *screen_add(struct wmWindow *win, char *name); @@ -49,8 +50,10 @@ void removenotused_scredges(bScreen *sc); int scredge_is_horizontal(ScrEdge *se); ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); -AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); +AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); +void ed_screen_set(bContext *C, bScreen *sc); +void ed_screen_fullarea(bContext *C); #endif /* ED_SCREEN_INTERN_H */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 615e65500fa..efcedc800b1 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -866,6 +866,10 @@ static int screen_set_exec(bContext *C, wmOperator *op) bScreen *screen= C->screen; int delta= RNA_int_get(op->ptr, "delta"); + /* this screen is 'fake', solve later XXX */ + if(C->area->full) + return OPERATOR_CANCELLED; + if(delta==1) { screen= screen->id.next; if(screen==NULL) screen= G.main->screen.first; @@ -879,7 +883,7 @@ static int screen_set_exec(bContext *C, wmOperator *op) } if(screen) { - ED_screen_set(C, screen); + ed_screen_set(C, screen); return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; @@ -898,6 +902,25 @@ void ED_SCR_OT_screen_set(wmOperatorType *ot) RNA_def_property(ot->srna, "delta", PROP_INT, PROP_NONE); } +/* ************** screen full-area operator ***************************** */ + + +/* function to be called outside UI context, or for redo */ +static int screen_full_area_exec(bContext *C, wmOperator *op) +{ + ed_screen_fullarea(C); + return OPERATOR_FINISHED; +} + +void ED_SCR_OT_screen_full_area(wmOperatorType *ot) +{ + ot->name = "Toggle Full Area in Screen"; + ot->idname = "ED_SCR_OT_screen_full_area"; + + ot->exec= screen_full_area_exec; + ot->poll= ED_operator_screenactive; +} + /* ************** join area operator ********************************************** */ @@ -1356,6 +1379,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(ED_SCR_OT_region_split); WM_operatortype_append(ED_SCR_OT_region_flip); WM_operatortype_append(ED_SCR_OT_screen_set); + WM_operatortype_append(ED_SCR_OT_screen_full_area); /*frame changes*/ WM_operatortype_append(ED_SCR_OT_frame_offset); @@ -1378,6 +1402,9 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_verify_item(keymap, "ED_SCR_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 0); RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); + WM_keymap_add_item(keymap, "ED_SCR_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_SCR_OT_screen_full_area", DOWNARROWKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_SCR_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* tests */ RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0)->ptr, "dir", 'h'); |