Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2022-07-07 19:14:05 +0300
committerJulian Eisel <julian@blender.org>2022-07-07 19:14:05 +0300
commitb8605ee458e31420a4e6653c223f841c5875a21d (patch)
treed0ad4bcde49c7b53ae40d8c280bf8148f4c8096b /source/blender/editors/screen
parente0cc86978c0f72f57240214ccb6bc7fe71428827 (diff)
UI: Superimposed pin icon for workspace scene pinning in the scene switcher
Followup to the previous commit, to display a pin icon in the scene switcher. This is a good indicator to have and such workspace-wide functionality should be available in the topbar, close to what it belongs to (scene switching). Downside is that it makes this already crowded region even more crowded. But thanks to the use of superimposed icons, it's not too noisy visually. Differential Revision: https://developer.blender.org/D11890 Reviewed by: Campbell Barton
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/workspace_edit.c30
1 files changed, 30 insertions, 0 deletions
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 */