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:
authorHans Goudey <h.goudey@me.com>2020-09-11 22:08:38 +0300
committerHans Goudey <h.goudey@me.com>2020-09-11 22:08:38 +0300
commita55093711644f1a87eb058d2bed20d530a4de155 (patch)
tree2406e19c3dc370e4360fd2540f8f6b64a9d89b3b /source/blender/editors/space_buttons/buttons_ops.c
parente22e30283714d03d0b57ebfa3a4dcda35c808c86 (diff)
UI: Use operator to set property editor's pinned data-block
This commit removes the custom callback that's currently used to set the property editor's pinned data, replacing it with an operator. This means "pin" button doesn't have to be defined in C. Differential Revision: https://developer.blender.org/D8376
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_ops.c')
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c41
1 files changed, 41 insertions, 0 deletions
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
* \{ */