[Bf-blender-cvs] [0b597bf7b96] blender2.8: UI: use popup draw style for redo panel

Campbell Barton noreply at git.blender.org
Tue Sep 11 03:12:01 CEST 2018


Commit: 0b597bf7b96ac7c613f80c11165f869e036d55ef
Author: Campbell Barton
Date:   Tue Sep 11 11:22:08 2018 +1000
Branches: blender2.8
https://developer.blender.org/rB0b597bf7b96ac7c613f80c11165f869e036d55ef

UI: use popup draw style for redo panel

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

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_hud.c

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index c9f3500e839..586d6e8efec 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1465,8 +1465,12 @@ void UI_block_draw(const bContext *C, uiBlock *block)
 		ui_draw_popover_back(ar, &style, block, &rect);
 	else if (block->flag & UI_BLOCK_LOOP)
 		ui_draw_menu_back(&style, block, &rect);
-	else if (block->panel)
-		ui_draw_aligned_panel(&style, block, &rect, UI_panel_category_is_visible(ar));
+	else if (block->panel) {
+		bool show_background = ar->alignment != RGN_ALIGN_FLOAT;
+		ui_draw_aligned_panel(
+		        &style, block, &rect,
+		        UI_panel_category_is_visible(ar), show_background);
+	}
 
 	BLF_batch_draw_begin();
 	UI_icon_draw_cache_begin();
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 59e1879d4f8..ee6fc16d8b6 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -674,7 +674,9 @@ void ui_popup_block_scrolltest(struct uiBlock *block);
 extern int ui_handler_panel_region(
         struct bContext *C, const struct wmEvent *event,
         struct ARegion *ar, const uiBut *active_but);
-extern void ui_draw_aligned_panel(struct uiStyle *style, uiBlock *block, const rcti *rect, const bool show_pin);
+extern void ui_draw_aligned_panel(
+        struct uiStyle *style, uiBlock *block, const rcti *rect,
+        const bool show_pin, const bool show_background);
 
 /* interface_draw.c */
 extern void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int select);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index cb5c104e638..53744e5e1b9 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -381,6 +381,9 @@ Panel *UI_panel_begin(ScrArea *sa, ARegion *ar, ListBase *lb, uiBlock *block, Pa
 	/* assign to block */
 	block->panel = pa;
 	pa->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED;
+	if (ar->alignment == RGN_ALIGN_FLOAT) {
+		UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
+	}
 
 	*r_open = false;
 
@@ -652,7 +655,9 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, const r
 }
 
 /* panel integrated in buttonswindow, tool/property lists etc */
-void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, const bool show_pin)
+void ui_draw_aligned_panel(
+        uiStyle *style, uiBlock *block, const rcti *rect,
+        const bool show_pin, const bool show_background)
 {
 	Panel *panel = block->panel;
 	rcti headrect;
@@ -661,7 +666,11 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 	const bool is_closed_x = (panel->flag & PNL_CLOSEDX) ? true : false;
 	const bool is_closed_y = (panel->flag & PNL_CLOSEDY) ? true : false;
 	const bool is_subpanel = (panel->type && panel->type->parent);
-	const bool show_drag = !is_subpanel;
+	const bool show_drag = (
+	        !is_subpanel &&
+	        /* FIXME(campbell): currently no background means floating panel which can't be dragged.
+	         * This may be changed in future. */
+	        show_background);
 
 	if (panel->paneltab) return;
 	if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
@@ -680,7 +689,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 	uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-	if (!is_subpanel) {
+	if (show_background && !is_subpanel) {
 		float minx = rect->xmin;
 		float maxx = is_closed_x ? (minx + PNL_HEADER / block->aspect) : rect->xmax;
 		float y = headrect.ymax;
@@ -775,11 +784,13 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 
 		GPU_blend(true);
 
-		/* panel backdrop */
-		int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
+		if (show_background) {
+			/* panel backdrop */
+			int panel_col = is_subpanel ? TH_PANEL_SUB_BACK : TH_PANEL_BACK;
 
-		immUniformThemeColor(panel_col);
-		immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+			immUniformThemeColor(panel_col);
+			immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+		}
 
 		if (panel->control & UI_PNL_SCALE)
 			ui_draw_panel_scalewidget(pos, rect);
@@ -1199,7 +1210,9 @@ void UI_panels_draw(const bContext *C, ARegion *ar)
 {
 	uiBlock *block;
 
-	UI_ThemeClearColor(TH_BACK);
+	if (ar->alignment != RGN_ALIGN_FLOAT) {
+		UI_ThemeClearColor(TH_BACK);
+	}
 
 	/* Draw panels, selected on top. Also in reverse order, because
 	 * UI blocks are added in reverse order and we need child panels
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index 3479b60a434..89b34f3f152 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -203,12 +203,7 @@ static void hud_region_draw(const bContext *C, ARegion *ar)
 	GPU_clear(GPU_COLOR_BIT);
 
 	if ((ar->flag & RGN_FLAG_HIDDEN) == 0) {
-		float color[4];
-		UI_GetThemeColor4fv(TH_BUTBACK, color);
-		if ((U.uiflag2 & USER_REGION_OVERLAP) == 0) {
-			color[3] = 1.0f;
-		}
-		ui_draw_widget_back_color(UI_WTYPE_BOX, false, &(rcti){.xmax = ar->winx, .ymax = ar->winy}, color);
+		ui_draw_menu_back(NULL, NULL, &(rcti){.xmax = ar->winx, .ymax = ar->winy});
 		ED_region_panels_draw(C, ar);
 	}
 }



More information about the Bf-blender-cvs mailing list