Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.c
| Show First 20 Lines • Show All 4,896 Lines • ▼ Show 20 Lines | |||||
| * because we need to pass in the original location so we know where to show the arrow. | * because we need to pass in the original location so we know where to show the arrow. | ||||
| */ | */ | ||||
| static void ui_draw_popover_back_impl(const uiWidgetColors *wcol, | static void ui_draw_popover_back_impl(const uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| int direction, | int direction, | ||||
| const float unit_size, | const float unit_size, | ||||
| const float mval_origin[2]) | const float mval_origin[2]) | ||||
| { | { | ||||
| /* tsk, this isn't nice. */ | |||||
| const float unit_half = unit_size / 2; | const float unit_half = unit_size / 2; | ||||
| const float cent_x = mval_origin ? CLAMPIS(mval_origin[0], | |||||
| rect->xmin + unit_size, | /* Constrain arrow location to popover width. */ | ||||
| rect->xmax - unit_size) : | const float cent_x = CLAMPIS(mval_origin[0], rect->xmin + unit_half, rect->xmax - unit_half); | ||||
| BLI_rcti_cent_x(rect); | const bool is_down = (direction == UI_DIR_DOWN); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| /* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */ | /* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */ | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| const int roundboxalign = UI_CNR_ALL; | /* Don't round the corner if the arrow is on the left or right. */ | ||||
| widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit); | const float radin = wcol->roundness * U.widget_unit; | ||||
| int roundboxalign = UI_CNR_ALL; | |||||
| if (IN_RANGE_INCL(cent_x - unit_half, rect->xmin, rect->xmin + radin)) { | |||||
| roundboxalign &= ~(is_down ? UI_CNR_TOP_LEFT : UI_CNR_BOTTOM_LEFT); | |||||
| } | |||||
| else if (IN_RANGE_INCL(cent_x + unit_half, rect->xmax, rect->xmax - radin)) { | |||||
| roundboxalign &= ~(is_down ? UI_CNR_TOP_RIGHT : UI_CNR_BOTTOM_RIGHT); | |||||
| } | |||||
| round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit); | widget_softshadow(rect, roundboxalign, radin); | ||||
| round_box_edges(&wtb, roundboxalign, rect, radin); | |||||
| wtb.draw_emboss = false; | wtb.draw_emboss = false; | ||||
| widgetbase_draw(&wtb, wcol); | widgetbase_draw(&wtb, wcol); | ||||
| } | } | ||||
| /* Draw popover arrow (top/bottom) */ | /* Draw popover arrow (top/bottom) */ | ||||
| if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { | if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| const bool is_down = (direction == UI_DIR_DOWN); | |||||
| const int sign = is_down ? 1 : -1; | const int sign = is_down ? 1 : -1; | ||||
| float y = is_down ? rect->ymax : rect->ymin; | float y = is_down ? rect->ymax : rect->ymin; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immBegin(GPU_PRIM_TRIS, 3); | immBegin(GPU_PRIM_TRIS, 3); | ||||
| immUniformColor4ubv(wcol->outline); | immUniformColor4ubv(wcol->outline); | ||||
| immVertex2f(pos, cent_x - unit_half, y); | immVertex2f(pos, cent_x - unit_half, y); | ||||
| immVertex2f(pos, cent_x + unit_half, y); | immVertex2f(pos, cent_x + unit_half, y); | ||||
| ▲ Show 20 Lines • Show All 424 Lines • Show Last 20 Lines | |||||