[Bf-blender-cvs] [f3b2cbcb815] temp-ui-tweaks: UI: Separate each choice inside radio buttons

Pablo Vazquez noreply at git.blender.org
Tue Aug 24 19:22:40 CEST 2021


Commit: f3b2cbcb8158e126c2053133c83fda81bbd844d6
Author: Pablo Vazquez
Date:   Tue Aug 24 18:46:21 2021 +0200
Branches: temp-ui-tweaks
https://developer.blender.org/rBf3b2cbcb8158e126c2053133c83fda81bbd844d6

UI: Separate each choice inside radio buttons

Add some room between the choices. This way we can give the background and
non-active options the same color and make it look more like only one choice
can be active at a time.

This is in an effort to make the radio buttons and toggle buttons look different.
Currently in Blender they looked the same even though radio buttons only allow
one active option at a time, while toggles can be have multiple.

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

M	source/blender/editors/interface/interface_widgets.c

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

diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 585348555a1..01bdf4ce7e2 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4198,10 +4198,32 @@ static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
 {
   uiWidgetBase wtb;
   widget_init(&wtb);
-
   const float rad = wcol->roundness * U.widget_unit;
-  round_box_edges(&wtb, roundboxalign, rect, rad);
+  const float padding = 0.05f;
+  float color[3];
+  rgba_uchar_to_float(color, wcol->item);
+
+  /* Draw the background for the entire widget first. */
+  UI_draw_roundbox_corner_set(roundboxalign);
+  UI_draw_roundbox_4fv(
+      &(const rctf){
+          .xmin = rect->xmin,
+          .xmax = rect->xmax,
+          .ymin = rect->ymin,
+          .ymax = rect->ymax,
+      },
+      true,
+      rad,
+      color);
+
+  /* Draw the pill inside, with a small margin to separate each radio choice. */
+  rect->xmin += padding * U.widget_unit;
+  rect->xmax -= padding * U.widget_unit;
+  rect->ymin += padding * U.widget_unit;
+  rect->ymax -= padding * U.widget_unit;
+  round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
 
+  wtb.draw_emboss = false;
   widgetbase_draw(&wtb, wcol);
 }



More information about the Bf-blender-cvs mailing list