[Bf-blender-cvs] [b3587b8] UI-graphical-redesign: A first panel redesign

Julian Eisel noreply at git.blender.org
Sat May 30 20:40:53 CEST 2015


Commit: b3587b8aa239ccf4ed88879fa55c80b6bd0a2b71
Author: Julian Eisel
Date:   Sat May 30 19:10:49 2015 +0200
Branches: UI-graphical-redesign
https://developer.blender.org/rBb3587b8aa239ccf4ed88879fa55c80b6bd0a2b71

A first panel redesign

Looking like this now: https://developer.blender.org/F182118

Based on this mockup by @venomgfx: https://dev-files.blender.org/file/
data/sgkm33r4yxspq3gzy2dl/PHID-FILE-xzedfbwhq5tdx4w7jgcw/
blender_ui_drag_widget_gone_padding.png

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

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/resources.c
M	source/blender/editors/screen/area.c
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 1b09671..1c93bd7 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -184,6 +184,7 @@ enum {
 #define UI_PANEL_WIDTH          340
 #define UI_COMPACT_PANEL_WIDTH  160
 
+#define UI_PANEL_MARGIN                (U.widget_unit * 0.25f)
 #define UI_PANEL_CATEGORY_MARGIN_WIDTH (U.widget_unit * 1.0f)
 
 /* but->drawflag - these flags should only affect how the button is drawn. */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 4b0585c..376d2ac 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -567,6 +567,10 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 	Panel *panel = block->panel;
 	rcti headrect;
 	rctf itemrect;
+	const bool draw_header = UI_GetThemeValue(TH_PANEL_SHOW_HEADER);
+	const bool draw_back = UI_GetThemeValue(TH_PANEL_SHOW_BACK);
+	const bool is_selected = panel->flag & PNL_SELECT;
+	const float alpha_fac = is_selected ? 0.7f : 1.0f;
 	int ofsx;
 
 	if (panel->paneltab) return;
@@ -578,6 +582,43 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 	headrect.ymin = headrect.ymax;
 	headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f);
 
