[Bf-blender-cvs] [d1917237562] modifier-panels-ui: Change padding around checkboxes
Julian Eisel
noreply at git.blender.org
Thu Apr 16 21:30:23 CEST 2020
Commit: d1917237562f2964d2da22e3716dc2219fd17b8c
Author: Julian Eisel
Date: Mon Apr 13 00:02:39 2020 +0200
Branches: modifier-panels-ui
https://developer.blender.org/rBd1917237562f2964d2da22e3716dc2219fd17b8c
Change padding around checkboxes
Two changes:
* Reduce padding between checkbox and text. That makes it clearer what
the checkbox belongs to if there's also a column heading in front of
the checkbox.
* Don't add padding on the left side of checkboxes. That makes them line
up better with items above and below it.
===================================================================
M source/blender/editors/interface/interface_layout.c
M source/blender/editors/interface/interface_widgets.c
===================================================================
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 95431531ed6..dec925a7eb4 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1784,6 +1784,7 @@ static void ui_item_rna_size(uiLayout *layout,
PropertyType type;
PropertySubType subtype;
int len, w = 0, h;
+ bool is_checkbox_only = false;
/* arbitrary extended width by type */
type = RNA_property_type(prop);
@@ -1795,6 +1796,10 @@ static void ui_item_rna_size(uiLayout *layout,
name = "non-empty text";
}
else if (type == PROP_BOOLEAN) {
+ if (icon == ICON_NONE) {
+ /* Exception for checkboxes, they need a little less space to align nicely. */
+ is_checkbox_only = true;
+ }
icon = ICON_DOT;
}
else if (type == PROP_ENUM) {
@@ -1854,6 +1859,9 @@ static void ui_item_rna_size(uiLayout *layout,
if (type == PROP_BOOLEAN && name[0]) {
w += UI_UNIT_X / 5;
}
+ else if (is_checkbox_only) {
+ w -= UI_UNIT_X / 4;
+ }
else if (type == PROP_ENUM && !icon_only) {
w += UI_UNIT_X / 4;
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index ae40b01c77d..fedf552632b 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -4121,10 +4121,10 @@ static void widget_optionbut(uiWidgetColors *wcol,
/* smaller */
delta = 1 + BLI_rcti_size_y(&recttemp) / 8;
- recttemp.xmin += delta;
- recttemp.ymin += delta;
- recttemp.xmax -= delta;
- recttemp.ymax -= delta;
+ BLI_rcti_resize(
+ &recttemp, BLI_rcti_size_x(&recttemp) - delta, BLI_rcti_size_y(&recttemp) - delta);
+ /* Keep one edge in place. */
+ BLI_rcti_translate(&recttemp, text_before_widget ? delta : -delta, 0);
rad = wcol->roundness * BLI_rcti_size_y(&recttemp);
round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
@@ -4136,8 +4136,8 @@ static void widget_optionbut(uiWidgetColors *wcol,
widgetbase_draw(&wtb, wcol);
- /* text space */
- const float offset = BLI_rcti_size_y(rect) * 0.7 + delta;
+ /* Text space - factor is really just eyeballed. */
+ const float offset = BLI_rcti_size_y(rect) * 0.31f + delta;
if (text_before_widget) {
rect->xmax -= offset;
}
More information about the Bf-blender-cvs
mailing list