diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-17 20:33:45 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-17 20:33:45 +0300 |
commit | 6634ed9a872ac7f5417ba9d6472a4a568f64d68d (patch) | |
tree | ce861078c2afee13a49d321c2899481914583a9e | |
parent | 065155a17d468fd0655069f3c75af3c5fea69fa9 (diff) |
2.5
Added screen-set notifier. Works for arrow keys now. For those who
know the messy old code, admire the simple 2-function call method
now :) Only context setting is messy a bit, that'll be solved.
Also: removed redundant code, and move freeing window handlers up
one level; windows can keep their handlers while screen switches.
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 29 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 49 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_init_exit.c | 5 |
4 files changed, 77 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 7b4dd41e4a8..2c0101f3542 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -72,6 +72,7 @@ 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/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 13c0f545a8a..b325bb8e5d8 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1048,7 +1048,6 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) for(sa= screen->areabase.first; sa; sa= sa->next) ED_area_exit(C, sa); - WM_event_remove_handlers(C, &window->handlers); C->window= prevwin; } @@ -1153,3 +1152,31 @@ int ED_screen_area_active(const bContext *C) } return 0; } + +/* operator call, WM + Window + screen already existed before */ +/* Do NOT call in area/region queues! */ +void ED_screen_set(bContext *C, bScreen *sc) +{ + + if(sc->full) { /* find associated full */ + bScreen *sc1; + for(sc1= G.main->screen.first; sc1; sc1= sc1->id.next) { + ScrArea *sa= sc1->areabase.first; + if(sa->full==sc) { + sc= sc1; + break; + } + } + if(sc1==NULL) printf("setscreen error\n"); + } + + if (C->screen != sc) { + ED_screen_exit(C, C->window, C->screen); + C->window->screen= sc; + C->screen= sc; + + ED_screen_refresh(C->wm, C->window); + WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); + } +} + diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 23f850ed027..615e65500fa 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -857,6 +857,49 @@ void ED_SCR_OT_frame_offset(wmOperatorType *ot) RNA_def_property(ot->srna, "delta", PROP_INT, PROP_NONE); } +/* ************** switch screen operator ***************************** */ + + +/* function to be called outside UI context, or for redo */ +static int screen_set_exec(bContext *C, wmOperator *op) +{ + bScreen *screen= C->screen; + int delta= RNA_int_get(op->ptr, "delta"); + + if(delta==1) { + screen= screen->id.next; + if(screen==NULL) screen= G.main->screen.first; + } + else if(delta== -1) { + screen= screen->id.prev; + if(screen==NULL) screen= G.main->screen.last; + } + else { + screen= NULL; + } + + if(screen) { + ED_screen_set(C, screen); + return OPERATOR_FINISHED; + } + return OPERATOR_CANCELLED; +} + +void ED_SCR_OT_screen_set(wmOperatorType *ot) +{ + ot->name = "Set Screen"; + ot->idname = "ED_SCR_OT_screen_set"; + + ot->exec= screen_set_exec; + ot->poll= ED_operator_screenactive; + + /* rna */ + RNA_def_property(ot->srna, "screen", PROP_POINTER, PROP_NONE); + RNA_def_property(ot->srna, "delta", PROP_INT, PROP_NONE); +} + + + /* ************** join area operator ********************************************** */ /* operator state vars used: @@ -1312,7 +1355,8 @@ void ED_operatortypes_screen(void) WM_operatortype_append(ED_SCR_OT_area_rip); WM_operatortype_append(ED_SCR_OT_region_split); WM_operatortype_append(ED_SCR_OT_region_flip); - + WM_operatortype_append(ED_SCR_OT_screen_set); + /*frame changes*/ WM_operatortype_append(ED_SCR_OT_frame_offset); @@ -1332,10 +1376,13 @@ void ED_keymap_screen(wmWindowManager *wm) WM_keymap_verify_item(keymap, "ED_SCR_OT_area_split", EVT_ACTIONZONE, 0, 0, 0); /* action tria */ 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); + 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); /* tests */ RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0)->ptr, "dir", 'h'); RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "dir", 'v'); + /*frame offsets*/ RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10); RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 4d170ceeb46..8727a9cadfe 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -167,14 +167,9 @@ void WM_exit(bContext *C) /* modal handlers are on window level freed, others too? */ if(C && C->wm) { for(win= C->wm->windows.first; win; win= win->next) { - ARegion *ar; C->window= win; /* needed by operator close callbacks */ WM_event_remove_handlers(C, &win->handlers); - - for(ar= win->screen->regionbase.first; ar; ar= ar->next) - WM_event_remove_handlers(C, &ar->handlers); - ED_screen_exit(C, win, win->screen); } } |