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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-10-29 18:58:34 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-10-29 21:04:07 +0300
commitb5667c2ca7f7cc33903b7f664dfbd3bccd8cdd22 (patch)
tree189f7a60d860c563c6abf37899aae3fcf85c46cf
parent4c7f08e5ebc107e13501a5b1e82a44edeaf7b7c3 (diff)
UI: allow off/on icons to be in reverse order.
The same icons are reused for "hide" and "show" properties, which need to be in reverse order compared to each other.
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface.c6
-rw-r--r--source/blender/editors/interface/interface_widgets.c19
-rw-r--r--source/blender/makesrna/RNA_define.h2
-rw-r--r--source/blender/makesrna/RNA_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_define.c6
6 files changed, 30 insertions, 6 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 92423d84c3f..ac463fe87a2 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -236,6 +236,8 @@ enum {
UI_BUT_ACTIVE_RIGHT = (1 << 22), /* Active right part of number button */
UI_BUT_HAS_SHORTCUT = (1 << 23), /* Button has shortcut text */
+
+ UI_BUT_ICON_REVERSE = (1 << 24), /* Reverse order of consecutive off/on icons */
};
/* scale fixed button widths by this to account for DPI */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3e8d32c0e2b..1e1c9c1fa3f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2985,7 +2985,11 @@ void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_ICON_TOGGLE:
case UI_BTYPE_ICON_TOGGLE_N:
- if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
+ if ((but->rnaprop == NULL) || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
+ if (but->rnaprop && RNA_property_flag(but->rnaprop) & PROP_ICONS_REVERSE) {
+ but->drawflag |= UI_BUT_ICON_REVERSE;
+ }
+
but->iconadd = (but->flag & UI_SELECT) ? 1 : 0;
}
break;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 99022a14b6a..b8a661c5542 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2016,6 +2016,21 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
}
+static BIFIconID widget_icon_id(uiBut *but)
+{
+ if (!(but->flag & UI_HAS_ICON)) {
+ return ICON_NONE;
+ }
+
+ /* Consecutive icons can be toggle between. */
+ if (but->drawflag & UI_BUT_ICON_REVERSE) {
+ return but->icon - but->iconadd;
+ }
+ else {
+ return but->icon + but->iconadd;
+ }
+}
+
/* draws text and icons for buttons */
static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
{
@@ -2039,7 +2054,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
/* Big previews with optional text label below */
if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) {
- const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
+ const BIFIconID icon = widget_icon_id(but);
int icon_size = BLI_rcti_size_y(rect);
int text_size = 0;
@@ -2076,7 +2091,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
}
#endif
- const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
+ const BIFIconID icon = widget_icon_id(but);
int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT;
const float icon_size = icon_size_init / (but->block->aspect / UI_DPI_FAC);
const float icon_padding = 2 * UI_DPI_FAC;
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 551805f6a80..e14dcbea09e 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -175,7 +175,7 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value);
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description);
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision);
-void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, bool consecutive);
+void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive);
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *updatefunc);
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable);
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 0e7c3956d7b..72e1c05de3c 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -184,6 +184,7 @@ typedef enum PropertyFlag {
/* icon */
PROP_ICONS_CONSECUTIVE = (1 << 12),
+ PROP_ICONS_REVERSE = (1 << 8),
/* hidden in the user interface */
PROP_HIDDEN = (1 << 19),
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index c3c7367283e..42db80c83c0 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1426,11 +1426,13 @@ void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *d
prop->description = description;
}
-void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, bool consecutive)
+void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
{
prop->icon = icon;
- if (consecutive)
+ if (consecutive != 0)
prop->flag |= PROP_ICONS_CONSECUTIVE;
+ if (consecutive < 0)
+ prop->flag |= PROP_ICONS_REVERSE;
}
/**