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:
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c27
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h1
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c41
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c1
4 files changed, 50 insertions, 20 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index e0a5158e510..9228853ed19 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -1133,7 +1133,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ButsContextPath *path = sbuts->path;
- uiLayout *row;
+ uiLayout *row, *sub;
uiBlock *block;
uiBut *but;
PointerRNA *ptr;
@@ -1199,25 +1199,12 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
uiItemSpacer(row);
- block = uiLayoutGetBlock(row);
- UI_block_emboss_set(block, UI_EMBOSS_NONE);
- but = uiDefIconButBitC(block,
- UI_BTYPE_ICON_TOGGLE,
- SB_PIN_CONTEXT,
- 0,
- ICON_UNPINNED,
- 0,
- 0,
- UI_UNIT_X,
- UI_UNIT_Y,
- &sbuts->flag,
- 0,
- 0,
- 0,
- 0,
- TIP_("Follow context or keep fixed data-block displayed"));
- UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */
- UI_but_func_set(but, pin_cb, NULL, NULL);
+ sub = uiLayoutRow(row, false);
+ uiLayoutSetEmboss(sub, UI_EMBOSS_NONE);
+ uiItemO(sub,
+ "",
+ (sbuts->flag & SB_PIN_CONTEXT) ? ICON_PINNED : ICON_UNPINNED,
+ "BUTTONS_OT_toggle_pin");
}
#ifdef USE_HEADER_CONTEXT_PATH
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 911cf4526bb..a1e2b9e9aaf 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -93,6 +93,7 @@ extern const char *buttons_context_dir[]; /* doc access */
void buttons_texture_context_compute(const struct bContext *C, struct SpaceProperties *sbuts);
/* buttons_ops.c */
+void BUTTONS_OT_toggle_pin(struct wmOperatorType *ot);
void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
void BUTTONS_OT_directory_browse(struct wmOperatorType *ot);
void BUTTONS_OT_context_menu(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index a062b178fc8..2e6ad82ef08 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -53,6 +53,47 @@
#include "buttons_intern.h" /* own include */
/* -------------------------------------------------------------------- */
+/** \name Pin ID Operator
+ * \{ */
+
+static int toggle_pin_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ SpaceProperties *sbuts = CTX_wm_space_properties(C);
+
+ sbuts->flag ^= SB_PIN_CONTEXT;
+
+ /* Create the properties space pointer. */
+ PointerRNA sbuts_ptr;
+ bScreen *screen = CTX_wm_screen(C);
+ RNA_pointer_create(&screen->id, &RNA_SpaceProperties, sbuts, &sbuts_ptr);
+
+ /* Create the new ID pointer and set the the pin ID with RNA
+ * so we can use the property's RNA update functionality. */
+ ID *new_id = (sbuts->flag & SB_PIN_CONTEXT) ? buttons_context_id_path(C) : NULL;
+ PointerRNA new_id_ptr;
+ RNA_id_pointer_create(new_id, &new_id_ptr);
+ RNA_pointer_set(&sbuts_ptr, "pin_id", new_id_ptr);
+
+ ED_area_tag_redraw(CTX_wm_area(C));
+
+ return OPERATOR_FINISHED;
+}
+
+void BUTTONS_OT_toggle_pin(wmOperatorType *ot)
+{
+ /* Identifiers. */
+ ot->name = "Toggle Pin ID";
+ ot->description = "Keep the current data-block displayed";
+ ot->idname = "BUTTONS_OT_toggle_pin";
+
+ /* Callbacks. */
+ ot->exec = toggle_pin_exec;
+ ot->poll = ED_operator_buttons_active;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Context Menu Operator
* \{ */
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index fd713e7094a..3b7fe45f9c8 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -328,6 +328,7 @@ static void buttons_main_region_listener(wmWindow *UNUSED(win),
static void buttons_operatortypes(void)
{
+ WM_operatortype_append(BUTTONS_OT_toggle_pin);
WM_operatortype_append(BUTTONS_OT_context_menu);
WM_operatortype_append(BUTTONS_OT_file_browse);
WM_operatortype_append(BUTTONS_OT_directory_browse);