[Bf-blender-cvs] [a0d40c6a8c4] blender2.8: UI: Move Properties editor context path into header

Julian Eisel noreply at git.blender.org
Mon Oct 29 23:01:16 CET 2018


Commit: a0d40c6a8c42c774d9286b5de0d80167c1d55fde
Author: Julian Eisel
Date:   Mon Oct 29 22:55:54 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBa0d40c6a8c42c774d9286b5de0d80167c1d55fde

UI: Move Properties editor context path into header

This will probably be a temporary solution to fill empty space, for until we
have a search button there. Hence, I made this optional using a compile flag.

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

M	source/blender/blenkernel/BKE_screen.h
M	source/blender/editors/screen/area.c
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/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index 58058d1e134..0d766e83299 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -266,6 +266,7 @@ typedef struct HeaderType {
 	int space_type;
 	int region_type;
 
+	bool (*poll)(const struct bContext *C, struct HeaderType *ht);
 	/* draw entirely, view changes should be handled here */
 	void (*draw)(const struct bContext *C, struct Header *header);
 
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 79f2bebd0d3..66044680f10 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2367,6 +2367,10 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
 
 	/* draw all headers types */
 	for (ht = ar->type->headertypes.first; ht; ht = ht->next) {
+		if (ht->poll && !ht->poll(C, ht)) {
+			continue;
+		}
+
 		block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS);
 		layout = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, buttony, 1, 0, style);
 
@@ -2378,6 +2382,9 @@ void ED_region_header_layout(const bContext *C, ARegion *ar)
 			header.type = ht;
 			header.layout = layout;
 			ht->draw(C, &header);
+			if (ht->next) {
+				uiItemS(layout);
+			}
 
 			/* for view2d */
 			xco = uiLayoutGetWidth(layout);
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 04948fd6984..abc2ed6ca3c 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -1049,19 +1049,38 @@ void buttons_context_draw(const bContext *C, uiLayout *layout)
 	}
 }
 
+#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
 {
 	SpaceButs *sbuts = CTX_wm_space_buts(C);
 	return (sbuts->mainb != BCONTEXT_TOOL);
 }
 
-static void buttons_panel_context_draw(const bContext *C, Panel *pa)
+#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, pa->layout);
+	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_BUTS;
+	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");
@@ -1072,6 +1091,7 @@ 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 aab7b39484d..65bcf7ef1c8 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -45,6 +45,9 @@ 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 {
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 50018b212a6..413d0ab376a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -358,6 +358,13 @@ 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 *ar)
 {
+#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(&ar->type->headertypes, "BUTTONS_HT_context", offsetof(HeaderType, idname));
+	BLI_remlink(&ar->type->headertypes, context_ht);
+	BLI_addtail(&ar->type->headertypes, context_ht);
+#endif
+
 	ED_region_header_init(ar);
 }
 
@@ -395,6 +402,10 @@ static void buttons_header_region_message_subscribe(
 	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 *ar)
@@ -687,9 +698,10 @@ 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;
-	BLI_addhead(&st->regiontypes, art);
-
+#ifndef USE_HEADER_CONTEXT_PATH
 	buttons_context_register(art);
+#endif
+	BLI_addhead(&st->regiontypes, art);
 
 	/* regions: header */
 	art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
@@ -700,6 +712,9 @@ 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