Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-22 07:29:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-22 07:43:23 +0300
commit813694e07b57e45ae3e4e2b707932fac73cab217 (patch)
tree0b2cac67fe2df57ce8a3de54bc2d3350522b70df /source/blender/editors/interface
parentbd2299aae5085b3498a6daaa71f18021e905c393 (diff)
UI: use checkbox text for property split layout
Use right aligned checkboxes when 'use_property_split' is enabled instead of a separate label.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_layout.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index ebff54ee6ae..8329ddfed48 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1572,6 +1572,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
bool is_array;
const bool use_prop_sep = ((layout->item.flag & UI_ITEM_PROP_SEP) != 0);
+ /* By default 'use_prop_sep' uses a separate column for labels.
+ * This is an exception for check-boxes otherwise only the small checkbox region is clickable.
+ *
+ * Keep using 'use_prop_sep' instead of disabling it entirely because
+ * we need the ability to have decorators still. */
+ bool use_prop_set_split_label = use_prop_sep;
+
#ifdef UI_PROP_DECORATE
struct {
bool use_prop_decorate;
@@ -1602,6 +1609,14 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
}
+#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
+ if (use_prop_sep) {
+ if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
+ use_prop_set_split_label = false;
+ }
+ }
+#endif
+
if (icon == ICON_NONE)
icon = RNA_property_ui_icon(prop);
@@ -1691,25 +1706,16 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
}
#endif /* UI_PROP_DECORATE */
- if (name[0] == '\0') {
+ if ((name[0] == '\0') || (use_prop_set_split_label == false)) {
/* Ensure we get a column when text is not set. */
layout = uiLayoutColumn(layout_row ? layout_row : layout, true);
layout->space = 0;
}
else {
const PropertySubType subtype = RNA_property_subtype(prop);
- uiLayout *layout_split;
-#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
- if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
- layout_split = uiLayoutRow(layout_row ? layout_row : layout, true);
- }
- else
-#endif /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */
- {
- layout_split = uiLayoutSplit(
- layout_row ? layout_row : layout,
- UI_ITEM_PROP_SEP_DIVIDE, true);
- }
+ uiLayout *layout_split = uiLayoutSplit(
+ layout_row ? layout_row : layout,
+ UI_ITEM_PROP_SEP_DIVIDE, true);
layout_split->space = 0;
uiLayout *layout_sub = uiLayoutColumn(layout_split, true);
layout_sub->space = 0;
@@ -1771,12 +1777,6 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
layout = uiLayoutColumn(layout_split, true);
}
layout->space = 0;
-
-#ifdef UI_PROP_SEP_ICON_WIDTH_EXCEPTION
- if (type == PROP_BOOLEAN && (icon == ICON_NONE) && !icon_only) {
- w = UI_UNIT_X;
- }
-#endif /* UI_PROP_SEP_ICON_WIDTH_EXCEPTION */
}
#ifdef UI_PROP_DECORATE
@@ -1797,7 +1797,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (index == RNA_NO_INDEX && is_array) {
ui_item_array(
layout, block, name, icon, ptr, prop, len, 0, 0, w, h,
- expand, slider, toggle, icon_only, compact, !use_prop_sep);
+ expand, slider, toggle, icon_only, compact, !use_prop_set_split_label);
}
/* enum item */
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
@@ -1838,6 +1838,13 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
if (layout->activate_init)
UI_but_flag_enable(but, UI_BUT_ACTIVATE_ON_INIT);
+
+ if (use_prop_set_split_label == false) {
+ /* When the button uses it's own text right align it. */
+ but->drawflag |= UI_BUT_TEXT_RIGHT;
+ but->drawflag &= ~UI_BUT_TEXT_LEFT;
+ }
+
}
/* Mark non-embossed textfields inside a listbox. */