Commit: d031455395a8a9bd6e235667c4182a76b71d40e0
Author: Julian Eisel
Date:   Fri May 29 21:10:53 2015 +0200
Branches: UI-graphical-redesign
https://developer.blender.org/rBd031455395a8a9bd6e235667c4182a76b71d40e0

Theme option to change widget corner roundness (per widget type)

Original patch by @venomgfx, updated and made a few minor changes.

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

M       release/scripts/startup/bl_ui/space_userpref.py
M       source/blender/blenkernel/BKE_blender.h
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 9b3a2b5..00cb1d8 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -619,6 +619,8 @@ class USERPREF_PT_theme(Panel):
         subsub.active = widget_style.show_shaded
         subsub.prop(widget_style, "shadetop")
         subsub.prop(widget_style, "shadedown")
+        subsub = colsub.column(align=True)
+        subsub.prop(widget_style, "roundness")
 
         layout.separator()
 
diff --git a/source/blender/blenkernel/BKE_blender.h 
b/source/blender/blenkernel/BKE_blender.h
index 80332c0..1af96f9 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         274
-#define BLENDER_SUBVERSION      5
+#define BLENDER_SUBVERSION      6
 /* Several breakages with 270, e.g. constraint deg vs rad */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index 4156614..30aa1b7 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2221,9 +2221,9 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti 
*rect, int flag, int dir
        }
        
        glEnable(GL_BLEND);
-       widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit);
+       widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
        
-       round_box_edges(&wtb, roundboxalign, rect, 0.25f * U.widget_unit);
+       round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * 
U.widget_unit);
        wtb.emboss = 0;
        widgetbase_draw(&wtb, wcol);
        
@@ -2657,8 +2657,9 @@ static void ui_draw_separator(const rcti *rect,  
uiWidgetColors *wcol)
 static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, 
