Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_ops.c
| Show First 20 Lines • Show All 1,370 Lines • ▼ Show 20 Lines | if (event && event->customdata) { | ||||
| actionzone_exit(op); | actionzone_exit(op); | ||||
| } | } | ||||
| return newwin ? OPERATOR_FINISHED : OPERATOR_CANCELLED; | return newwin ? OPERATOR_FINISHED : OPERATOR_CANCELLED; | ||||
| } | } | ||||
| static void SCREEN_OT_area_dupli(wmOperatorType *ot) | static void SCREEN_OT_area_dupli(wmOperatorType *ot) | ||||
| { | { | ||||
| ot->name = "Duplicate Area into New Window"; | ot->name = "Duplicate Area into New Window"; | ||||
Severin: I personally find the proposed name worse :) | |||||
| ot->description = "Duplicate selected area into new window"; | ot->description = "Duplicate selected area into new window"; | ||||
| ot->idname = "SCREEN_OT_area_dupli"; | ot->idname = "SCREEN_OT_area_dupli"; | ||||
| ot->invoke = area_dupli_invoke; | ot->invoke = area_dupli_invoke; | ||||
| ot->poll = ED_operator_areaactive; | ot->poll = ED_operator_areaactive; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Area Close Operator | |||||
| * | |||||
| * Close selected area, replace by expanding a neighbor | |||||
| * \{ */ | |||||
| /* operator callback */ | |||||
| static int area_close_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) | |||||
| { | |||||
| ScrArea *area = CTX_wm_area(C); | |||||
| if ((area != NULL) && screen_area_close(C, CTX_wm_screen(C), area)) { | |||||
| WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| static bool area_close_poll(bContext *C) | |||||
| { | |||||
| if (!ED_operator_areaactive(C)) { | |||||
| return false; | |||||
| } | |||||
| ScrArea *area = CTX_wm_area(C); | |||||
| if (ED_area_is_global(area)) { | |||||
| return false; | |||||
| } | |||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| /* Can this area join with ANY other area? */ | |||||
| LISTBASE_FOREACH (ScrArea *, ar, &screen->areabase) { | |||||
| if (area_getorientation(ar, area) != -1) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| static void SCREEN_OT_area_close(wmOperatorType *ot) | |||||
| { | |||||
Not Done Inline ActionsReturn "true" and "false" here. HooglyBoogly: Return "true" and "false" here. | |||||
| ot->name = "Close Area"; | |||||
| ot->description = "Close selected area"; | |||||
| ot->idname = "SCREEN_OT_area_close"; | |||||
| ot->invoke = area_close_invoke; | |||||
| ot->poll = area_close_poll; | |||||
| } | |||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Move Area Edge Operator | /** \name Move Area Edge Operator | ||||
| * \{ */ | * \{ */ | ||||
| /* operator state vars used: | /* operator state vars used: | ||||
| * x, y mouse coord near edge | * x, y mouse coord near edge | ||||
| * delta movement of edge | * delta movement of edge | ||||
| * | * | ||||
| * functions: | * functions: | ||||
| ▲ Show 20 Lines • Show All 1,809 Lines • ▼ Show 20 Lines | |||||
| * modal() accept modal events while doing it | * modal() accept modal events while doing it | ||||
| * call apply() with active window and nonactive window | * call apply() with active window and nonactive window | ||||
| * call exit() and remove handler when LMB confirm | * call exit() and remove handler when LMB confirm | ||||
| */ | */ | ||||
| typedef struct sAreaJoinData { | typedef struct sAreaJoinData { | ||||
| ScrArea *sa1; /* first area to be considered */ | ScrArea *sa1; /* first area to be considered */ | ||||
| ScrArea *sa2; /* second area to be considered */ | ScrArea *sa2; /* second area to be considered */ | ||||
| void *draw_callback; /* call `ED_screen_draw_join_shape` */ | void *draw_callback; /* call 'ED_screen_draw_join_highlight' */ | ||||
| } sAreaJoinData; | } sAreaJoinData; | ||||
| static void area_join_draw_cb(const struct wmWindow *UNUSED(win), void *userdata) | static void area_join_draw_cb(const struct wmWindow *UNUSED(win), void *userdata) | ||||
| { | { | ||||
| const wmOperator *op = userdata; | const wmOperator *op = userdata; | ||||
| sAreaJoinData *sd = op->customdata; | sAreaJoinData *sd = op->customdata; | ||||
| if (sd->sa1 && sd->sa2) { | if (sd->sa1 && sd->sa2) { | ||||
| ED_screen_draw_join_shape(sd->sa1, sd->sa2); | ED_screen_draw_join_highlight(sd->sa1, sd->sa2); | ||||
| } | } | ||||
| } | } | ||||
| /* validate selection inside screen, set variables OK */ | /* validate selection inside screen, set variables OK */ | ||||
| /* return false: init failed */ | /* return false: init failed */ | ||||
| static bool area_join_init(bContext *C, wmOperator *op, ScrArea *sa1, ScrArea *sa2) | static bool area_join_init(bContext *C, wmOperator *op, ScrArea *sa1, ScrArea *sa2) | ||||
| { | { | ||||
| if (sa1 == NULL || sa2 == NULL) { | if (sa1 == NULL || sa2 == NULL) { | ||||
| ▲ Show 20 Lines • Show All 830 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Region Context Menu Operator (Header/Footer/Navbar) | /** \name Region Context Menu Operator (Header/Footer/Navbar) | ||||
| * \{ */ | * \{ */ | ||||
| static void screen_area_menu_items(ScrArea *area, uiLayout *layout) | |||||
| { | |||||
| if (ED_area_is_global(area)) { | |||||
| return; | |||||
| } | |||||
| PointerRNA ptr; | |||||
Not Done Inline ActionsThe caller should be responsible for making sure the items are separated as needed. What if we want to call this function for an otherwise empty menu? Severin: The caller should be responsible for making sure the items are separated as needed. What if we… | |||||
| /* Mouse position as if in middle of area. */ | |||||
| const int loc[2] = {BLI_rcti_cent_x(&area->totrct), BLI_rcti_cent_y(&area->totrct)}; | |||||
| /* Vertical Split */ | |||||
| uiItemFullO(layout, | |||||
Not Done Inline ActionsUse BLI_rcti_cent_x()/y. Severin: Use `BLI_rcti_cent_x()`/`y`.
Can also be `const` it seems. | |||||
| "SCREEN_OT_area_split", | |||||
| IFACE_("Vertical Split"), | |||||
| ICON_NONE, | |||||
| NULL, | |||||
| WM_OP_INVOKE_DEFAULT, | |||||
| 0, | |||||
| &ptr); | |||||
| RNA_int_set_array(&ptr, "cursor", loc); | |||||
Not Done Inline ActionsShould be static natecraddock: Should be `static` | |||||
| RNA_enum_set(&ptr, "direction", 'v'); | |||||
| /* Horizontal Split */ | |||||
Not Done Inline ActionsWhy &loc[0]? Should be able to just pass loc as is. Severin: Why `&loc[0]`? Should be able to just pass `loc` as is. | |||||
| uiItemFullO(layout, | |||||
| "SCREEN_OT_area_split", | |||||
| IFACE_("Horizontal Split"), | |||||
| ICON_NONE, | |||||
| NULL, | |||||
| WM_OP_INVOKE_DEFAULT, | |||||
| 0, | |||||
| &ptr); | |||||
| RNA_int_set_array(&ptr, "cursor", &loc[0]); | |||||
| RNA_enum_set(&ptr, "direction", 'h'); | |||||
| uiItemS(layout); | |||||
| if (area->spacetype != SPACE_FILE) { | |||||
| uiItemO(layout, | |||||
| area->full ? IFACE_("Restore Areas") : IFACE_("Maximize Area"), | |||||
| ICON_NONE, | |||||
| "SCREEN_OT_screen_full_area"); | |||||
| if (!area->full) { | |||||
| uiItemFullO(layout, | |||||
| "SCREEN_OT_screen_full_area", | |||||
| IFACE_("Full Screen Area"), | |||||
| ICON_NONE, | |||||
| NULL, | |||||
| WM_OP_INVOKE_DEFAULT, | |||||
| 0, | |||||
| &ptr); | |||||
| RNA_boolean_set(&ptr, "use_hide_panels", true); | |||||
| } | |||||
| } | |||||
| uiItemO(layout, NULL, ICON_NONE, "SCREEN_OT_area_dupli"); | |||||
| uiItemS(layout); | |||||
| uiItemO(layout, NULL, ICON_NONE, "SCREEN_OT_area_close"); | |||||
| } | |||||
| void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) | void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ? | const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ? | ||||
| IFACE_("Flip to Bottom") : | IFACE_("Flip to Bottom") : | ||||
| IFACE_("Flip to Top"); | IFACE_("Flip to Top"); | ||||
| { | { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr); | RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr); | ||||
Not Done Inline ActionsBetter commit separately. Severin: Better commit separately. | |||||
| if (!ELEM(area->spacetype, SPACE_TOPBAR)) { | if (!ELEM(area->spacetype, SPACE_TOPBAR)) { | ||||
Not Done Inline ActionsI would prefer to consistently use capitals for these actions: "Flip Header to Bottom", etc.. This comment also applies to the operators below in this function. HooglyBoogly: I would prefer to consistently use capitals for these actions: "Flip Header to Bottom", etc.. | |||||
| uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE); | uiItemR(layout, &ptr, "show_region_header", 0, IFACE_("Show Header"), ICON_NONE); | ||||
| } | } | ||||
| ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); | ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER); | ||||
| uiLayout *col = uiLayoutColumn(layout, 0); | uiLayout *col = uiLayoutColumn(layout, 0); | ||||
| uiLayoutSetActive(col, (region_header->flag & RGN_FLAG_HIDDEN) == 0); | uiLayoutSetActive(col, (region_header->flag & RGN_FLAG_HIDDEN) == 0); | ||||
| if (BKE_area_find_region_type(area, RGN_TYPE_TOOL_HEADER)) { | if (BKE_area_find_region_type(area, RGN_TYPE_TOOL_HEADER)) { | ||||
| uiItemR(col, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE); | uiItemR(col, &ptr, "show_region_tool_header", 0, IFACE_("Show Tool Settings"), ICON_NONE); | ||||
| } | } | ||||
| uiItemO(col, | uiItemO(col, | ||||
| IFACE_("Show Menus"), | IFACE_("Show Menus"), | ||||
| (area->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT, | (area->flag & HEADER_NO_PULLDOWN) ? ICON_CHECKBOX_DEHLT : ICON_CHECKBOX_HLT, | ||||
| "SCREEN_OT_header_toggle_menus"); | "SCREEN_OT_header_toggle_menus"); | ||||
| } | } | ||||
| /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ | /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ | ||||
| uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); | uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); | ||||
| if (!ELEM(area->spacetype, SPACE_TOPBAR)) { | if (!ELEM(area->spacetype, SPACE_TOPBAR)) { | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); | uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); | ||||
| } | |||||
| /* File browser should be fullscreen all the time, top-bar should | |||||
| * never be. But other regions can be maximized/restored. */ | |||||
| if (!ELEM(area->spacetype, SPACE_FILE, SPACE_TOPBAR)) { | |||||
| uiItemS(layout); | uiItemS(layout); | ||||
Not Done Inline ActionsBetter commit separately. Severin: Better commit separately. | |||||
| screen_area_menu_items(area, layout); | |||||
| const char *but_str = area->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); | |||||
| uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area"); | |||||
| } | } | ||||
| } | } | ||||
| void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) | void ED_screens_footer_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ? | const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_TOP) ? | ||||
| IFACE_("Flip to Bottom") : | IFACE_("Flip to Bottom") : | ||||
| IFACE_("Flip to Top"); | IFACE_("Flip to Top"); | ||||
| { | { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr); | RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, area->spacedata.first, &ptr); | ||||
Not Done Inline ActionsBetter commit separately. Severin: Better commit separately. | |||||
| uiItemR(layout, &ptr, "show_region_footer", 0, IFACE_("Show Footer"), ICON_NONE); | uiItemR(layout, &ptr, "show_region_footer", 0, IFACE_("Show Footer"), ICON_NONE); | ||||
| } | } | ||||
| /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ | /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ | ||||
| uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); | uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); | ||||
| uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); | uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); | ||||
| /* File browser should be fullscreen all the time, top-bar should | |||||
| * never be. But other regions can be maximized/restored... */ | |||||
| if (!ELEM(area->spacetype, SPACE_FILE, SPACE_TOPBAR)) { | |||||
| uiItemS(layout); | uiItemS(layout); | ||||
| screen_area_menu_items(area, layout); | |||||
| const char *but_str = area->full ? IFACE_("Tile Area") : IFACE_("Maximize Area"); | |||||
| uiItemO(layout, but_str, ICON_NONE, "SCREEN_OT_screen_full_area"); | |||||
| } | |||||
| } | } | ||||
| void ED_screens_navigation_bar_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) | void ED_screens_navigation_bar_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) | ||||
| { | { | ||||
| const ARegion *region = CTX_wm_region(C); | const ARegion *region = CTX_wm_region(C); | ||||
| const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_LEFT) ? | const char *but_flip_str = (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_LEFT) ? | ||||
| IFACE_("Flip to Right") : | IFACE_("Flip to Right") : | ||||
| IFACE_("Flip to Left"); | IFACE_("Flip to Left"); | ||||
| /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ | /* default is WM_OP_INVOKE_REGION_WIN, which we don't want here. */ | ||||
Not Done Inline ActionsBetter commit separately. Severin: Better commit separately. | |||||
| uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); | uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); | ||||
| uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); | uiItemO(layout, but_flip_str, ICON_NONE, "SCREEN_OT_region_flip"); | ||||
| } | } | ||||
| static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg)) | static void ed_screens_statusbar_menu_create(uiLayout *layout, void *UNUSED(arg)) | ||||
| { | { | ||||
| PointerRNA ptr; | PointerRNA ptr; | ||||
| RNA_pointer_create(NULL, &RNA_PreferencesView, &U, &ptr); | RNA_pointer_create(NULL, &RNA_PreferencesView, &U, &ptr); | ||||
| uiItemR(layout, &ptr, "show_statusbar_stats", 0, IFACE_("Scene Statistics"), ICON_NONE); | uiItemR(layout, &ptr, "show_statusbar_stats", 0, IFACE_("Scene Statistics"), ICON_NONE); | ||||
| uiItemR(layout, &ptr, "show_statusbar_memory", 0, IFACE_("System Memory"), ICON_NONE); | uiItemR(layout, &ptr, "show_statusbar_memory", 0, IFACE_("System Memory"), ICON_NONE); | ||||
| if (GPU_mem_stats_supported()) { | if (GPU_mem_stats_supported()) { | ||||
| uiItemR(layout, &ptr, "show_statusbar_vram", 0, IFACE_("Video Memory"), ICON_NONE); | uiItemR(layout, &ptr, "show_statusbar_vram", 0, IFACE_("Video Memory"), ICON_NONE); | ||||
| } | } | ||||
| uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE); | uiItemR(layout, &ptr, "show_statusbar_version", 0, IFACE_("Blender Version"), ICON_NONE); | ||||
| } | } | ||||
| static int screen_context_menu_invoke(bContext *C, | static int screen_context_menu_invoke(bContext *C, | ||||
Not Done Inline ActionsUnused variable natecraddock: Unused variable | |||||
| wmOperator *UNUSED(op), | wmOperator *UNUSED(op), | ||||
| const wmEvent *UNUSED(event)) | const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| const ScrArea *area = CTX_wm_area(C); | const ScrArea *area = CTX_wm_area(C); | ||||
| const ARegion *region = CTX_wm_region(C); | const ARegion *region = CTX_wm_region(C); | ||||
| if (area && area->spacetype == SPACE_STATUSBAR) { | if (area && area->spacetype == SPACE_STATUSBAR) { | ||||
| uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE); | uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Status Bar"), ICON_NONE); | ||||
| ▲ Show 20 Lines • Show All 1,274 Lines • ▼ Show 20 Lines | void ED_operatortypes_screen(void) | ||||
| WM_operatortype_append(SCREEN_OT_repeat_last); | WM_operatortype_append(SCREEN_OT_repeat_last); | ||||
| WM_operatortype_append(SCREEN_OT_repeat_history); | WM_operatortype_append(SCREEN_OT_repeat_history); | ||||
| WM_operatortype_append(SCREEN_OT_redo_last); | WM_operatortype_append(SCREEN_OT_redo_last); | ||||
| /* screen tools */ | /* screen tools */ | ||||
| WM_operatortype_append(SCREEN_OT_area_move); | WM_operatortype_append(SCREEN_OT_area_move); | ||||
| WM_operatortype_append(SCREEN_OT_area_split); | WM_operatortype_append(SCREEN_OT_area_split); | ||||
| WM_operatortype_append(SCREEN_OT_area_join); | WM_operatortype_append(SCREEN_OT_area_join); | ||||
| WM_operatortype_append(SCREEN_OT_area_close); | |||||
| WM_operatortype_append(SCREEN_OT_area_options); | WM_operatortype_append(SCREEN_OT_area_options); | ||||
| WM_operatortype_append(SCREEN_OT_area_dupli); | WM_operatortype_append(SCREEN_OT_area_dupli); | ||||
| WM_operatortype_append(SCREEN_OT_area_swap); | WM_operatortype_append(SCREEN_OT_area_swap); | ||||
| WM_operatortype_append(SCREEN_OT_region_quadview); | WM_operatortype_append(SCREEN_OT_region_quadview); | ||||
| WM_operatortype_append(SCREEN_OT_region_scale); | WM_operatortype_append(SCREEN_OT_region_scale); | ||||
| WM_operatortype_append(SCREEN_OT_region_toggle); | WM_operatortype_append(SCREEN_OT_region_toggle); | ||||
| WM_operatortype_append(SCREEN_OT_region_flip); | WM_operatortype_append(SCREEN_OT_region_flip); | ||||
| WM_operatortype_append(SCREEN_OT_header_toggle_menus); | WM_operatortype_append(SCREEN_OT_header_toggle_menus); | ||||
| ▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines | |||||
I personally find the proposed name worse :)