diff options
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 9ba1a2c73f4..1be62e535de 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -518,7 +518,7 @@ GPUBatch *ui_batch_roundbox_shadow_get(void) void UI_draw_anti_tria( float x1, float y1, float x2, float y2, float x3, float y3, const float color[4]) { - float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}}; + const float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}}; float draw_color[4]; copy_v4_v4(draw_color, color); @@ -1181,12 +1181,7 @@ void UI_widgetbase_draw_cache_flush(void) MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, (float *)g_widget_base_batch.params); GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GPU_matrix_bind(batch->interface); - GPU_shader_set_srgb_uniform(batch->interface); - GPU_batch_bind(batch); - GPU_batch_draw_advanced(batch, 0, 0, 0, g_widget_base_batch.count); - - GPU_batch_program_use_end(batch); + GPU_batch_draw_instanced(batch, g_widget_base_batch.count); } g_widget_base_batch.count = 0; } @@ -1356,7 +1351,7 @@ static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect) static int ui_but_draw_menu_icon(const uiBut *but) { - return (but->flag & UI_BUT_ICON_SUBMENU) && (but->dt == UI_EMBOSS_PULLDOWN); + return (but->flag & UI_BUT_ICON_SUBMENU) && (but->emboss == UI_EMBOSS_PULLDOWN); } /* icons have been standardized... and this call draws in untransformed coordinates */ @@ -1400,7 +1395,7 @@ static void widget_draw_icon( alpha *= but->a2; } } - else if (ELEM(but->type, UI_BTYPE_BUT)) { + else if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_DECORATOR)) { if (but->flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { alpha *= 0.5f; } @@ -1417,7 +1412,7 @@ static void widget_draw_icon( but->str && but->str[0] == '\0') { xs = rect->xmin + 2.0f * ofs; } - else if (but->dt == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) { + else if (but->emboss == UI_EMBOSS_NONE || but->type == UI_BTYPE_LABEL) { xs = rect->xmin + 2.0f * ofs; } else { @@ -2375,7 +2370,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* pass (even if its a menu toolbar) */ } else if (ui_block_is_pie_menu(but->block)) { - if (but->dt == UI_EMBOSS_RADIAL) { + if (but->emboss == UI_EMBOSS_RADIAL) { rect->xmin += 0.3f * U.widget_unit; } } @@ -2568,7 +2563,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_REDALERT) { - uchar red[4] = {255, 0, 0}; + const uchar red[4] = {255, 0, 0}; if (wt->draw) { color_blend_v3_v3(wt->wcol.inner, red, 0.4f); } @@ -2585,7 +2580,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_NODE_ACTIVE) { - uchar blue[4] = {86, 128, 194}; + const uchar blue[4] = {86, 128, 194}; color_blend_v3_v3(wt->wcol.inner, blue, 0.3f); } } @@ -2971,7 +2966,10 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const * \{ */ /* draws in resolution of 48x4 colors */ -void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, const float alpha) +void ui_draw_gradient(const rcti *rect, + const float hsv[3], + const eButGradientType type, + const float alpha) { /* allows for 4 steps (red->yellow) */ const int steps = 48; @@ -3088,6 +3086,8 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons copy_v3_v3(col1[1], col1[2]); copy_v3_v3(col1[3], col1[2]); break; + default: + break; } /* rect */ @@ -3122,11 +3122,11 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } void ui_hsvcube_pos_from_vals( - const uiBut *but, const rcti *rect, const float *hsv, float *r_xp, float *r_yp) + const uiButHSVCube *hsv_but, const rcti *rect, const float *hsv, float *r_xp, float *r_yp) { float x = 0.0f, y = 0.0f; - switch ((int)but->a1) { + switch (hsv_but->gradient_type) { case UI_GRAD_SV: x = hsv[1]; y = hsv[2]; @@ -3159,7 +3159,7 @@ void ui_hsvcube_pos_from_vals( case UI_GRAD_V_ALT: x = 0.5f; /* exception only for value strip - use the range set in but->min/max */ - y = (hsv[2] - but->softmin) / (but->softmax - but->softmin); + y = (hsv[2] - hsv_but->but.softmin) / (hsv_but->but.softmax - hsv_but->but.softmin); break; } @@ -3170,6 +3170,7 @@ void ui_hsvcube_pos_from_vals( static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) { + const uiButHSVCube *hsv_but = (uiButHSVCube *)but; float rgb[3]; float x = 0.0f, y = 0.0f; ColorPicker *cpicker = but->custom_data; @@ -3183,9 +3184,9 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) ui_scene_linear_to_color_picker_space(but, rgb); rgb_to_hsv_compat_v(rgb, hsv_n); - ui_draw_gradient(rect, hsv_n, but->a1, 1.0f); + ui_draw_gradient(rect, hsv_n, hsv_but->gradient_type, 1.0f); - ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y); + ui_hsvcube_pos_from_vals(hsv_but, rect, hsv_n, &x, &y); CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); @@ -3202,6 +3203,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) /* vertical 'value' slider, using new widget code */ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) { + const uiButHSVCube *hsv_but = (uiButHSVCube *)but; bTheme *btheme = UI_GetTheme(); uiWidgetColors *wcol = &btheme->tui.wcol_numslider; uiWidgetBase wtb; @@ -3212,7 +3214,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) ui_but_v3_get(but, rgb); ui_scene_linear_to_color_picker_space(but, rgb); - if (but->a1 == UI_GRAD_L_ALT) { + if (hsv_but->gradient_type == UI_GRAD_L_ALT) { rgb_to_hsl_v(rgb, hsv); } else { @@ -3221,7 +3223,7 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) v = hsv[2]; /* map v from property range to [0,1] */ - if (but->a1 == UI_GRAD_V_ALT) { + if (hsv_but->gradient_type == UI_GRAD_V_ALT) { float min = but->softmin, max = but->softmax; v = (v - min) / (max - min); } @@ -3609,6 +3611,7 @@ static void widget_scroll( static void widget_progressbar( uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) { + uiButProgressbar *but_progressbar = (uiButProgressbar *)but; uiWidgetBase wtb, wtb_bar; rcti rect_prog = *rect, rect_bar = *rect; @@ -3616,7 +3619,7 @@ static void widget_progressbar( widget_init(&wtb_bar); /* round corners */ - float value = but->a1; + float value = but_progressbar->progress; float offs = wcol->roundness * BLI_rcti_size_y(&rect_prog); float w = value * BLI_rcti_size_x(&rect_prog); @@ -3768,6 +3771,8 @@ static void widget_numslider( static void widget_swatch( uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { + BLI_assert(but->type == UI_BTYPE_COLOR); + uiButColor *color_but = (uiButColor *)but; uiWidgetBase wtb; float rad, col[4]; @@ -3822,8 +3827,8 @@ static void widget_swatch( } widgetbase_draw_ex(&wtb, wcol, show_alpha_checkers); - if (but->a1 == UI_PALETTE_COLOR && - ((Palette *)but->rnapoin.owner_id)->active_color == (int)but->a2) { + if (color_but->is_pallete_color && + ((Palette *)but->rnapoin.owner_id)->active_color == color_but->palette_color_index) { float width = rect->xmax - rect->xmin; float height = rect->ymax - rect->ymin; /* find color luminance and change it slightly */ @@ -4071,7 +4076,7 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_REDALERT) { - uchar red[4] = {255, 0, 0}; + const uchar red[4] = {255, 0, 0}; color_blend_v3_v3(wt->wcol.text, red, 0.4f); } } @@ -4502,7 +4507,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu uiWidgetType *wt = NULL; /* handle menus separately */ - if (but->dt == UI_EMBOSS_PULLDOWN) { + if (but->emboss == UI_EMBOSS_PULLDOWN) { switch (but->type) { case UI_BTYPE_LABEL: widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); @@ -4515,7 +4520,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu break; } } - else if (but->dt == UI_EMBOSS_NONE) { + else if (but->emboss == UI_EMBOSS_NONE) { /* "nothing" */ switch (but->type) { case UI_BTYPE_LABEL: @@ -4526,11 +4531,11 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu break; } } - else if (but->dt == UI_EMBOSS_RADIAL) { + else if (but->emboss == UI_EMBOSS_RADIAL) { wt = widget_type(UI_WTYPE_MENU_ITEM_RADIAL); } else { - BLI_assert(but->dt == UI_EMBOSS); + BLI_assert(but->emboss == UI_EMBOSS); switch (but->type) { case UI_BTYPE_LABEL: @@ -4552,6 +4557,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu break; case UI_BTYPE_BUT: + case UI_BTYPE_DECORATOR: #ifdef USE_UI_TOOLBAR_HACK if ((but->icon != ICON_NONE) && UI_but_is_tool(but)) { wt = widget_type(UI_WTYPE_TOOLBAR_ITEM); @@ -4666,8 +4672,10 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect); break; - case UI_BTYPE_HSVCUBE: - if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { + case UI_BTYPE_HSVCUBE: { + const uiButHSVCube *hsv_but = (uiButHSVCube *)but; + + if (ELEM(hsv_but->gradient_type, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { /* vertical V slider, uses new widget draw now */ ui_draw_but_HSV_v(but, rect); } @@ -4675,6 +4683,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu ui_draw_but_HSVCUBE(but, rect); } break; + } case UI_BTYPE_HSVCIRCLE: ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect); @@ -4779,7 +4788,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu } if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - if (but->dt != UI_EMBOSS_PULLDOWN) { + if (but->emboss != UI_EMBOSS_PULLDOWN) { disabled = true; } } |