[Bf-blender-cvs] [131caab] UI-graphical-redesign: Add an "Interface Style" theme option for flat vs. classic drawing

Julian Eisel noreply at git.blender.org
Tue Jun 9 23:58:40 CEST 2015


Commit: 131caabfdb762304c66a9154288db932c045f8be
Author: Julian Eisel
Date:   Tue Jun 9 23:54:33 2015 +0200
Branches: UI-graphical-redesign
https://developer.blender.org/rB131caabfdb762304c66a9154288db932c045f8be

Add an "Interface Style" theme option for flat vs. classic drawing

Adds an "Interface Style" menu containing the items "Flat" (default) and
"Classic". The classic option basically brings back widget outlines,
emboss, shading and old checkbox design.

Open design question:
Currently widget outlines, emboss and shading is hardcoded disabled for
the "Flat" option. Meaning that tweaks to their theme options don't have
any effect. I think it should be fine to just disable the theme buttons
for this, but I'm all ears for better approaches.

Requested by @campbellbarton and @ton

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/resources.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 28faaca..56484b3 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -681,6 +681,14 @@ class USERPREF_PT_theme(Panel):
             col = split.column()
             ui = theme.user_interface
 
+            row = col.row()
+            subsplit = row.split(percentage=0.47)
+            subsplit.prop(ui, "interface_style")
+
+            col.separator()
+            col.separator()
+            col.separator()
+
             col.label(text="Regular:")
             self._theme_widget_style(col, ui.wcol_regular)
 
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 426cf72..dd36c1a 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -64,6 +64,10 @@
 /* icons are 80% of height of button (16 pixels inside 20 height) */
 #define ICON_SIZE_FROM_BUTRECT(rect) (0.8f * BLI_rcti_size_y(rect))
 
+/* for checking interface style type */
+#define IFACE_STYLE_IS_CLASSIC (((bTheme *)UI_GetTheme())->tui.interface_style == TH_IFACE_STYLE_CLASSIC)
+#define IFACE_STYLE_IS_FLAT    (((bTheme *)UI_GetTheme())->tui.interface_style == TH_IFACE_STYLE_FLAT)
+
 /* ************** widget base functions ************** */
 /**
  * - in: roundbox codes for corner types and radius
@@ -273,11 +277,19 @@ static void widget_init(uiWidgetBase *wtb)
 	wtb->tria2.tot = 0;
 
 	wtb->draw_inner = true;
-	wtb->draw_emboss = true;
 	wtb->draw_shadedir = true;
 
-	/* don't draw outline by default */
-	wtb->draw_outline = false;
+	if (IFACE_STYLE_IS_CLASSIC) {
+		wtb->draw_outline = true;
+		wtb->draw_emboss = true;
+	}
+	else {
+		BLI_assert(IFACE_STYLE_IS_FLAT);
+
+		/* don't draw outline or emboss by default */
+		wtb->draw_outline = false;
+		wtb->draw_emboss = false;
+	}
 }
 
 /* helper call, makes shadow rect, with 'sun' above menu, so only shadow to left/right/bottom */
