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:
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c49
-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.c3
4 files changed, 55 insertions, 39 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index e567b3ca54c..84a020a9ed7 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -333,8 +333,10 @@ static bool buttons_context_path_material(ButsContextPath *path)
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
ma = BKE_object_material_get(ob, ob->actcol);
- RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
- path->len++;
+ if (ma != NULL) {
+ RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
+ path->len++;
+ }
return true;
}
}
@@ -1113,27 +1115,11 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r
/************************* Drawing the Path ************************/
-static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
-{
- SpaceProperties *sbuts = CTX_wm_space_properties(C);
-
- if (sbuts->flag & SB_PIN_CONTEXT) {
- sbuts->pinid = buttons_context_id_path(C);
- }
- else {
- sbuts->pinid = NULL;
- }
-
- ED_area_tag_redraw(CTX_wm_area(C));
-}
-
void buttons_context_draw(const bContext *C, uiLayout *layout)
{
SpaceProperties *sbuts = CTX_wm_space_properties(C);
ButsContextPath *path = sbuts->path;
- uiLayout *row;
- uiBlock *block;
- uiBut *but;
+ uiLayout *row, *sub;
PointerRNA *ptr;
char namebuf[128], *name;
int a, icon;
@@ -1197,25 +1183,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 d7cf2e4d544..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);
@@ -658,8 +659,8 @@ static void buttons_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id
if (sbuts->path) {
ButsContextPath *path = sbuts->path;
- int i;
+ int i;
for (i = 0; i < path->len; i++) {
if (path->ptr[i].owner_id == old_id) {
break;