[Bf-blender-cvs] [f3197de2659] property-search-ui-v2: Property Search: Move properties context buttons back to a panel

Hans Goudey noreply at git.blender.org
Wed Sep 9 21:03:18 CEST 2020


Commit: f3197de26599897e91046b66246a237f02a0362a
Author: Hans Goudey
Date:   Wed Sep 9 11:56:28 2020 -0500
Branches: property-search-ui-v2
https://developer.blender.org/rBf3197de26599897e91046b66246a237f02a0362a

Property Search: Move properties context buttons back to a panel

The context path buttons used to be in a panel in 2.79. Although they look
a bit better in the header, there is not space for them with the property
search field in the header as well.

In the long term, maybe it will be possible to shrink the text button and
then animate it expanding when property search begins, then there
would be enough room for both.

Note that this diff is just for review, Blender won't ever actually have only
the pin button in the header like the following image.

{F8858554 size=full}

Differential Revision: https://developer.blender.org/D8853

===================================================================

M	release/scripts/startup/bl_ui/space_properties.py
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/buttons_intern.h
M	source/blender/editors/space_buttons/space_buttons.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
index 7d9ca687524..d4d5843f415 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -23,11 +23,16 @@ from bpy.types import Header, Panel
 class PROPERTIES_HT_header(Header):
     bl_space_type = 'PROPERTIES'
 
-    def draw(self, _context):
+    def draw(self, context):
         layout = self.layout
+        view = context.space_data
 
         layout.template_header()
 
+        row = layout.row()
+        row.emboss = 'NONE'
+        row.operator("buttons.toggle_pin", icon=('PINNED' if view.use_pin_id else 'UNPINNED'), text="")
+
 
 class PROPERTIES_PT_navigation_bar(Panel):
     bl_space_type = 'PROPERTIES'
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index b8c94049b2a..38b22464761 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -1116,27 +1116,18 @@ 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))
+static bool buttons_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
 {
   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));
+  return sbuts->mainb != BCONTEXT_TOOL;
 }
 
-void buttons_context_draw(const bContext *C, uiLayout *layout)
+static void buttons_panel_context_draw(const bContext *C, Panel *panel)
 {
+  uiLayout *layout = panel->layout;
   SpaceProperties *sbuts = CTX_wm_space_properties(C);
   ButsContextPath *path = sbuts->path;
-  uiLayout *row, *sub;
-  uiBlock *block;
-  uiBut *but;
+  uiLayout *row;
   PointerRNA *ptr;
   char namebuf[128], *name;
   int a, icon;
@@ -1197,52 +1188,11 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
       }
     }
   }
-
-  uiItemSpacer(row);
-
-  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
-static bool buttons_header_context_poll(const bContext *C, HeaderType *UNUSED(ht))
-#else
-static bool buttons_panel_context_poll(const bContext *C, PanelType *UNUSED(pt))
-#endif
-{
-  SpaceProperties *sbuts = CTX_wm_space_properties(C);
-  return (sbuts->mainb != BCONTEXT_TOOL);
-}
-
-#ifdef USE_HEADER_CONTEXT_PATH
-static void buttons_header_context_draw(const bContext *C, Header *ptr)
-#else
-static void buttons_panel_context_draw(const bContext *C, Panel *ptr)
-#endif
-{
-  buttons_context_draw(C, ptr->layout);
 }
 
 void buttons_context_register(ARegionType *art)
 {
-#ifdef USE_HEADER_CONTEXT_PATH
-  HeaderType *ht;
-
-  ht = MEM_callocN(sizeof(HeaderType), "spacetype buttons context header");
-  strcpy(ht->idname, "BUTTONS_HT_context");
-  ht->space_type = SPACE_PROPERTIES;
-  ht->region_type = art->regionid;
-  ht->poll = buttons_header_context_poll;
-  ht->draw = buttons_header_context_draw;
-  BLI_addtail(&art->headertypes, ht);
-#else
-  PanelType *pt;
-
-  pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context");
+  PanelType *pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context");
   strcpy(pt->idname, "BUTTONS_PT_context");
   strcpy(pt->label, N_("Context")); /* XXX C panels unavailable through RNA bpy.types! */
   strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
@@ -1250,7 +1200,6 @@ void buttons_context_register(ARegionType *art)
   pt->draw = buttons_panel_context_draw;
   pt->flag = PNL_NO_HEADER;
   BLI_addtail(&art->paneltypes, pt);
-#endif
 }
 
 ID *buttons_context_id_path(const bContext *C)
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index a1e2b9e9aaf..76a4d72057f 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -37,9 +37,6 @@ struct bNodeTree;
 struct uiLayout;
 struct wmOperatorType;
 
-/* Display the context path in the header instead of the main window */
-#define USE_HEADER_CONTEXT_PATH
-
 /* context data */
 
 typedef struct ButsContextPath {
@@ -83,7 +80,6 @@ void buttons_context_compute(const struct bContext *C, struct SpaceProperties *s
 int buttons_context(const struct bContext *C,
                     const char *member,
                     struct bContextDataResult *result);
-void buttons_context_draw(const struct bContext *C, struct uiLayout *layout);
 void buttons_context_register(struct ARegionType *art);
 struct ID *buttons_context_id_path(const struct bContext *C);
 
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 8ba9dbe1d36..20d81ff6da1 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -342,14 +342,6 @@ static void buttons_keymap(struct wmKeyConfig *keyconf)
 /* add handlers, stuff you only do once or on area/region changes */
 static void buttons_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
 {
-#ifdef USE_HEADER_CONTEXT_PATH
-  /* Reinsert context buttons header-type at the end of the list so it's drawn last. */
-  HeaderType *context_ht = BLI_findstring(
-      &region->type->headertypes, "BUTTONS_HT_context", offsetof(HeaderType, idname));
-  BLI_remlink(&region->type->headertypes, context_ht);
-  BLI_addtail(&region->type->headertypes, context_ht);
-#endif
-
   ED_region_header_init(region);
 }
 
@@ -389,10 +381,6 @@ static void buttons_header_region_message_subscribe(const bContext *UNUSED(C),
   if (sbuts->mainb == BCONTEXT_TOOL) {
     WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
   }
-
-#ifdef USE_HEADER_CONTEXT_PATH
-  WM_msg_subscribe_rna_anon_prop(mbus, SpaceProperties, context, &msg_sub_value_region_tag_redraw);
-#endif
 }
 
 static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion *region)
@@ -726,9 +714,7 @@ void ED_spacetype_buttons(void)
   art->draw = ED_region_panels_draw;
   art->listener = buttons_main_region_listener;
   art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
-#ifndef USE_HEADER_CONTEXT_PATH
   buttons_context_register(art);
-#endif
   BLI_addhead(&st->regiontypes, art);
 
   /* Register the panel types from modifiers. The actual panels are built per modifier rather than
@@ -764,9 +750,6 @@ void ED_spacetype_buttons(void)
   art->init = buttons_header_region_init;
   art->draw = buttons_header_region_draw;
   art->message_subscribe = buttons_header_region_message_subscribe;
-#ifdef USE_HEADER_CONTEXT_PATH
-  buttons_context_register(art);
-#endif
   BLI_addhead(&st->regiontypes, art);
 
   /* regions: navigation bar */



More information about the Bf-blender-cvs mailing list