diff options
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 22 | ||||
-rw-r--r-- | source/blender/editors/screen/workspace_edit.c | 30 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_topbar/space_topbar.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_workspace.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 49 |
7 files changed, 88 insertions, 24 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 05ae5299e58..96d31700eb9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1024,6 +1024,26 @@ static const char *template_id_browse_tip(const StructRNA *type) } /** + * Add a superimposed extra icon to \a but, for workspace pinning. + * Rather ugly special handling, but this is really a special case at this point, nothing worth + * generalizing. + */ +static void template_id_workspace_pin_extra_icon(const TemplateID *template_ui, uiBut *but) +{ + if ((template_ui->idcode != ID_SCE) || (template_ui->ptr.type != &RNA_Window)) { + return; + } + + const wmWindow *win = template_ui->ptr.data; + const WorkSpace *workspace = WM_window_get_active_workspace(win); + UI_but_extra_operator_icon_add(but, + "WORKSPACE_OT_scene_pin_toggle", + WM_OP_INVOKE_DEFAULT, + (workspace->flags & WORKSPACE_USE_PIN_SCENE) ? ICON_PINNED : + ICON_UNPINNED); +} + +/** * \return a type-based i18n context, needed e.g. by "New" button. * In most languages, this adjective takes different form based on gender of type name... */ @@ -1220,6 +1240,8 @@ static void template_ID(const bContext *C, UI_but_flag_enable(but, UI_BUT_REDALERT); } + template_id_workspace_pin_extra_icon(template_ui, but); + if (ID_IS_LINKED(id)) { const bool disabled = !BKE_idtype_idcode_is_localizable(GS(id->name)); if (id->tag & LIB_TAG_INDIRECT) { diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 0535a270176..cb29f15420c 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -585,6 +585,35 @@ static void WORKSPACE_OT_reorder_to_front(wmOperatorType *ot) ot->exec = workspace_reorder_to_front_exec; } +static int workspace_scene_pin_toggle(bContext *C, wmOperator *UNUSED(op)) +{ + WorkSpace *workspace = workspace_context_get(C); + + /* Trivial. The operator is only needed to display a superimposed extra icon, which + * requires an operator. */ + workspace->flags ^= WORKSPACE_USE_PIN_SCENE; + + WM_event_add_notifier(C, NC_WORKSPACE, NULL); + + return OPERATOR_FINISHED; +} + +static void WORKSPACE_OT_scene_pin_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Pin Scene to Workspace"; + ot->description = + "Remember the last used scene for the current workspace and switch to it whenever this " + "workspace is activated again"; + ot->idname = "WORKSPACE_OT_scene_pin_toggle"; + + /* api callbacks */ + ot->poll = workspace_context_poll; + ot->exec = workspace_scene_pin_toggle; + + ot->flag = OPTYPE_INTERNAL; +} + void ED_operatortypes_workspace(void) { WM_operatortype_append(WORKSPACE_OT_duplicate); @@ -593,6 +622,7 @@ void ED_operatortypes_workspace(void) WM_operatortype_append(WORKSPACE_OT_append_activate); WM_operatortype_append(WORKSPACE_OT_reorder_to_back); WM_operatortype_append(WORKSPACE_OT_reorder_to_front); + WM_operatortype_append(WORKSPACE_OT_scene_pin_toggle); } /** \} Workspace Operators */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 052af39319c..e60946b8f66 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -778,6 +778,9 @@ static void buttons_area_listener(const wmSpaceTypeListenerParams *params) sbuts->preview = 1; } break; + case NC_WORKSPACE: + buttons_area_redraw(area, BCONTEXT_TOOL); + break; case NC_SPACE: if (wmn->data == ND_SPACE_PROPERTIES) { ED_area_tag_redraw(area); diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index e9a9e690e60..bc68de1dfce 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -155,6 +155,9 @@ static void topbar_header_listener(const wmRegionListenerParams *params) ED_region_tag_redraw(region); } break; + case NC_WORKSPACE: + ED_region_tag_redraw(region); + break; case NC_SPACE: if (wmn->data == ND_SPACE_INFO) { ED_region_tag_redraw(region); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 9ed2fec96db..a423a842019 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1300,6 +1300,10 @@ static void view3d_main_region_listener(const wmRegionListenerParams *params) ED_region_tag_redraw(region); } break; + case NC_WORKSPACE: + /* In case the region displays workspace settings. */ + ED_region_tag_redraw(region); + break; } } diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index 4873831abce..a0d89b8b15a 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -419,6 +419,7 @@ static void rna_def_workspace(BlenderRNA *brna) "Pin Scene", "Remember the last used scene for the workspace and switch to it " "whenever this workspace is activated again"); + RNA_def_property_update(prop, NC_WORKSPACE, NULL); /* Flags */ prop = RNA_def_property(srna, "use_filter_by_owner", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index aebd62ee91b..32bc2f96365 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -323,34 +323,35 @@ typedef struct wmNotifier { #define NOTE_CATEGORY 0xFF000000 #define NC_WM (1 << 24) #define NC_WINDOW (2 << 24) -#define NC_SCREEN (3 << 24) -#define NC_SCENE (4 << 24) -#define NC_OBJECT (5 << 24) -#define NC_MATERIAL (6 << 24) -#define NC_TEXTURE (7 << 24) -#define NC_LAMP (8 << 24) -#define NC_GROUP (9 << 24) -#define NC_IMAGE (10 << 24) -#define NC_BRUSH (11 << 24) -#define NC_TEXT (12 << 24) -#define NC_WORLD (13 << 24) -#define NC_ANIMATION (14 << 24) +#define NC_WORKSPACE (3 << 24) +#define NC_SCREEN (4 << 24) +#define NC_SCENE (5 << 24) +#define NC_OBJECT (6 << 24) +#define NC_MATERIAL (7 << 24) +#define NC_TEXTURE (8 << 24) +#define NC_LAMP (9 << 24) +#define NC_GROUP (10 << 24) +#define NC_IMAGE (11 << 24) +#define NC_BRUSH (12 << 24) +#define NC_TEXT (13 << 24) +#define NC_WORLD (14 << 24) +#define NC_ANIMATION (15 << 24) /* When passing a space as reference data with this (e.g. `WM_event_add_notifier(..., space)`), * the notifier will only be sent to this space. That avoids unnecessary updates for unrelated * spaces. */ -#define NC_SPACE (15 << 24) -#define NC_GEOM (16 << 24) -#define NC_NODE (17 << 24) -#define NC_ID (18 << 24) -#define NC_PAINTCURVE (19 << 24) -#define NC_MOVIECLIP (20 << 24) -#define NC_MASK (21 << 24) -#define NC_GPENCIL (22 << 24) -#define NC_LINESTYLE (23 << 24) -#define NC_CAMERA (24 << 24) -#define NC_LIGHTPROBE (25 << 24) +#define NC_SPACE (16 << 24) +#define NC_GEOM (17 << 24) +#define NC_NODE (18 << 24) +#define NC_ID (19 << 24) +#define NC_PAINTCURVE (20 << 24) +#define NC_MOVIECLIP (21 << 24) +#define NC_MASK (22 << 24) +#define NC_GPENCIL (23 << 24) +#define NC_LINESTYLE (24 << 24) +#define NC_CAMERA (25 << 24) +#define NC_LIGHTPROBE (26 << 24) /* Changes to asset data in the current .blend. */ -#define NC_ASSET (26 << 24) +#define NC_ASSET (27 << 24) /* data type, 256 entries is enough, it can overlap */ #define NOTE_DATA 0x00FF0000 |