+	/* draw panel shadow */
+	if (draw_header == false && panel->flag & PNL_CLOSED) {
+		/* skip */
+	}
+	else if ((draw_header || draw_back)) {
+		rcti shadowrect = headrect;
+		float alpha_fac_tmp = 0.2f * alpha_fac;
+		int shadow_ofs = is_selected ? 2.0f * U.pixelsize : 1.0f * U.pixelsize;
+
+		if (!(panel->flag & PNL_CLOSED) && draw_back) {
+			shadowrect.ymin = rect->ymin;
+		}
+		if (draw_back && !draw_header) {
+			shadowrect.ymax = rect->ymax;
+		}
+
+		glEnable(GL_BLEND);
+
+		if (is_selected) {
+			UI_draw_box_shadow(alpha_fac * 255, shadowrect.xmin, shadowrect.ymin, shadowrect.xmax, shadowrect.ymax);
+		}
+		else {
+			int i;
+
+			for (i = 0; i < 2; i++) {
+				glColor4f(0.0f, 0.0f, 0.0f, alpha_fac_tmp);
+
+				glRectf(shadowrect.xmin + shadow_ofs, shadowrect.ymin - shadow_ofs,
+				        shadowrect.xmax + shadow_ofs, shadowrect.ymax - shadow_ofs);
+
+				shadow_ofs += 1 * U.pixelsize;
+				alpha_fac_tmp *= 0.5f;
+			}
+		}
+		glDisable(GL_BLEND);
+	}
+
 	{
 		float minx = rect->xmin;
 		float maxx = rect->xmax;
@@ -585,13 +626,19 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 
 		glEnable(GL_BLEND);
 
-		if (UI_GetThemeValue(TH_PANEL_SHOW_HEADER)) {
+		if (draw_header) {
+			unsigned char col[4];
+
+			UI_GetThemeColor3ubv(TH_PANEL_HEADER, col);
+
 			/* draw with background color */
-			UI_ThemeColor4(TH_PANEL_HEADER);
-			glRectf(minx, headrect.ymin + 1, maxx, y);
+			glColor4ub(UNPACK3(col), alpha_fac * 255.0f);
 
-			fdrawline(minx, y, maxx, y);
-			fdrawline(minx, y, maxx, y);
+			glRectf(minx, headrect.ymin, maxx, y);
+
+			glColor4f(1.0f, 1.0f, 1.0f, 0.17f);
+			fdrawline(minx, y - 1, maxx, y - 1);
+			fdrawline(minx, headrect.ymin, minx, y - 1);
 		}
 		else if (!(panel->runtime_flag & PNL_FIRST)) {
 			/* draw embossed separator */
@@ -647,21 +694,23 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con
 	}
 	/* an open panel */
 	else {
-		/* in some occasions, draw a border */
-		if (panel->flag & PNL_SELECT) {
-			if (panel->control & UI_PNL_SOLID) UI_draw_roundbox_corner_set(UI_CNR_ALL);
-			else UI_draw_roundbox_corner_set(UI_CNR_NONE);
-
-			UI_ThemeColorShade(TH_BACK, -120);
-			UI_draw_roundbox_unfilled(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8);
-		}
-
 		/* panel backdrop */
-		if (UI_GetThemeValue(TH_PANEL_SHOW_BACK)) {
+		if (draw_back) {
 			/* draw with background color */
+			unsigned char col[4];
+
+			UI_GetThemeColor3ubv(TH_PANEL_BACK, col);
+
 			glEnable(GL_BLEND);
-			UI_ThemeColor4(TH_PANEL_BACK);
+			glColor4ub(UNPACK3(col), alpha_fac * 255.0f);
+
 			glRecti(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
+
+			glColor4f(1.0f, 1.0f, 1.0f, 0.10f);
+			if (draw_header == false) {
+				fdrawline(rect->xmin + 1, rect->ymax - 1, rect->xmax, rect->ymax - 1);
+			}
+			fdrawline(rect->xmin, rect->ymin, rect->xmin, rect->ymax);
 		}
 
 		if (panel->control & UI_PNL_SCALE)
@@ -842,8 +891,9 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
 	
 	/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
 	ps = panelsort;
-	ps->pa->ofsx = 0;
-	ps->pa->ofsy = -get_panel_size_y(ps->pa);
+	ps->pa->ofsx = UI_PANEL_MARGIN;
+	/* offset first panel, but not for properties editor, there is already some space making this look odd */
+	ps->pa->ofsy = -(get_panel_size_y(ps->pa) + (sa->spacetype == SPACE_BUTS ? 0 : UI_PANEL_MARGIN));
 
 	if (has_category_tabs) {
 		if (align == BUT_VERTICAL) {
@@ -856,10 +906,10 @@ static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bo
 
 		if (align == BUT_VERTICAL) {
 			psnext->pa->ofsx = ps->pa->ofsx;
-			psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa);
+			psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa) - UI_PANEL_MARGIN;
 		}
 		else {
-			psnext->pa->ofsx = get_panel_real_ofsx(ps->pa);
+			psnext->pa->ofsx = get_panel_real_ofsx(ps->pa) + UI_PANEL_MARGIN * 2;
 			psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
 		}
 	}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 1a5ce20..e2110e9 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -798,6 +798,11 @@ static void ui_theme_init_new_do(ThemeSpace *ts)
 	rgba_char_args_set(ts->tab_inactive,   83, 83, 83, 255);
 	rgba_char_args_set(ts->tab_back,       64, 64, 64, 255);
 	rgba_char_args_set(ts->tab_outline,    60, 60, 60, 255);
+
+	/* XXX maybe remove show_back/show_header options? */
+	ts->panelcolors.show_back = ts->panelcolors.show_header = true;
+	rgba_char_args_set(ts->panelcolors.back, 128, 128, 128, 255);
+	rgba_char_args_set(ts->panelcolors.header, 97, 97, 97, 255);
 }
 
 static void ui_theme_init_new(bTheme *btheme)
@@ -887,10 +892,6 @@ void ui_theme_init_default(void)
 	ui_theme_init_new(btheme);
 	
 	/* space view3d */
-	btheme->tv3d.panelcolors.show_back = false;
-	btheme->tv3d.panelcolors.show_header = false;
-	rgba_char_args_set_fl(btheme->tv3d.panelcolors.back, 0.45, 0.45, 0.45, 0.5);
-	rgba_char_args_set_fl(btheme->tv3d.panelcolors.header, 0, 0, 0, 0.01);
 	rgba_char_args_set_fl(btheme->tv3d.back,       0.225, 0.225, 0.225, 1.0);
 	rgba_char_args_set(btheme->tv3d.text,       0, 0, 0, 255);
 	rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
@@ -2639,6 +2640,8 @@ void init_userdef_do_versions(void)
 
 	if (U.versionfile < 274 || (U.versionfile == 274 && U.subversionfile < 6)) {
 		bTheme *btheme;
+		ThemeSpace *ts;
+
 		for (btheme = U.themes.first; btheme; btheme = btheme->next) {
 			btheme->tui.wcol_box.roundness = 0.2f;
 			btheme->tui.wcol_list_item.roundness = 0.2f;
@@ -2657,6 +2660,13 @@ void init_userdef_do_versions(void)
 			btheme->tui.wcol_toggle.roundness = 0.2f;
 			btheme->tui.wcol_tool.roundness = 0.25f;
 			btheme->tui.wcol_tooltip.roundness = 0.2f;
+
+			for (ts = UI_THEMESPACE_START(btheme); ts != UI_THEMESPACE_END(btheme); ts++) {
+				/* XXX maybe remove show_back/show_header options? */
+				ts->panelcolors.show_back = ts->panelcolors.show_header = true;
+				rgba_char_args_set(ts->panelcolors.back, 128, 128, 128, 255);
+				rgba_char_args_set(ts->panelcolors.header, 97, 97, 97, 255);
+			}
 		}
 	}
 
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 7fe6518..3a459c0 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1814,7 +1814,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
 			em = (ar->type->prefsizex) ? 10 : 20;
 		}
 
-		w -= margin_x;
+		w -= margin_x + UI_PANEL_MARGIN * 2.0f;
 		
 		/* create panels */
 		UI_panels_begin(C, ar);
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index a67ea55..218e79b 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -877,10 +877,12 @@ static void rna_def_userdef_theme_ui_panel(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Theme Panel Color", "Theme settings for panel colors");
 		
 	prop = RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Header", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 	
 	prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Background", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");




More information about the Bf-blender-cvs mailing list