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/interface/interface_templates.c
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/interface/interface_templates.c')
-rw-r--r--source/blender/editors/interface/interface_templates.c22
1 files changed, 22 insertions, 0 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) {