int roundboxalign, bool emboss)
 {
        uiWidgetBase wtb;
-       const float rad = 0.5f * BLI_rcti_size_y(rect);
-       float textofs = rad * 0.85f;
+       const int sizey = BLI_rcti_size_y(rect);
+       const float rad = wcol->roundness * sizey;
+       float textofs = 0.43f * sizey;
 
        if (state & UI_SELECT)
                SWAP(short, wcol->shadetop, wcol->shadedown);
@@ -2758,9 +2759,9 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const 
rcti *rect, const rcti *s
        horizontal = (BLI_rcti_size_x(rect) > BLI_rcti_size_y(rect));
 
        if (horizontal)
-               rad = 0.5f * BLI_rcti_size_y(rect);
+               rad = wcol->roundness * BLI_rcti_size_y(rect);
        else
-               rad = 0.5f * BLI_rcti_size_x(rect);
+               rad = wcol->roundness * BLI_rcti_size_x(rect);
        
        wtb.shadedir = (horizontal) ? 1 : 0;
        
@@ -2941,7 +2942,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors 
*wcol, rcti *rect, int s
        /* backdrop first */
        
        /* fully rounded */
-       offs = 0.5f * BLI_rcti_size_y(rect);
+       offs = wcol->roundness * BLI_rcti_size_y(rect);
        toffs = offs * 0.75f;
        round_box_edges(&wtb, roundboxalign, rect, offs);
 
@@ -3031,7 +3032,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors 
*wcol, rcti *rect, int stat
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.25f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
                
        ui_but_v3_get(but, col);
@@ -3091,7 +3092,7 @@ static void widget_icon_has_anim(uiBut *but, 
uiWidgetColors *wcol, rcti *rect, i
                wtb.outline = 0;
                
                /* rounded */
-               rad = 0.5f * BLI_rcti_size_y(rect);
+               rad = wcol->roundness * BLI_rcti_size_y(rect);
                round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
                widgetbase_draw(&wtb, wcol);
        }
@@ -3114,7 +3115,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti 
*rect, int state, int roun
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
@@ -3129,7 +3130,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti 
*rect, int UNUSED(state),
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
        
        /* decoration */
@@ -3149,7 +3150,7 @@ static void widget_menuiconbut(uiWidgetColors *wcol, rcti 
*rect, int UNUSED(stat
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
        
        /* decoration */
@@ -3166,7 +3167,7 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti 
*rect, int UNUSED(stat
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
 
        wcol->inner[0] = min_ii(wcol->inner[0] + 15, 255);
@@ -3185,7 +3186,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti 
*rect, int state, int
 {
        if (state & UI_ACTIVE) {
                uiWidgetBase wtb;
-               const float rad = 0.2f * U.widget_unit;
+               const float rad = wcol->roundness * U.widget_unit;
 
                widget_init(&wtb);
 
@@ -3235,13 +3236,12 @@ static void widget_menu_radial_itembut(uiBut *but, 
uiWidgetColors *wcol, rcti *r
 static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int 
UNUSED(state), int UNUSED(roundboxalign))
 {
        uiWidgetBase wtb;
-       float rad;
+       const float rad = wcol->roundness * U.widget_unit;
        
        widget_init(&wtb);
        
        /* rounded, but no outline */
        wtb.outline = 0;
-       rad = 0.2f * U.widget_unit;
        round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
@@ -3267,7 +3267,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti 
*rect, int state, int UN
        recttemp.ymax -= delta;
 
        /* half rounded */
-       rad = 0.35f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
 
        /* some offset for decoration */
@@ -3314,7 +3314,7 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti 
*rect, int UNUSED(state),
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
@@ -3338,7 +3338,7 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, 
rcti *rect, int UNUSED(
        }
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
@@ -3354,7 +3354,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, 
int UNUSED(state), int
        widget_init(&wtb);
        
        /* half rounded */
-       rad = 0.2f * U.widget_unit;
+       rad = wcol->roundness * U.widget_unit;
        round_box_edges(&wtb, roundboxalign, rect, rad);
        
        widgetbase_draw(&wtb, wcol);
@@ -3363,7 +3363,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, 
int UNUSED(state), int
 static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int 
UNUSED(state), int roundboxalign)
 {
        uiWidgetBase wtb;
-       const float rad = 0.25f * U.widget_unit;
+       const float rad = wcol->roundness * U.widget_unit;
        
        widget_init(&wtb);
        
diff --git a/source/blender/editors/interface/resources.c 
b/source/blender/editors/interface/resources.c
index ed61518..1a5ce20 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -855,6 +855,24 @@ void ui_theme_init_default(void)
        
        rgba_char_args_set_fl(btheme->tui.widget_emboss, 1.0f, 1.0f, 1.0f, 
0.02f);
 
+       btheme->tui.wcol_box.roundness = 0.2f;
+       btheme->tui.wcol_list_item.roundness = 0.2f;
+       btheme->tui.wcol_menu.roundness = 0.2f;
+       btheme->tui.wcol_menu_back.roundness = 0.25f;
+       btheme->tui.wcol_menu_item.roundness = 0.2f;
+       btheme->tui.wcol_num.roundness = 0.5f;
+       btheme->tui.wcol_numslider.roundness = 0.5f;
+       btheme->tui.wcol_option.roundness = 0.35f;
+       btheme->tui.wcol_progress.roundness = 0.2f;
+       btheme->tui.wcol_pulldown.roundness = 0.2f;
+       btheme->tui.wcol_radio.roundness = 0.2f;
+       btheme->tui.wcol_regular.roundness = 0.2f;
+       btheme->tui.wcol_scroll.roundness = 0.5f;
+       btheme->tui.wcol_text.roundness = 0.2f;
+       btheme->tui.wcol_toggle.roundness = 0.2f;
+       btheme->tui.wcol_tool.roundness = 0.25f;
+       btheme->tui.wcol_tooltip.roundness = 0.2f;
+
        rgba_char_args_set(btheme->tui.xaxis, 220,   0,   0, 255);
        rgba_char_args_set(btheme->tui.yaxis,   0, 220,   0, 255);
        rgba_char_args_set(btheme->tui.zaxis,   0,   0, 220, 255);
@@ -2619,6 +2637,29 @@ void init_userdef_do_versions(void)
                }
        }
 
+       if (U.versionfile < 274 || (U.versionfile == 274 && U.subversionfile < 
6)) {
+               bTheme *btheme;
+               for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+                       btheme->tui.wcol_box.roundness = 0.2f;
+                       btheme->tui.wcol_list_item.roundness = 0.2f;
+                       btheme->tui.wcol_menu.roundness = 0.2f;
+                       btheme->tui.wcol_menu_back.roundness = 0.25f;
+                       btheme->tui.wcol_menu_item.roundness = 0.2f;
+                       btheme->tui.wcol_num.roundness = 0.5f;
+                       btheme->tui.wcol_numslider.roundness = 0.5f;
+                       btheme->tui.wcol_option.roundness = 0.35f;
+                       btheme->tui.wcol_progress.roundness = 0.2f;
+                       btheme->tui.wcol_pulldown.roundness = 0.2f;
+                       btheme->tui.wcol_radio.roundness = 0.2f;
+                       btheme->tui.wcol_regular.roundness = 0.2f;
+                       btheme->tui.wcol_scroll.roundness = 0.5f;
+                       btheme->tui.wcol_text.roundness = 0.2f;
+                       btheme->tui.wcol_toggle.roundness = 0.2f;
+                       btheme->tui.wcol_tool.roundness = 0.25f;
+                       btheme->tui.wcol_tooltip.roundness = 0.2f;
+               }
+       }
+
                
        if (U.pixelsize == 0.0f)
                U.pixelsize = 1.0f;
diff --git a/source/blender/makesdna/DNA_userdef_types.h 
b/source/blender/makesdna/DNA_userdef_types.h
index af0c3bf..45f70b0 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -129,6 +129,7 @@ typedef struct uiWidgetColors {
        short shaded;
        short shadetop, shadedown;
        short alpha_check;
+       float roundness, pad;
 } uiWidgetColors;
 
 typedef struct uiWidgetStateColors {
diff --git a/source/blender/makesrna/intern/rna_userdef.c 
b/source/blender/makesrna/intern/rna_userdef.c

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to