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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-23 09:38:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-23 09:51:13 +0300
commitdea3ba6d81843f4eac67713961963f5d12997831 (patch)
treef399de7eabfe506b7711a6411cf70640812d9c91 /source
parent9971eb4437acc0eeeed24f3975c3352599271f2a (diff)
UI: show arrow for popovers above buttons
Also don't align popover buttons with activated popovers.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_widgets.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index c3bf1dce962..a9bb3089175 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -2730,7 +2730,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
glDisable(GL_BLEND);
}
-static void widget_popover_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction)
+static void widget_popover_back(uiWidgetColors *wcol, rcti *rect, int UNUSED(flag), int direction)
{
/* tsk, this isn't nice. */
const float unit_half = (BLI_rcti_size_x(rect) / UI_POPOVER_WIDTH_UNITS) / 2;
@@ -2738,22 +2738,46 @@ static void widget_popover_back(uiWidgetColors *wcol, rcti *rect, int flag, int
rect->ymax -= unit_half;
rect->ymin += unit_half;
- widget_menu_back(wcol, rect, flag, direction);
- unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ glEnable(GL_BLEND);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ /* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */
+ {
+ uiWidgetBase wtb;
+ widget_init(&wtb);
- immUniformColor4ubv((unsigned char *)wcol->inner);
+ const int roundboxalign = UI_CNR_ALL;
+ widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
+
+ round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit);
+ wtb.draw_emboss = false;
+ widgetbase_draw(&wtb, wcol);
+ }
+
+ /* Draw popover arrow (top/bottom) */
+ if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) {
+ unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immUniformColor4ubv((unsigned char *)wcol->inner);
+ glEnable(GL_BLEND);
+ immBegin(GWN_PRIM_TRIS, 3);
+ if (direction == UI_DIR_DOWN) {
+ const float y = rect->ymax;
+ immVertex2f(pos, cent_x - unit_half, y);
+ immVertex2f(pos, cent_x + unit_half, y);
+ immVertex2f(pos, cent_x, y + unit_half);
+ }
+ else {
+ const float y = rect->ymin;
+ immVertex2f(pos, cent_x - unit_half, y);
+ immVertex2f(pos, cent_x + unit_half, rect->ymin);
+ immVertex2f(pos, cent_x, y - unit_half);
+ }
+ immEnd();
+ immUnbindProgram();
+ }
- glEnable(GL_BLEND);
- immBegin(GWN_PRIM_TRIS, 3);
- immVertex2f(pos, cent_x - unit_half, rect->ymax);
- immVertex2f(pos, cent_x + unit_half, rect->ymax);
- immVertex2f(pos, cent_x, rect->ymax + unit_half);
- immEnd();
glDisable(GL_BLEND);
- immUnbindProgram();
}
static void ui_hsv_cursor(float x, float y)
@@ -4293,7 +4317,7 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
}
/* align with open menu */
- if (but->active) {
+ if (but->active && (but->type != UI_BTYPE_POPOVER)) {
int direction = ui_but_menu_direction(but);
if (direction == UI_DIR_UP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT);