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:
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r--source/blender/editors/interface/interface_widgets.c54
1 files changed, 52 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 51bf09125ba..44a9d0d91b6 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -66,6 +66,15 @@
/* icons are 80% of height of button (16 pixels inside 20 height) */
#define ICON_SIZE_FROM_BUTRECT(rect) (0.8f * BLI_rcti_size_y(rect))
+#define UI_BUT_FLAGS_PUBLIC \
+ (UI_SELECT | UI_SCROLLED | UI_ACTIVE | UI_HAS_ICON | UI_TEXTINPUT | UI_HIDDEN)
+
+/* Bits 0..5 are from UI_SELECT .. etc */
+enum {
+ /* Show that holding the button opens a menu. */
+ UI_STATE_HOLD_ACTION = (1 << 6),
+};
+
/* ************** widget base functions ************** */
/**
* - in: roundbox codes for corner types and radius
@@ -184,6 +193,15 @@ static const unsigned int check_tria_face[4][3] = {
{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
};
+#define OY -0.2
+#define SC 0.35
+static const unsigned int hold_action_tri_face[2][3] = {{2, 0, 1}, {3, 5, 4}};
+static const float hold_action_tri_vert[6][2] = {
+ {-0.5 + SC, 1.0 + OY}, {0.5, 1.0 + OY}, {0.5, 0.0 + OY + SC},
+};
+#undef OY
+#undef SC
+
/* ************************************************* */
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
@@ -529,6 +547,14 @@ static void widget_num_tria(uiWidgetTrias *tria, const rcti *rect, float triasiz
num_tria_face, ARRAY_SIZE(num_tria_face));
}
+static void widget_hold_action_tria(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
+{
+ widget_draw_tria_ex(
+ tria, rect, triasize, where,
+ hold_action_tri_vert, ARRAY_SIZE(hold_action_tri_vert),
+ hold_action_tri_face, ARRAY_SIZE(hold_action_tri_face));
+}
+
static void widget_scroll_circle(uiWidgetTrias *tria, const rcti *rect, float triasize, char where)
{
widget_draw_tria_ex(
@@ -3347,6 +3373,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
widgetbase_draw(&wtb, wcol);
}
+#if 0
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
uiWidgetBase wtb;
@@ -3359,6 +3386,25 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
widgetbase_draw(&wtb, wcol);
}
+#endif
+
+static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+ uiWidgetBase wtb;
+ const float rad = 0.25f * U.widget_unit;
+
+ widget_init(&wtb);
+
+ if (state & UI_STATE_HOLD_ACTION) {
+ /* Show that keeping pressed performs another action (typically a menu). */
+ widget_hold_action_tria(&wtb.tria1, rect, 0.75f, 'r');
+ }
+
+ /* half rounded */
+ round_box_edges(&wtb, roundboxalign, rect, rad);
+
+ widgetbase_draw(&wtb, wcol);
+}
static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect)
{
@@ -3439,7 +3485,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
case UI_WTYPE_EXEC:
wt.wcol_theme = &btheme->tui.wcol_tool;
- wt.draw = widget_roundbut;
+ wt.draw = widget_roundbut_exec;
break;
case UI_WTYPE_TOOLTIP:
@@ -3849,7 +3895,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
roundboxalign = widget_roundbox_set(but, rect);
- state = but->flag;
+ state = but->flag & UI_BUT_FLAGS_PUBLIC;
if ((but->editstr) ||
(UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_but_drag_multi_edit_get(but)))
@@ -3857,6 +3903,10 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
state |= UI_TEXTINPUT;
}
+ if (but->hold_func) {
+ state |= UI_STATE_HOLD_ACTION;
+ }
+
if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
if (but->dt != UI_EMBOSS_PULLDOWN)
disabled = true;