diff options
Diffstat (limited to 'source/blender/editors/screen/screen_ops.c')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 109 |
1 files changed, 81 insertions, 28 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5eac841dec6..bd171ef247a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -192,7 +192,7 @@ int ED_operator_region_view3d_active(bContext *C) return TRUE; CTX_wm_operator_poll_msg_set(C, "expected a view3d region"); - return FALSE; + return FALSE; } /* generic for any view2d which uses anim_ops */ @@ -256,7 +256,7 @@ int ED_operator_node_active(bContext *C) return 0; } -// XXX rename +/* XXX rename */ int ED_operator_graphedit_active(bContext *C) { return ed_spacetype_test(C, SPACE_IPO); @@ -580,7 +580,7 @@ static int actionzone_area_poll(bContext *C) for (az = sa->actionzones.first; az; az = az->next) if (BLI_rcti_isect_pt(&az->rect, x, y)) return 1; - } + } return 0; } @@ -628,6 +628,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) event.type = EVT_ACTIONZONE_AREA; else event.type = EVT_ACTIONZONE_REGION; + event.val = 0; event.customdata = op->customdata; event.customdatafree = TRUE; op->customdata = NULL; @@ -701,7 +702,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) case ESCKEY: actionzone_exit(op); return OPERATOR_CANCELLED; - case LEFTMOUSE: + case LEFTMOUSE: actionzone_exit(op); return OPERATOR_CANCELLED; @@ -969,18 +970,18 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller /* if top or down edge selected, test height */ if (sa->v1->flag && sa->v4->flag) - *bigger = MIN2(*bigger, y1); + *bigger = min_ii(*bigger, y1); else if (sa->v2->flag && sa->v3->flag) - *smaller = MIN2(*smaller, y1); + *smaller = min_ii(*smaller, y1); } else { int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX; /* if left or right edge selected, test width */ if (sa->v1->flag && sa->v2->flag) - *bigger = MIN2(*bigger, x1); + *bigger = min_ii(*bigger, x1); else if (sa->v3->flag && sa->v4->flag) - *smaller = MIN2(*smaller, x1); + *smaller = min_ii(*smaller, x1); } } } @@ -1341,7 +1342,7 @@ static int area_split_apply(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return 1; - } + } return 0; } @@ -1691,7 +1692,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) AZone *az; if (event->type != EVT_ACTIONZONE_REGION) { - BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); + BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } @@ -1855,7 +1856,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) break; case ESCKEY: - ; + break; } return OPERATOR_RUNNING_MODAL; @@ -2071,15 +2072,23 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) /* ************** switch screen operator ***************************** */ +static int screen_set_is_ok(bScreen *screen, bScreen *screen_prev) +{ + return ((screen->winid == 0) && + (screen->full == 0) && + (screen != screen_prev) && + (screen->id.name[2] != '.' || !(U.uiflag & USER_HIDE_DOT))); +} /* function to be called outside UI context, or for redo */ static int screen_set_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bScreen *screen = CTX_wm_screen(C); bScreen *screen_prev = screen; ScrArea *sa = CTX_wm_area(C); - int tot = BLI_countlist(&CTX_data_main(C)->screen); + int tot = BLI_countlist(&bmain->screen); int delta = RNA_int_get(op->ptr, "delta"); /* temp screens are for userpref or render display */ @@ -2089,17 +2098,19 @@ static int screen_set_exec(bContext *C, wmOperator *op) if (delta == 1) { while (tot--) { screen = screen->id.next; - if (screen == NULL) screen = CTX_data_main(C)->screen.first; - if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) + if (screen == NULL) screen = bmain->screen.first; + if (screen_set_is_ok(screen, screen_prev)) { break; + } } } else if (delta == -1) { while (tot--) { screen = screen->id.prev; - if (screen == NULL) screen = CTX_data_main(C)->screen.last; - if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) + if (screen == NULL) screen = bmain->screen.last; + if (screen_set_is_ok(screen, screen_prev)) { break; + } } } else { @@ -2359,14 +2370,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa = screen_areahascursor(sc, event->x, event->y); int dir; - if (sa) { + if (sa) { if (jd->sa1 != sa) { dir = area_getorientation(jd->sa1, sa); if (dir >= 0) { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = sa; jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - } + } else { /* we are not bordering on the previously selected area * we check if area has common border with the one marked for removal @@ -2380,14 +2391,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) jd->sa2 = sa; if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - } + } else { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = NULL; } } WM_event_add_notifier(C, NC_WINDOW, NULL); - } + } else { /* we are back in the area previously selected for keeping * we swap the areas if possible to allow user to choose */ @@ -2402,7 +2413,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) if (dir < 0) { printf("oops, didn't expect that!\n"); } - } + } else { dir = area_getorientation(jd->sa1, sa); if (dir >= 0) { @@ -2837,7 +2848,7 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) /* don't do anything if no region */ if (ar == NULL) return OPERATOR_CANCELLED; - } + } /* copied from SCREEN_OT_region_flip */ if (ar->alignment == RGN_ALIGN_TOP) @@ -2871,6 +2882,38 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) ot->flag = 0; } + + +/* ************** show menus operator ***************************** */ + +/* show/hide header text menus */ +static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ScrArea *sa = CTX_wm_area(C); + + sa->flag = sa->flag ^ HEADER_NO_PULLDOWN; + + ED_area_tag_redraw(CTX_wm_area(C)); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + + +static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Show/Hide Header Menus"; + ot->idname = "SCREEN_OT_header_toggle_menus"; + ot->description = "Show or hide the header pulldown menus"; + + /* api callbacks */ + ot->exec = header_toggle_menus_exec; + ot->poll = ED_operator_areaactive; + ot->flag = 0; +} + + /* ************** header tools operator ***************************** */ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { @@ -2883,6 +2926,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN else uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip"); + if (sa->flag & HEADER_NO_PULLDOWN) + uiItemO(layout, IFACE_("Show Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus"); + else + uiItemO(layout, IFACE_("Hide Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus"); + uiItemS(layout); /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */ @@ -3035,7 +3083,11 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e } else { if (sync) { - int step = floor((wt->duration - sad->last_duration) * FPS); + /* note: this is very simplistic, + * its has problem that it may skip too many frames. + * however at least this gives a less jittery playback */ + const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS)); + /* skip frames */ if (sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra -= step; @@ -3125,7 +3177,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* recalculate the timestep for the timer now that we've finished calculating this, * since the frames-per-second value may have been changed */ - // TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? + /* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */ wt->timestep = (1.0 / FPS); return OPERATOR_FINISHED; @@ -3175,7 +3227,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) else { int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ - if (mode == 1) // XXX only play audio forwards!? + if (mode == 1) /* XXX only play audio forwards!? */ sound_play_scene(scene); ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode); @@ -3427,7 +3479,7 @@ static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) static void SCREEN_OT_delete(wmOperatorType *ot) { /* identifiers */ - ot->name = "Delete Screen"; //was scene + ot->name = "Delete Screen"; /* was scene */ ot->description = "Delete active screen"; ot->idname = "SCREEN_OT_delete"; @@ -3547,6 +3599,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_region_scale); WM_operatortype_append(SCREEN_OT_region_flip); WM_operatortype_append(SCREEN_OT_header_flip); + WM_operatortype_append(SCREEN_OT_header_toggle_menus); WM_operatortype_append(SCREEN_OT_header_toolbox); WM_operatortype_append(SCREEN_OT_screen_set); WM_operatortype_append(SCREEN_OT_screen_full_area); @@ -3574,7 +3627,7 @@ void ED_operatortypes_screen(void) /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_undo_push); - WM_operatortype_append(ED_OT_redo); + WM_operatortype_append(ED_OT_redo); WM_operatortype_append(ED_OT_undo_history); } @@ -3744,7 +3797,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", MEDIASTOP, KM_PRESS, 0, 0); /* Alternative keys for animation and sequencer playing */ -#if 0 // XXX: disabled for restoring later... bad implementation +#if 0 /* XXX: disabled for restoring later... bad implementation */ keymap = WM_keymap_find(keyconf, "Frames", 0, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); |