@@ -695,7 +707,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
 
 	/* backdrop non AA */
 	if (wtb->draw_inner) {
-		if (wcol->shaded == 0) {
+		if (wcol->shaded == 0 || IFACE_STYLE_IS_FLAT) {
 			if (wcol->alpha_check) {
 				float inner_v_half[WIDGET_SIZE_MAX][2];
 				float x_mid = 0.0f; /* used for dumb clamping of values */
@@ -1788,7 +1800,7 @@ static struct uiWidgetColors wcol_num = {
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
-	0,
+	1,
 	-20, 0,
 
 	0, /* pad */
@@ -1804,7 +1816,7 @@ static struct uiWidgetColors wcol_numslider = {
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
-	0,
+	1,
 	-20, 0,
 
 	0, /* pad */
@@ -1820,7 +1832,7 @@ static struct uiWidgetColors wcol_text = {
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
-	0,
+	1,
 	0, 25,
 
 	0, /* pad */
@@ -1836,7 +1848,7 @@ static struct uiWidgetColors wcol_option = {
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
-	0,
+	1,
 	15, -15,
 
 	0, /* pad */
@@ -1853,7 +1865,7 @@ static struct uiWidgetColors wcol_menu = {
 	{255, 255, 255, 255},
 	{204, 204, 204, 255},
 	
-	0,
+	1,
 	15, -15,
 
 	0, /* pad */
@@ -1887,7 +1899,7 @@ static struct uiWidgetColors wcol_menu_item = {
 	{255, 255, 255, 255},
 	{0, 0, 0, 255},
 	
-	0,
+	1,
 	38, 0,
 
 	0, /* pad */
@@ -1921,7 +1933,7 @@ static struct uiWidgetColors wcol_pie_menu = {
 	{160, 160, 160, 255},
 	{255, 255, 255, 255},
 
-	0,
+	1,
 	10, -10,
 
 	0, /* pad */
@@ -1955,7 +1967,7 @@ static struct uiWidgetColors wcol_radio = {
 	{255, 255, 255, 255},
 	{0, 0, 0, 255},
 	
-	0,
+	1,
 	15, -15,
 
 	0, /* pad */
@@ -1987,7 +1999,7 @@ static struct uiWidgetColors wcol_tool = {
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
-	0,
+	1,
 	15, -15,
 
 	0, /* pad */
@@ -2035,7 +2047,7 @@ static struct uiWidgetColors wcol_scroll = {
 	{0, 0, 0, 255},
 	{255, 255, 255, 255},
 	
-	0,
+	1,
 	5, -5,
 
 	0, /* pad */
@@ -3247,6 +3259,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
 	toffs = offs * 0.75f;
 	round_box_edges(&wtb, roundboxalign, rect, offs);
 
+	wtb.draw_outline = false;
 	widgetbase_draw(&wtb, wcol);
 	
 	/* draw left/right parts only when not in text editing */
@@ -3271,6 +3284,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
 		/* left part of slider, always rounded */
 		rect1.xmax = rect1.xmin + ceil(offs + U.pixelsize);
 		round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs);
+		wtb1.draw_outline = false;
 		widgetbase_draw(&wtb1, wcol);
 		
 		/* right part of slider, interpolate roundness */
@@ -3294,6 +3308,13 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
 			SWAP(short, wcol->shadetop, wcol->shadedown);
 	}
 
+	/* outline */
+	if (IFACE_STYLE_IS_CLASSIC) {
+		wtb.draw_outline = true;
+		wtb.draw_inner   = false;
+		widgetbase_draw(&wtb, wcol);
+	}
+
 	/* add space at either side of the button so text aligns with numbuttons (which have arrow icons) */
 	if (!(state & UI_TEXTINPUT)) {
 		rect->xmax -= toffs;
@@ -3385,6 +3406,7 @@ static void widget_icon_has_anim(uiBut *but, uiWidgetColors *wcol, rcti *rect, i
 		float rad;
 		
 		widget_init(&wtb);
+		wtb.draw_outline = false;
 		
 		/* rounded */
 		rad = wcol->roundness * BLI_rcti_size_y(rect);
@@ -3499,6 +3521,7 @@ static void widget_menu_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
 	widget_init(&wtb);
 	
 	/* not rounded, no outline */
+	wtb.draw_outline = false;
 	round_box_edges(&wtb, 0, rect, 0.0f);
 	
 	widgetbase_draw(&wtb, wcol);
@@ -3535,6 +3558,7 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
 	widget_init(&wtb);
 	
 	/* rounded, but no outline */
+	wtb.draw_outline = false;
 	round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
 
 	widgetbase_draw(&wtb, wcol);
@@ -3544,6 +3568,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
 {
 	uiWidgetBase wtb;
 	rcti recttemp = *rect;
+	const bool is_style_flat = IFACE_STYLE_IS_FLAT;
 
 	widget_init(&wtb);
 
@@ -3551,23 +3576,30 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
 	recttemp.xmax = recttemp.xmin + BLI_rcti_size_y(&recttemp);
 
 	/* smaller */
-	BLI_rcti_scale(&recttemp, 0.8f);
+	BLI_rcti_scale(&recttemp, is_style_flat ? 0.8f : 0.7f);
 
-	/* draw inner */
-	glColor4ubv((unsigned char *)wcol->inner);
-	ui_draw_anti_circle_rect(&recttemp);
+	if (is_style_flat) {
+		/* draw circle as inner */
+		glColor4ubv((unsigned char *)wcol->inner);
+		ui_draw_anti_circle_rect(&recttemp);
 
-	/* adjust recttemp for decoration */
-	BLI_rcti_translate(&recttemp, -0.1f * U.widget_unit, -0.1f * U.widget_unit);
-	BLI_rcti_scale(&recttemp, 0.9f);
+		/* adjust recttemp for decoration */
+		BLI_rcti_translate(&recttemp, -0.1f * U.widget_unit, -0.1f * U.widget_unit);
+		BLI_rcti_scale(&recttemp, 0.9f);
+	}
+	else {
+		round_box_edges(&wtb, UI_CNR_ALL, &recttemp, 0.2f * U.widget_unit);
+	}
 
 	/* decoration */
 	if (state & UI_SELECT) {
 		widget_check_trias(&wtb.tria1, &recttemp);
 	}
 
-	/* disable inner as this was already drawn */
-	wtb.draw_inner = false;
+	if (is_style_flat) {
+		/* disable inner as this was already drawn */
+		wtb.draw_inner = false;
+	}
 	widgetbase_draw(&wtb, wcol);
 
 	/* text space */
@@ -4358,7 +4390,7 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
 	uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
 	
 	glEnable(GL_BLEND);
-	widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit, false);
+	widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit, IFACE_STYLE_IS_CLASSIC);
 	glDisable(GL_BLEND);
 
 	wt->state(wt, 0);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index fead706..7ed528c 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -2640,7 +2640,8 @@ void init_userdef_do_versions(void)
 			}
 
 			rgba_char_args_set_fl(btheme->tui.area_edges, 0.23f, 0.23f, 0.23f, 1.0f);
-			btheme->tui.widget_emboss[3] = 0;
+
+			btheme->tui.interface_style = TH_IFACE_STYLE_FLAT;
 
 			ui_widget_color_init(&btheme->tui);
 		}
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 03bc616..974bb0b 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -170,6 +170,9 @@ typedef struct ThemeUI {
 
 	uiPanelColors panel; /* depricated, but we keep it for do_versions (2.66.1) */
 
+	short interface_style; /* flat/classic - don't confuse with uiStyle */
+	short pad2;
+
 	char area_edges[4];
 
 	char widget_emboss[4];
@@ -178,7 +181,7 @@ typedef struct ThemeUI {
 	float menu_shadow_fac;
 	short menu_shadow_width;
 	
-	short pad[5];
+	short pad[3];
 	
 	char iconfile[256];	// FILE_MAXFILE length
 	float icon_alpha;
@@ -885,6 +888,11 @@ typedef enum eUserpref_VirtualPixel {
 	VIRTUAL_PIXEL_DOUBLE = 1,
 } eUserpref_VirtualPixel;
 
+typedef enum eTheme_InterfaceStyle {
+	TH_IFACE_STYLE_CLASSIC = 0,
+	TH_IFACE_STYLE_FLAT    = 1,
+} eTheme_InterfaceStyle;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 906bd94..cc2ee46 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -926,6 +926,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
+	static EnumPropertyItem interface_style_items[] = {
+		{TH_IFACE_STYLE_CLASSIC, "CLASSIC", 0, "Classic", "Use a classic interface drawing style"},
+		{TH_IFACE_STYLE_FLAT,    "FLAT",    0, "Flat",    "Use a flat interface drawing style"},
+		{0, NULL, 0, NULL, NULL}
+	};
+
 	rna_def_userdef_theme_ui_wcol(brna);
 	rna_def_userdef_theme_ui_wcol_state(brna);
 	rna_def_userdef_theme_ui_panel(brna);
@@ -1031,6 +1037,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "State Colors", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 
+	prop = RNA_def_property(srna, "i

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list