Merge branch 'blender-v3.0-release'
This commit is contained in:
commit
6b1b3383c6
|
@ -1351,7 +1351,10 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
|
|||
immUnbindProgram();
|
||||
}
|
||||
|
||||
void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rect)
|
||||
void ui_draw_but_UNITVEC(uiBut *but,
|
||||
const uiWidgetColors *wcol,
|
||||
const rcti *rect,
|
||||
const float radius)
|
||||
{
|
||||
/* sphere color */
|
||||
const float diffuse[3] = {1.0f, 1.0f, 1.0f};
|
||||
|
@ -1368,7 +1371,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
|
|||
.ymax = rect->ymax,
|
||||
},
|
||||
true,
|
||||
5.0f,
|
||||
radius,
|
||||
wcol->inner,
|
||||
255);
|
||||
|
||||
|
|
|
@ -923,7 +923,10 @@ void ui_draw_but_VECTORSCOPE(struct ARegion *region,
|
|||
const struct uiWidgetColors *wcol,
|
||||
const rcti *rect);
|
||||
void ui_draw_but_COLORBAND(uiBut *but, const struct uiWidgetColors *wcol, const rcti *rect);
|
||||
void ui_draw_but_UNITVEC(uiBut *but, const struct uiWidgetColors *wcol, const rcti *rect);
|
||||
void ui_draw_but_UNITVEC(uiBut *but,
|
||||
const struct uiWidgetColors *wcol,
|
||||
const rcti *rect,
|
||||
const float radius);
|
||||
void ui_draw_but_CURVE(struct ARegion *region,
|
||||
uiBut *but,
|
||||
const struct uiWidgetColors *wcol,
|
||||
|
|
|
@ -1122,7 +1122,8 @@ static void panel_draw_highlight_border(const Panel *panel,
|
|||
}
|
||||
|
||||
const bTheme *btheme = UI_GetTheme();
|
||||
const float radius = btheme->tui.panel_roundness * U.widget_unit * 0.5f;
|
||||
const float aspect = panel->runtime.block->aspect;
|
||||
const float radius = (btheme->tui.panel_roundness * U.widget_unit * 0.5f) / aspect;
|
||||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
|
||||
float color[4];
|
||||
|
@ -1245,7 +1246,8 @@ static void panel_draw_aligned_backdrop(const Panel *panel,
|
|||
}
|
||||
|
||||
const bTheme *btheme = UI_GetTheme();
|
||||
const float radius = btheme->tui.panel_roundness * U.widget_unit * 0.5f;
|
||||
const float aspect = panel->runtime.block->aspect;
|
||||
const float radius = btheme->tui.panel_roundness * U.widget_unit * 0.5f / aspect;
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
|
@ -45,6 +46,7 @@
|
|||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_interface_icons.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "interface_intern.h"
|
||||
|
||||
|
@ -267,8 +269,9 @@ typedef struct uiWidgetType {
|
|||
uiWidgetColors wcol;
|
||||
|
||||
void (*state)(struct uiWidgetType *, int state, int drawflag, eUIEmbossType emboss);
|
||||
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
|
||||
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
|
||||
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign, const float zoom);
|
||||
void (*custom)(
|
||||
uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign, const float zoom);
|
||||
void (*text)(const uiFontStyle *, const uiWidgetColors *, uiBut *, rcti *);
|
||||
|
||||
} uiWidgetType;
|
||||
|
@ -2594,6 +2597,27 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag, eUIEmbossTyp
|
|||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Widget Corner Radius Calculation
|
||||
*
|
||||
* A lot of places of the UI like the Node Editor or panels are zoomable. In most cases we can
|
||||
* get the zoom factor from the aspect, but in some cases like popups we need to fall back to
|
||||
* using the the size of the element. The latter method relies on the element always being the same
|
||||
* size.
|
||||
* \{ */
|
||||
|
||||
static float widget_radius_from_zoom(const float zoom, const uiWidgetColors *wcol)
|
||||
{
|
||||
return wcol->roundness * U.widget_unit * zoom;
|
||||
}
|
||||
|
||||
static float widget_radius_from_rcti(const rcti *rect, const uiWidgetColors *wcol)
|
||||
{
|
||||
return wcol->roundness * BLI_rcti_size_y(rect);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Widget Types
|
||||
* \{ */
|
||||
|
@ -2785,7 +2809,8 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r
|
|||
immUnbindProgram();
|
||||
}
|
||||
|
||||
static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction)
|
||||
static void widget_menu_back(
|
||||
uiWidgetColors *wcol, rcti *rect, int flag, int direction, const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
int roundboxalign = UI_CNR_ALL;
|
||||
|
@ -2807,9 +2832,10 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
|
|||
}
|
||||
|
||||
GPU_blend(GPU_BLEND_ALPHA);
|
||||
widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit);
|
||||
const float radius = widget_radius_from_zoom(zoom, wcol);
|
||||
widget_softshadow(rect, roundboxalign, radius);
|
||||
|
||||
round_box_edges(&wtb, roundboxalign, rect, wcol->roundness * U.widget_unit);
|
||||
round_box_edges(&wtb, roundboxalign, rect, radius);
|
||||
wtb.draw_emboss = false;
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
||||
|
@ -3314,9 +3340,9 @@ static void ui_draw_separator(const rcti *rect, const uiWidgetColors *wcol)
|
|||
* \{ */
|
||||
|
||||
static void widget_numbut_draw(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, bool emboss)
|
||||
uiWidgetColors *wcol, rcti *rect, const float zoom, int state, int roundboxalign, bool emboss)
|
||||
{
|
||||
const float rad = wcol->roundness * BLI_rcti_size_y(rect);
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
const int handle_width = min_ii(BLI_rcti_size_x(rect) / 3, BLI_rcti_size_y(rect) * 0.7f);
|
||||
|
||||
if (state & UI_SELECT) {
|
||||
|
@ -3415,17 +3441,19 @@ static void widget_numbut_draw(
|
|||
}
|
||||
}
|
||||
|
||||
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
static void widget_numbut(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
widget_numbut_draw(wcol, rect, state, roundboxalign, false);
|
||||
widget_numbut_draw(wcol, rect, zoom, state, roundboxalign, false);
|
||||
}
|
||||
|
||||
static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
||||
static void widget_menubut(
|
||||
uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign, const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
/* decoration */
|
||||
|
@ -3464,10 +3492,14 @@ static void widget_menubut_embossn(const uiBut *UNUSED(but),
|
|||
/**
|
||||
* Draw number buttons still with triangles when field is not embossed
|
||||
*/
|
||||
static void widget_numbut_embossn(
|
||||
const uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
static void widget_numbut_embossn(const uiBut *UNUSED(but),
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int state,
|
||||
int roundboxalign,
|
||||
const float zoom)
|
||||
{
|
||||
widget_numbut_draw(wcol, rect, state, roundboxalign, true);
|
||||
widget_numbut_draw(wcol, rect, zoom, state, roundboxalign, true);
|
||||
}
|
||||
|
||||
/* function in use for buttons and for view2d sliders */
|
||||
|
@ -3558,8 +3590,12 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
|
|||
}
|
||||
}
|
||||
|
||||
static void widget_scroll(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
|
||||
static void widget_scroll(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int state,
|
||||
int UNUSED(roundboxalign),
|
||||
const float UNUSED(zoom))
|
||||
{
|
||||
/* calculate slider part */
|
||||
const float value = (float)ui_but_value_get(but);
|
||||
|
@ -3616,8 +3652,12 @@ static void widget_scroll(
|
|||
UI_draw_widget_scroll(wcol, rect, &rect1, state);
|
||||
}
|
||||
|
||||
static void widget_progressbar(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
||||
static void widget_progressbar(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int roundboxalign,
|
||||
const float zoom)
|
||||
{
|
||||
uiButProgressbar *but_progressbar = (uiButProgressbar *)but;
|
||||
rcti rect_prog = *rect, rect_bar = *rect;
|
||||
|
@ -3628,7 +3668,7 @@ static void widget_progressbar(
|
|||
|
||||
/* round corners */
|
||||
const float value = but_progressbar->progress;
|
||||
const float ofs = wcol->roundness * BLI_rcti_size_y(&rect_prog);
|
||||
const float ofs = widget_radius_from_zoom(zoom, wcol);
|
||||
float w = value * BLI_rcti_size_x(&rect_prog);
|
||||
|
||||
/* Ensure minimum size. */
|
||||
|
@ -3647,15 +3687,19 @@ static void widget_progressbar(
|
|||
widgetbase_draw(&wtb_bar, wcol);
|
||||
}
|
||||
|
||||
static void widget_treerow_exec(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign), int indentation)
|
||||
static void widget_treerow_exec(uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int state,
|
||||
int UNUSED(roundboxalign),
|
||||
int indentation,
|
||||
const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
/* no outline */
|
||||
wtb.draw_outline = false;
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
if ((state & UI_ACTIVE) || (state & UI_SELECT)) {
|
||||
|
@ -3667,17 +3711,19 @@ static void widget_treerow_exec(
|
|||
}
|
||||
|
||||
static void widget_treerow(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
uiButTreeRow *tree_row = (uiButTreeRow *)but;
|
||||
BLI_assert(but->type == UI_BTYPE_TREEROW);
|
||||
widget_treerow_exec(wcol, rect, state, roundboxalign, tree_row->indentation);
|
||||
widget_treerow_exec(wcol, rect, state, roundboxalign, tree_row->indentation, zoom);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void widget_nodesocket(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
static void widget_nodesocket(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int UNUSED(roundboxalign),
|
||||
const float UNUSED(zoom))
|
||||
{
|
||||
const int radi = 0.25f * BLI_rcti_size_y(rect);
|
||||
|
||||
|
@ -3712,14 +3758,14 @@ static void widget_nodesocket(
|
|||
}
|
||||
|
||||
static void widget_numslider(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb, wtb1;
|
||||
widget_init(&wtb);
|
||||
widget_init(&wtb1);
|
||||
|
||||
/* Backdrop first. */
|
||||
const float ofs = wcol->roundness * BLI_rcti_size_y(rect);
|
||||
const float ofs = widget_radius_from_zoom(zoom, wcol);
|
||||
const float toffs = ofs * 0.75f;
|
||||
round_box_edges(&wtb, roundboxalign, rect, ofs);
|
||||
|
||||
|
@ -3822,7 +3868,7 @@ static void widget_numslider(
|
|||
#define SWATCH_KEYED_BORDER 3
|
||||
|
||||
static void widget_swatch(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
BLI_assert(but->type == UI_BTYPE_COLOR);
|
||||
uiButColor *color_but = (uiButColor *)but;
|
||||
|
@ -3841,7 +3887,7 @@ static void widget_swatch(
|
|||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
ui_but_v3_get(but, col);
|
||||
|
@ -3906,14 +3952,19 @@ static void widget_swatch(
|
|||
}
|
||||
}
|
||||
|
||||
static void widget_unitvec(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
static void widget_unitvec(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int UNUSED(roundboxalign),
|
||||
const float zoom)
|
||||
{
|
||||
ui_draw_but_UNITVEC(but, wcol, rect);
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
ui_draw_but_UNITVEC(but, wcol, rect, rad);
|
||||
}
|
||||
|
||||
static void widget_icon_has_anim(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT) &&
|
||||
but->emboss != UI_EMBOSS_NONE) {
|
||||
|
@ -3921,14 +3972,14 @@ static void widget_icon_has_anim(
|
|||
widget_init(&wtb);
|
||||
wtb.draw_outline = false;
|
||||
|
||||
const float rad = wcol->roundness * BLI_rcti_size_y(rect);
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
else if (but->type == UI_BTYPE_NUM) {
|
||||
/* Draw number buttons still with left/right
|
||||
* triangles when field is not embossed */
|
||||
widget_numbut_embossn(but, wcol, rect, state, roundboxalign);
|
||||
widget_numbut_embossn(but, wcol, rect, state, roundboxalign, zoom);
|
||||
}
|
||||
else if (but->type == UI_BTYPE_MENU) {
|
||||
/* Draw menu buttons still with down arrow. */
|
||||
|
@ -3936,7 +3987,8 @@ static void widget_icon_has_anim(
|
|||
}
|
||||
}
|
||||
|
||||
static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
static void widget_textbut(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
if (state & UI_SELECT) {
|
||||
SWAP(short, wcol->shadetop, wcol->shadedown);
|
||||
|
@ -3945,43 +3997,46 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun
|
|||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_preview_tile(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
static void widget_preview_tile(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int UNUSED(roundboxalign),
|
||||
const float UNUSED(zoom))
|
||||
{
|
||||
const uiStyle *style = UI_style_get();
|
||||
ui_draw_preview_item_stateless(
|
||||
&style->widget, rect, but->drawstr, but->icon, wcol->text, UI_STYLE_TEXT_CENTER);
|
||||
}
|
||||
|
||||
static void widget_menuiconbut(uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int roundboxalign)
|
||||
static void widget_menuiconbut(
|
||||
uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign, const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
/* decoration */
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
static void widget_pulldownbut(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
float back[4];
|
||||
UI_GetThemeColor4fv(TH_BACK, back);
|
||||
|
||||
if ((state & UI_ACTIVE) || (back[3] < 1.0f)) {
|
||||
uiWidgetBase wtb;
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
|
||||
if (state & UI_ACTIVE) {
|
||||
copy_v4_v4_uchar(wcol->inner, wcol->inner_sel);
|
||||
|
@ -4005,26 +4060,33 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int
|
|||
static void widget_menu_itembut(uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int UNUSED(roundboxalign))
|
||||
int UNUSED(roundboxalign),
|
||||
const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
/* Padding on the sides. */
|
||||
const float padding = 0.125f * BLI_rcti_size_y(rect);
|
||||
const float padding = zoom * 0.125f * U.widget_unit;
|
||||
rect->xmin += padding;
|
||||
rect->xmax -= padding;
|
||||
|
||||
/* No outline. */
|
||||
wtb.draw_outline = false;
|
||||
const float rad = wcol->roundness * BLI_rcti_size_y(rect);
|
||||
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_menu_radial_itembut(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign))
|
||||
static void widget_menu_radial_itembut(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int UNUSED(roundboxalign),
|
||||
const float zoom)
|
||||
{
|
||||
const float fac = but->block->pie_data.alphafac;
|
||||
|
||||
|
@ -4033,7 +4095,7 @@ static void widget_menu_radial_itembut(
|
|||
|
||||
wtb.draw_emboss = false;
|
||||
|
||||
const float rad = wcol->roundness * BLI_rcti_size_y(rect);
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
wcol->inner[3] *= fac;
|
||||
|
@ -4049,14 +4111,15 @@ static void widget_menu_radial_itembut(
|
|||
static void widget_list_itembut(uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int UNUSED(roundboxalign))
|
||||
int UNUSED(roundboxalign),
|
||||
const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
/* no outline */
|
||||
wtb.draw_outline = false;
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
@ -4065,7 +4128,8 @@ static void widget_list_itembut(uiWidgetColors *wcol,
|
|||
static void widget_optionbut(uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int state,
|
||||
int UNUSED(roundboxalign))
|
||||
int UNUSED(roundboxalign),
|
||||
const float UNUSED(zoom))
|
||||
{
|
||||
const bool text_before_widget = (state & UI_STATE_TEXT_BEFORE_WIDGET);
|
||||
rcti recttemp = *rect;
|
||||
|
@ -4088,7 +4152,7 @@ static void widget_optionbut(uiWidgetColors *wcol,
|
|||
/* Keep one edge in place. */
|
||||
BLI_rcti_translate(&recttemp, text_before_widget ? delta : -delta, 0);
|
||||
|
||||
const float rad = wcol->roundness * BLI_rcti_size_y(&recttemp);
|
||||
const float rad = widget_radius_from_rcti(&recttemp, wcol);
|
||||
round_box_edges(&wtb, UI_CNR_ALL, &recttemp, rad);
|
||||
|
||||
/* decoration */
|
||||
|
@ -4135,19 +4199,24 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag, eUIEmb
|
|||
}
|
||||
}
|
||||
|
||||
static void widget_radiobut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
||||
static void widget_radiobut(
|
||||
uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign, const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_box(
|
||||
uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
||||
static void widget_box(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
int UNUSED(state),
|
||||
int roundboxalign,
|
||||
const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
@ -4163,7 +4232,7 @@ static void widget_box(
|
|||
wcol->inner[3] = but->col[3];
|
||||
}
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
@ -4171,12 +4240,13 @@ static void widget_box(
|
|||
copy_v3_v3_uchar(wcol->inner, old_col);
|
||||
}
|
||||
|
||||
static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
|
||||
static void widget_but(
|
||||
uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign, const float zoom)
|
||||
{
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
|
@ -4197,10 +4267,9 @@ static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
|
|||
}
|
||||
#endif
|
||||
|
||||
static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
static void widget_roundbut_exec(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
|
||||
uiWidgetBase wtb;
|
||||
widget_init(&wtb);
|
||||
|
||||
|
@ -4209,15 +4278,18 @@ static void widget_roundbut_exec(uiWidgetColors *wcol, rcti *rect, int state, in
|
|||
shape_preset_init_hold_action(&wtb.tria1, rect, 0.75f, 'r');
|
||||
}
|
||||
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
|
||||
/* half rounded */
|
||||
round_box_edges(&wtb, roundboxalign, rect, rad);
|
||||
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_tab(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||
static void widget_tab(
|
||||
uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign, const float zoom)
|
||||
{
|
||||
const float rad = wcol->roundness * U.widget_unit;
|
||||
const float rad = widget_radius_from_zoom(zoom, wcol);
|
||||
const bool is_active = (state & UI_SELECT);
|
||||
|
||||
/* Draw shaded outline - Disabled for now,
|
||||
|
@ -4882,12 +4954,13 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
|
|||
}
|
||||
#endif
|
||||
|
||||
const float zoom = 1.0f / but->block->aspect;
|
||||
wt->state(wt, state, drawflag, but->emboss);
|
||||
if (wt->custom) {
|
||||
wt->custom(but, &wt->wcol, rect, state, roundboxalign);
|
||||
wt->custom(but, &wt->wcol, rect, state, roundboxalign, zoom);
|
||||
}
|
||||
else if (wt->draw) {
|
||||
wt->draw(&wt->wcol, rect, state, roundboxalign);
|
||||
wt->draw(&wt->wcol, rect, state, roundboxalign, zoom);
|
||||
}
|
||||
|
||||
if (wt->text) {
|
||||
|
@ -4930,10 +5003,11 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
|
|||
|
||||
wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
|
||||
if (block) {
|
||||
wt->draw(&wt->wcol, rect, block->flag, block->direction);
|
||||
const float zoom = 1.0f / block->aspect;
|
||||
wt->draw(&wt->wcol, rect, block->flag, block->direction, zoom);
|
||||
}
|
||||
else {
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
wt->draw(&wt->wcol, rect, 0, 0, 1.0f);
|
||||
}
|
||||
|
||||
ui_draw_clip_tri(block, rect, wt);
|
||||
|
@ -5027,8 +5101,9 @@ void ui_draw_popover_back(struct ARegion *region,
|
|||
wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
|
||||
}
|
||||
else {
|
||||
const float zoom = 1.0f / block->aspect;
|
||||
wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
wt->draw(&wt->wcol, rect, 0, 0, zoom);
|
||||
}
|
||||
|
||||
ui_draw_clip_tri(block, rect, wt);
|
||||
|
@ -5220,7 +5295,7 @@ static void ui_draw_widget_back_color(uiWidgetTypeEnum type,
|
|||
if (color) {
|
||||
rgba_float_to_uchar(wt->wcol.inner, color);
|
||||
}
|
||||
wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL);
|
||||
wt->draw(&wt->wcol, &rect_copy, 0, UI_CNR_ALL, 1.0f);
|
||||
}
|
||||
void ui_draw_widget_menu_back_color(const rcti *rect, bool use_shadow, const float color[4])
|
||||
{
|
||||
|
@ -5237,7 +5312,7 @@ void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(bl
|
|||
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
|
||||
wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
|
||||
/* wt->draw ends up using same function to draw the tooltip as menu_back */
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
wt->draw(&wt->wcol, rect, 0, 0, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5265,7 +5340,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
|
|||
char *cpoin = NULL;
|
||||
|
||||
wt->state(wt, state, 0, UI_EMBOSS_UNDEFINED);
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
wt->draw(&wt->wcol, rect, 0, 0, 1.0f);
|
||||
|
||||
UI_fontstyle_set(fstyle);
|
||||
|
||||
|
@ -5455,7 +5530,7 @@ void ui_draw_preview_item(const uiFontStyle *fstyle,
|
|||
|
||||
/* drawing button background */
|
||||
wt->state(wt, state, 0, UI_EMBOSS_UNDEFINED);
|
||||
wt->draw(&wt->wcol, rect, 0, 0);
|
||||
wt->draw(&wt->wcol, rect, 0, 0, 1.0f);
|
||||
|
||||
ui_draw_preview_item_stateless(fstyle, rect, name, iconid, wt->wcol.text, text_align);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue