Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.cc
- This file was moved from source/blender/editors/interface/interface_widgets.c.
| Context not available. | |||||
| * \ingroup edinterface | * \ingroup edinterface | ||||
| */ | */ | ||||
| #include <limits.h> | #include <climits> | ||||
| #include <stdlib.h> | #include <cstdlib> | ||||
| #include <string.h> | #include <cstring> | ||||
| #include "DNA_brush_types.h" | #include "DNA_brush_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| Context not available. | |||||
| /* visual types for drawing */ | /* visual types for drawing */ | ||||
| /* for time being separated from functional types */ | /* for time being separated from functional types */ | ||||
| typedef enum { | enum uiWidgetTypeEnum { | ||||
| /* default */ | /* default */ | ||||
| UI_WTYPE_REGULAR, | UI_WTYPE_REGULAR, | ||||
| Context not available. | |||||
| UI_WTYPE_PROGRESSBAR, | UI_WTYPE_PROGRESSBAR, | ||||
| UI_WTYPE_NODESOCKET, | UI_WTYPE_NODESOCKET, | ||||
| UI_WTYPE_VIEW_ITEM, | UI_WTYPE_VIEW_ITEM, | ||||
| } uiWidgetTypeEnum; | }; | ||||
| /** | /** | ||||
| * The button's state information adapted for drawing. Use #STATE_INFO_NULL for empty state. | * The button's state information adapted for drawing. Use #STATE_INFO_NULL for empty state. | ||||
| */ | */ | ||||
| typedef struct { | struct uiWidgetStateInfo { | ||||
| /** Copy of #uiBut.flag (possibly with overrides for drawing). */ | /** Copy of #uiBut.flag (possibly with overrides for drawing). */ | ||||
| int but_flag; | int but_flag; | ||||
| /** Copy of #uiBut.drawflag (possibly with overrides for drawing). */ | /** Copy of #uiBut.drawflag (possibly with overrides for drawing). */ | ||||
| Context not available. | |||||
| bool has_hold_action : 1; | bool has_hold_action : 1; | ||||
| /** The button is in text input mode. */ | /** The button is in text input mode. */ | ||||
| bool is_text_input : 1; | bool is_text_input : 1; | ||||
| } uiWidgetStateInfo; | }; | ||||
| static const uiWidgetStateInfo STATE_INFO_NULL = {0}; | static const uiWidgetStateInfo STATE_INFO_NULL = {0}; | ||||
| Context not available. | |||||
| /* fill this struct with polygon info to draw AA'ed */ | /* fill this struct with polygon info to draw AA'ed */ | ||||
| /* it has outline, back, and two optional tria meshes */ | /* it has outline, back, and two optional tria meshes */ | ||||
| typedef struct uiWidgetTrias { | struct uiWidgetTrias { | ||||
| uint tot; | uint tot; | ||||
| int type; | int type; | ||||
| float size, center[2]; | float size, center[2]; | ||||
| float vec[16][2]; | float vec[16][2]; | ||||
| const uint (*index)[3]; | const uint (*index)[3]; | ||||
| }; | |||||
| } uiWidgetTrias; | |||||
| /* max as used by round_box__edges */ | /* max as used by round_box__edges */ | ||||
| /* Make sure to change widget_base_vert.glsl accordingly. */ | /* Make sure to change widget_base_vert.glsl accordingly. */ | ||||
| #define WIDGET_CURVE_RESOLU 9 | #define WIDGET_CURVE_RESOLU 9 | ||||
| #define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4) | #define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4) | ||||
| typedef struct uiWidgetBase { | struct uiWidgetBase { | ||||
| /* TODO: remove these completely. */ | /* TODO: remove these completely. */ | ||||
| int totvert, halfwayvert; | int totvert, halfwayvert; | ||||
| float outer_v[WIDGET_SIZE_MAX][2]; | float outer_v[WIDGET_SIZE_MAX][2]; | ||||
| Context not available. | |||||
| /* Widget shader parameters, must match the shader layout. */ | /* Widget shader parameters, must match the shader layout. */ | ||||
| uiWidgetBaseParameters uniform_params; | uiWidgetBaseParameters uniform_params; | ||||
| } uiWidgetBase; | }; | ||||
| /** | /** | ||||
| * For time being only for visual appearance, | * For time being only for visual appearance, | ||||
| * later, a handling callback can be added too. | * later, a handling callback can be added too. | ||||
| */ | */ | ||||
| typedef struct uiWidgetType { | struct uiWidgetType { | ||||
| /* pointer to theme color definition */ | /* pointer to theme color definition */ | ||||
| const uiWidgetColors *wcol_theme; | const uiWidgetColors *wcol_theme; | ||||
| Context not available. | |||||
| void (*draw_block)( | void (*draw_block)( | ||||
| uiWidgetColors *, rcti *, int block_flag, int roundboxalign, const float zoom); | uiWidgetColors *, rcti *, int block_flag, int roundboxalign, const float zoom); | ||||
| void (*text)(const uiFontStyle *, const uiWidgetColors *, uiBut *, rcti *); | void (*text)(const uiFontStyle *, const uiWidgetColors *, uiBut *, rcti *); | ||||
| }; | |||||
| } uiWidgetType; | |||||
| /** \} */ | /** \} */ | ||||
| Context not available. | |||||
| static void set_roundbox_vertex_data(GPUVertBufRaw *vflag_step, uint32_t d) | static void set_roundbox_vertex_data(GPUVertBufRaw *vflag_step, uint32_t d) | ||||
| { | { | ||||
| uint32_t *data = GPU_vertbuf_raw_step(vflag_step); | uint32_t *data = static_cast<uint32_t *>(GPU_vertbuf_raw_step(vflag_step)); | ||||
| *data = d; | *data = d; | ||||
| } | } | ||||
| Context not available. | |||||
| bool emboss, | bool emboss, | ||||
| int color) | int color) | ||||
| { | { | ||||
| uint32_t *data = GPU_vertbuf_raw_step(vflag_step); | uint32_t *data = static_cast<uint32_t *>(GPU_vertbuf_raw_step(vflag_step)); | ||||
| *data = corner_id; | *data = corner_id; | ||||
| *data |= corner_v << 2; | *data |= corner_v << 2; | ||||
| *data |= jit_v << 6; | *data |= jit_v << 6; | ||||
| Context not available. | |||||
| GPUBatch *ui_batch_roundbox_widget_get(void) | GPUBatch *ui_batch_roundbox_widget_get(void) | ||||
| { | { | ||||
| if (g_ui_batch_cache.roundbox_widget == NULL) { | if (g_ui_batch_cache.roundbox_widget == nullptr) { | ||||
| GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); | GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); | ||||
| GPU_vertbuf_data_alloc(vbo, 12); | GPU_vertbuf_data_alloc(vbo, 12); | ||||
| Context not available. | |||||
| GPUBatch *ui_batch_roundbox_shadow_get(void) | GPUBatch *ui_batch_roundbox_shadow_get(void) | ||||
| { | { | ||||
| if (g_ui_batch_cache.roundbox_shadow == NULL) { | if (g_ui_batch_cache.roundbox_shadow == nullptr) { | ||||
| uint32_t last_data; | uint32_t last_data; | ||||
| GPUVertBufRaw vflag_step; | GPUVertBufRaw vflag_step; | ||||
| GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); | GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex( | g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex( | ||||
| GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); | GPU_PRIM_TRI_STRIP, vbo, nullptr, GPU_BATCH_OWNS_VBO); | ||||
| gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow); | gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow); | ||||
| } | } | ||||
| return g_ui_batch_cache.roundbox_shadow; | return g_ui_batch_cache.roundbox_shadow; | ||||
| Context not available. | |||||
| static void widget_draw_vertex_buffer(uint pos, | static void widget_draw_vertex_buffer(uint pos, | ||||
| uint col, | uint col, | ||||
| int mode, | GPUPrimType mode, | ||||
| const float quads_pos[WIDGET_SIZE_MAX][2], | const float quads_pos[WIDGET_SIZE_MAX][2], | ||||
| const uchar quads_col[WIDGET_SIZE_MAX][4], | const uchar quads_col[WIDGET_SIZE_MAX][4], | ||||
| uint totvert) | uint totvert) | ||||
| Context not available. | |||||
| widget_verts_to_triangle_strip(wtb, wtb->totvert, triangle_strip); | widget_verts_to_triangle_strip(wtb, wtb->totvert, triangle_strip); | ||||
| widget_draw_vertex_buffer( | widget_draw_vertex_buffer( | ||||
| pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, NULL, wtb->totvert * 2 + 2); | pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, nullptr, wtb->totvert * 2 + 2); | ||||
| } | } | ||||
| static void widgetbase_set_uniform_alpha_discard(uiWidgetBase *wtb, | static void widgetbase_set_uniform_alpha_discard(uiWidgetBase *wtb, | ||||
| Context not available. | |||||
| BLI_assert(str[0]); | BLI_assert(str[0]); | ||||
| /* How many BYTES (not characters) of this utf-8 string can fit, along with appended ellipsis. */ | /* How many BYTES (not characters) of this utf-8 string can fit, along with appended ellipsis. */ | ||||
| int l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, NULL); | int l_end = BLF_width_to_strlen( | ||||
| fstyle->uifont_id, str, max_len, okwidth - sep_strwidth, nullptr); | |||||
| if (l_end > 0) { | if (l_end > 0) { | ||||
| /* At least one character, so clip and add the ellipsis. */ | /* At least one character, so clip and add the ellipsis. */ | ||||
| Context not available. | |||||
| } | } | ||||
| else { | else { | ||||
| /* Otherwise fit as much as we can without adding an ellipsis. */ | /* Otherwise fit as much as we can without adding an ellipsis. */ | ||||
| l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, NULL); | l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, okwidth, nullptr); | ||||
| str[l_end] = '\0'; | str[l_end] = '\0'; | ||||
| if (r_final_len) { | if (r_final_len) { | ||||
| *r_final_len = (size_t)l_end; | *r_final_len = (size_t)l_end; | ||||
| Context not available. | |||||
| const int sep_len = sizeof(sep) - 1; | const int sep_len = sizeof(sep) - 1; | ||||
| const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1); | const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1); | ||||
| char *rpart = NULL, rpart_buf[UI_MAX_DRAW_STR]; | char *rpart = nullptr, rpart_buf[UI_MAX_DRAW_STR]; | ||||
| float rpart_width = 0.0f; | float rpart_width = 0.0f; | ||||
| size_t rpart_len = 0; | size_t rpart_len = 0; | ||||
| size_t final_lpart_len; | size_t final_lpart_len; | ||||
| Context not available. | |||||
| /* Not enough place for actual label, just display protected right part. | /* Not enough place for actual label, just display protected right part. | ||||
| * Here just for safety, should never happen in real life! */ | * Here just for safety, should never happen in real life! */ | ||||
| memmove(str, rpart, rpart_len + 1); | memmove(str, rpart, rpart_len + 1); | ||||
| rpart = NULL; | rpart = nullptr; | ||||
| okwidth += rpart_width; | okwidth += rpart_width; | ||||
| strwidth = rpart_width; | strwidth = rpart_width; | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| const size_t l_end = BLF_width_to_strlen( | const size_t l_end = BLF_width_to_strlen( | ||||
| fstyle->uifont_id, str, max_len, parts_strwidth, NULL); | fstyle->uifont_id, str, max_len, parts_strwidth, nullptr); | ||||
| if (l_end < 10 || min_ff(parts_strwidth, strwidth - okwidth) < minwidth) { | if (l_end < 10 || min_ff(parts_strwidth, strwidth - okwidth) < minwidth) { | ||||
| /* If we really have no place, or we would clip a very small piece of string in the middle, | /* If we really have no place, or we would clip a very small piece of string in the middle, | ||||
| * only show start of string. | * only show start of string. | ||||
| Context not available. | |||||
| else { | else { | ||||
| size_t r_offset, r_len; | size_t r_offset, r_len; | ||||
| r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, NULL); | r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, nullptr); | ||||
| r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */ | r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */ | ||||
| if (l_end + sep_len + r_len + rpart_len > max_len) { | if (l_end + sep_len + r_len + rpart_len > max_len) { | ||||
| Context not available. | |||||
| { | { | ||||
| int drawstr_left_len = UI_MAX_DRAW_STR; | int drawstr_left_len = UI_MAX_DRAW_STR; | ||||
| const char *drawstr = but->drawstr; | const char *drawstr = but->drawstr; | ||||
| const char *drawstr_right = NULL; | const char *drawstr_right = nullptr; | ||||
| bool use_right_only = false; | bool use_right_only = false; | ||||
| #ifdef WITH_INPUT_IME | #ifdef WITH_INPUT_IME | ||||
| Context not available. | |||||
| else { | else { | ||||
| if (but->editstr) { | if (but->editstr) { | ||||
| /* max length isn't used in this case, | /* max length isn't used in this case, | ||||
| * we rely on string being NULL terminated. */ | * we rely on string being nullptr terminated. */ | ||||
| drawstr_left_len = INT_MAX; | drawstr_left_len = INT_MAX; | ||||
| #ifdef WITH_INPUT_IME | #ifdef WITH_INPUT_IME | ||||
| Context not available. | |||||
| bool use_drawstr_right_as_hint = false; | bool use_drawstr_right_as_hint = false; | ||||
| /* cut string in 2 parts - only for menu entries */ | /* cut string in 2 parts - only for menu entries */ | ||||
| if (but->flag & UI_BUT_HAS_SEP_CHAR && (but->editstr == NULL)) { | if (but->flag & UI_BUT_HAS_SEP_CHAR && (but->editstr == nullptr)) { | ||||
| drawstr_right = strrchr(drawstr, UI_SEP_CHAR); | drawstr_right = strrchr(drawstr, UI_SEP_CHAR); | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| use_drawstr_right_as_hint = true; | use_drawstr_right_as_hint = true; | ||||
| Context not available. | |||||
| if (!drawstr_right && (but->drawflag & UI_BUT_TEXT_LEFT) && | if (!drawstr_right && (but->drawflag & UI_BUT_TEXT_LEFT) && | ||||
| ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && | ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && | ||||
| /* if we're editing or multi-drag (fake editing), then use left alignment */ | /* if we're editing or multi-drag (fake editing), then use left alignment */ | ||||
| (but->editstr == NULL) && (drawstr == but->drawstr)) { | (but->editstr == nullptr) && (drawstr == but->drawstr)) { | ||||
| drawstr_right = strrchr(drawstr + but->ofs, ':'); | drawstr_right = strrchr(drawstr + but->ofs, ':'); | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| drawstr_right++; | drawstr_right++; | ||||
| Context not available. | |||||
| (drawstr_left_len - but->ofs); | (drawstr_left_len - but->ofs); | ||||
| if (drawlen > 0) { | if (drawlen > 0) { | ||||
| uiFontStyleDraw_Params params{}; | |||||
| params.align = align; | |||||
| UI_fontstyle_draw_ex(fstyle, | UI_fontstyle_draw_ex(fstyle, | ||||
| rect, | rect, | ||||
| drawstr + but->ofs, | drawstr + but->ofs, | ||||
| drawlen, | drawlen, | ||||
| wcol->text, | wcol->text, | ||||
| &(struct uiFontStyleDraw_Params){ | ¶ms, | ||||
| .align = align, | |||||
| }, | |||||
| &font_xofs, | &font_xofs, | ||||
| &font_yofs, | &font_yofs, | ||||
| NULL); | nullptr); | ||||
| if (but->menu_key != '\0') { | if (but->menu_key != '\0') { | ||||
| const char *drawstr_ofs = drawstr + but->ofs; | const char *drawstr_ofs = drawstr + but->ofs; | ||||
| Context not available. | |||||
| const char keys[] = {but->menu_key - 32, but->menu_key}; | const char keys[] = {but->menu_key - 32, but->menu_key}; | ||||
| for (int i = 0; i < ARRAY_SIZE(keys); i++) { | for (int i = 0; i < ARRAY_SIZE(keys); i++) { | ||||
| const char *drawstr_menu = strchr(drawstr_ofs, keys[i]); | const char *drawstr_menu = strchr(drawstr_ofs, keys[i]); | ||||
| if (drawstr_menu != NULL && drawstr_menu < drawstr_end) { | if (drawstr_menu != nullptr && drawstr_menu < drawstr_end) { | ||||
| ul_index = (int)(drawstr_menu - drawstr_ofs); | ul_index = (int)(drawstr_menu - drawstr_ofs); | ||||
| break; | break; | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| rect->xmax -= UI_TEXT_CLIP_MARGIN; | rect->xmax -= UI_TEXT_CLIP_MARGIN; | ||||
| UI_fontstyle_draw(fstyle, | uiFontStyleDraw_Params params{}; | ||||
| rect, | params.align = UI_STYLE_TEXT_RIGHT; | ||||
| drawstr_right, | UI_fontstyle_draw(fstyle, rect, drawstr_right, UI_MAX_DRAW_STR, col, ¶ms); | ||||
| UI_MAX_DRAW_STR, | |||||
| col, | |||||
| &(struct uiFontStyleDraw_Params){ | |||||
| .align = UI_STYLE_TEXT_RIGHT, | |||||
| }); | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| UI_widgetbase_draw_cache_flush(); | UI_widgetbase_draw_cache_flush(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| ED_node_socket_draw(but->custom_data, rect, col, scale); | ED_node_socket_draw(static_cast<bNodeSocket *>(but->custom_data), rect, col, scale); | ||||
| } | } | ||||
| else { | else { | ||||
| widget_draw_icon(but, ICON_LAYER_USED, alpha, rect, wcol->text); | widget_draw_icon(but, ICON_LAYER_USED, alpha, rect, wcol->text); | ||||
| Context not available. | |||||
| /* Big previews with optional text label below */ | /* Big previews with optional text label below */ | ||||
| if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { | if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { | ||||
| const BIFIconID icon = ui_but_icon(but); | const BIFIconID icon = BIFIconID(ui_but_icon(but)); | ||||
| int icon_size = BLI_rcti_size_y(rect); | int icon_size = BLI_rcti_size_y(rect); | ||||
| int text_size = 0; | int text_size = 0; | ||||
| Context not available. | |||||
| } | } | ||||
| #endif | #endif | ||||
| const BIFIconID icon = ui_but_icon(but); | const BIFIconID icon = BIFIconID(ui_but_icon(but)); | ||||
| const int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT; | const int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT; | ||||
| const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac); | const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac); | ||||
| const float icon_padding = 2 * UI_DPI_FAC; | const float icon_padding = 2 * UI_DPI_FAC; | ||||
| Context not available. | |||||
| rect->xmin += text_padding; | rect->xmin += text_padding; | ||||
| } | } | ||||
| else if (but->flag & UI_BUT_DRAG_MULTI) { | else if (but->flag & UI_BUT_DRAG_MULTI) { | ||||
| const bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL; | const bool text_is_edited = ui_but_drag_multi_edit_get(but) != nullptr; | ||||
| if (text_is_edited || (but->drawflag & UI_BUT_TEXT_LEFT)) { | if (text_is_edited || (but->drawflag & UI_BUT_TEXT_LEFT)) { | ||||
| rect->xmin += text_padding; | rect->xmin += text_padding; | ||||
| } | } | ||||
| Context not available. | |||||
| { | { | ||||
| /* Explicitly require #UI_EMBOSS_NONE_OR_STATUS for color blending with no emboss. */ | /* Explicitly require #UI_EMBOSS_NONE_OR_STATUS for color blending with no emboss. */ | ||||
| if (emboss == UI_EMBOSS_NONE) { | if (emboss == UI_EMBOSS_NONE) { | ||||
| return NULL; | return nullptr; | ||||
| } | } | ||||
| if (state->but_drawflag & UI_BUT_ANIMATED_CHANGED) { | if (state->but_drawflag & UI_BUT_ANIMATED_CHANGED) { | ||||
| Context not available. | |||||
| if (state->but_flag & UI_BUT_OVERRIDDEN) { | if (state->but_flag & UI_BUT_OVERRIDDEN) { | ||||
| return wcol_state->inner_overridden_sel; | return wcol_state->inner_overridden_sel; | ||||
| } | } | ||||
| return NULL; | return nullptr; | ||||
| } | } | ||||
| /* copy colors from theme, and set changes in it based on state */ | /* copy colors from theme, and set changes in it based on state */ | ||||
| Context not available. | |||||
| if (state->but_flag & UI_SELECT) { | if (state->but_flag & UI_SELECT) { | ||||
| copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); | copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); | ||||
| if (color_blend != NULL) { | if (color_blend != nullptr) { | ||||
| color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend); | color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend); | ||||
| } | } | ||||
| Context not available. | |||||
| copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); | copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); | ||||
| copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_sel); | copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_sel); | ||||
| } | } | ||||
| if (color_blend != NULL) { | if (color_blend != nullptr) { | ||||
| color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend); | color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend); | ||||
| } | } | ||||
| Context not available. | |||||
| widget_state(wt, state, emboss); | widget_state(wt, state, emboss); | ||||
| const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, emboss); | const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, emboss); | ||||
| if (color_blend != NULL) { | if (color_blend != nullptr) { | ||||
| /* Set the slider 'item' so that it reflects state settings too. | /* Set the slider 'item' so that it reflects state settings too. | ||||
| * De-saturate so the color of the slider doesn't conflict with the blend color, | * De-saturate so the color of the slider doesn't conflict with the blend color, | ||||
| * which can make the color hard to see when the slider is set to full (see T66102). */ | * which can make the color hard to see when the slider is set to full (see T66102). */ | ||||
| Context not available. | |||||
| } | } | ||||
| static void widget_state_nothing(uiWidgetType *wt, | static void widget_state_nothing(uiWidgetType *wt, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| eUIEmbossType UNUSED(emboss)) | eUIEmbossType /*emboss*/) | ||||
| { | { | ||||
| wt->wcol = *(wt->wcol_theme); | wt->wcol = *(wt->wcol_theme); | ||||
| } | } | ||||
| /* special case, button that calls pulldown */ | /* special case, button that calls pulldown */ | ||||
| static void widget_state_pulldown(uiWidgetType *wt, | static void widget_state_pulldown(uiWidgetType *wt, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| eUIEmbossType UNUSED(emboss)) | eUIEmbossType /*emboss*/) | ||||
| { | { | ||||
| wt->wcol = *(wt->wcol_theme); | wt->wcol = *(wt->wcol_theme); | ||||
| } | } | ||||
| Context not available. | |||||
| /* special case, pie menu items */ | /* special case, pie menu items */ | ||||
| static void widget_state_pie_menu_item(uiWidgetType *wt, | static void widget_state_pie_menu_item(uiWidgetType *wt, | ||||
| const uiWidgetStateInfo *state, | const uiWidgetStateInfo *state, | ||||
| eUIEmbossType UNUSED(emboss)) | eUIEmbossType /*emboss*/) | ||||
| { | { | ||||
| wt->wcol = *(wt->wcol_theme); | wt->wcol = *(wt->wcol_theme); | ||||
| Context not available. | |||||
| /* special case, menu items */ | /* special case, menu items */ | ||||
| static void widget_state_menu_item(uiWidgetType *wt, | static void widget_state_menu_item(uiWidgetType *wt, | ||||
| const uiWidgetStateInfo *state, | const uiWidgetStateInfo *state, | ||||
| eUIEmbossType UNUSED(emboss)) | eUIEmbossType /*emboss*/) | ||||
| { | { | ||||
| wt->wcol = *(wt->wcol_theme); | wt->wcol = *(wt->wcol_theme); | ||||
| Context not available. | |||||
| widget_verts_to_triangle_strip(&wtb, totvert, triangle_strip); | widget_verts_to_triangle_strip(&wtb, totvert, triangle_strip); | ||||
| widget_draw_vertex_buffer(pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, NULL, totvert * 2); | widget_draw_vertex_buffer(pos, 0, GPU_PRIM_TRI_STRIP, triangle_strip, nullptr, totvert * 2); | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| Context not available. | |||||
| const float centy = BLI_rcti_cent_y_fl(rect); | const float centy = BLI_rcti_cent_y_fl(rect); | ||||
| const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; | const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; | ||||
| ColorPicker *cpicker = but->custom_data; | ColorPicker *cpicker = static_cast<ColorPicker *>(but->custom_data); | ||||
| float rgb[3], hsv[3], rgb_center[3]; | float rgb[3], hsv[3], rgb_center[3]; | ||||
| const bool is_color_gamma = ui_but_is_color_gamma(but); | const bool is_color_gamma = ui_but_is_color_gamma(but); | ||||
| Context not available. | |||||
| const uiButHSVCube *hsv_but = (uiButHSVCube *)but; | const uiButHSVCube *hsv_but = (uiButHSVCube *)but; | ||||
| float rgb[3]; | float rgb[3]; | ||||
| float x = 0.0f, y = 0.0f; | float x = 0.0f, y = 0.0f; | ||||
| ColorPicker *cpicker = but->custom_data; | ColorPicker *cpicker = static_cast<ColorPicker *>(but->custom_data); | ||||
| float *hsv = cpicker->hsv_perceptual; | float *hsv = cpicker->hsv_perceptual; | ||||
| float hsv_n[3]; | float hsv_n[3]; | ||||
| Context not available. | |||||
| round_box_edges(&wtb, UI_CNR_ALL, rect, rad); | round_box_edges(&wtb, UI_CNR_ALL, rect, rad); | ||||
| /* setup temp colors */ | /* setup temp colors */ | ||||
| widgetbase_draw(&wtb, | uiWidgetColors colors{}; | ||||
| &((uiWidgetColors){ | colors.outline[0] = 0; | ||||
| .outline = {0, 0, 0, 255}, | colors.outline[1] = 0; | ||||
| .inner = {128, 128, 128, 255}, | colors.outline[2] = 0; | ||||
| .shadetop = 127, | colors.outline[3] = 255; | ||||
| .shadedown = -128, | colors.inner[0] = 128; | ||||
| .shaded = 1, | colors.inner[1] = 128; | ||||
| })); | colors.inner[2] = 128; | ||||
| colors.inner[3] = 255; | |||||
| colors.shadetop = 127; | |||||
| colors.shadedown = -128; | |||||
| colors.shaded = 1; | |||||
| widgetbase_draw(&wtb, &colors); | |||||
| /* We are drawing on top of widget bases. Flush cache. */ | /* We are drawing on top of widget bases. Flush cache. */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| Context not available. | |||||
| static void widget_menubut(uiWidgetColors *wcol, | static void widget_menubut(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int roundboxalign, | int roundboxalign, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| Context not available. | |||||
| /** | /** | ||||
| * Draw menu buttons still with triangles when field is not embossed | * Draw menu buttons still with triangles when field is not embossed | ||||
| */ | */ | ||||
| static void widget_menubut_embossn(const uiBut *UNUSED(but), | static void widget_menubut_embossn(const uiBut * /*but*/, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign)) | int /*roundboxalign*/) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| Context not available. | |||||
| /** | /** | ||||
| * Draw number buttons still with triangles when field is not embossed | * Draw number buttons still with triangles when field is not embossed | ||||
| */ | */ | ||||
| static void widget_numbut_embossn(const uiBut *UNUSED(but), | static void widget_numbut_embossn(const uiBut * /*but*/, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *state, | const uiWidgetStateInfo *state, | ||||
| Context not available. | |||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *state, | const uiWidgetStateInfo *state, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float UNUSED(zoom)) | const float /*zoom*/) | ||||
| { | { | ||||
| /* calculate slider part */ | /* calculate slider part */ | ||||
| const float value = (float)ui_but_value_get(but); | const float value = (float)ui_but_value_get(but); | ||||
| Context not available. | |||||
| static void widget_progressbar(uiBut *but, | static void widget_progressbar(uiBut *but, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int roundboxalign, | int roundboxalign, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| Context not available. | |||||
| static void widget_view_item(uiWidgetColors *wcol, | static void widget_view_item(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *state, | const uiWidgetStateInfo *state, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| Context not available. | |||||
| static void widget_nodesocket(uiBut *but, | static void widget_nodesocket(uiBut *but, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float UNUSED(zoom)) | const float /*zoom*/) | ||||
| { | { | ||||
| const int radi = 0.25f * BLI_rcti_size_y(rect); | const int radi = 0.25f * BLI_rcti_size_y(rect); | ||||
| Context not available. | |||||
| static void widget_unitvec(uiBut *but, | static void widget_unitvec(uiBut *but, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| const float rad = widget_radius_from_zoom(zoom, wcol); | const float rad = widget_radius_from_zoom(zoom, wcol); | ||||
| Context not available. | |||||
| static void widget_preview_tile(uiBut *but, | static void widget_preview_tile(uiBut *but, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float UNUSED(zoom)) | const float /*zoom*/) | ||||
| { | { | ||||
| const uiStyle *style = UI_style_get(); | const uiStyle *style = UI_style_get(); | ||||
| ui_draw_preview_item_stateless( | ui_draw_preview_item_stateless( | ||||
| Context not available. | |||||
| static void widget_menuiconbut(uiWidgetColors *wcol, | static void widget_menuiconbut(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int roundboxalign, | int roundboxalign, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| Context not available. | |||||
| static void widget_menu_itembut(uiWidgetColors *wcol, | static void widget_menu_itembut(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| Context not available. | |||||
| static void widget_menu_itembut_unpadded(uiWidgetColors *wcol, | static void widget_menu_itembut_unpadded(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| /* This function is used for menu items placed close to each other horizontally, e.g. the matcap | /* This function is used for menu items placed close to each other horizontally, e.g. the matcap | ||||
| Context not available. | |||||
| static void widget_menu_radial_itembut(uiBut *but, | static void widget_menu_radial_itembut(uiBut *but, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| const float fac = but->block->pie_data.alphafac; | const float fac = but->block->pie_data.alphafac; | ||||
| Context not available. | |||||
| static void widget_list_itembut(uiWidgetColors *wcol, | static void widget_list_itembut(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| Context not available. | |||||
| static void widget_optionbut(uiWidgetColors *wcol, | static void widget_optionbut(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *state, | const uiWidgetStateInfo *state, | ||||
| int UNUSED(roundboxalign), | int /*roundboxalign*/, | ||||
| const float UNUSED(zoom)) | const float /*zoom*/) | ||||
| { | { | ||||
| /* For a right aligned layout (signified by #UI_BUT_TEXT_RIGHT), draw the text on the left of the | /* For a right aligned layout (signified by #UI_BUT_TEXT_RIGHT), draw the text on the left of the | ||||
| * checkbox. */ | * checkbox. */ | ||||
| Context not available. | |||||
| static void widget_radiobut(uiWidgetColors *wcol, | static void widget_radiobut(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int roundboxalign, | int roundboxalign, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| Context not available. | |||||
| static void widget_box(uiBut *but, | static void widget_box(uiBut *but, | ||||
| uiWidgetColors *wcol, | uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int roundboxalign, | int roundboxalign, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| Context not available. | |||||
| copy_v3_v3_uchar(old_col, wcol->inner); | copy_v3_v3_uchar(old_col, wcol->inner); | ||||
| /* abuse but->hsv - if it's non-zero, use this color as the box's background */ | /* abuse but->hsv - if it's non-zero, use this color as the box's background */ | ||||
| if (but != NULL && but->col[3]) { | if (but != nullptr && but->col[3]) { | ||||
| wcol->inner[0] = but->col[0]; | wcol->inner[0] = but->col[0]; | ||||
| wcol->inner[1] = but->col[1]; | wcol->inner[1] = but->col[1]; | ||||
| wcol->inner[2] = but->col[2]; | wcol->inner[2] = but->col[2]; | ||||
| Context not available. | |||||
| static void widget_but(uiWidgetColors *wcol, | static void widget_but(uiWidgetColors *wcol, | ||||
| rcti *rect, | rcti *rect, | ||||
| const uiWidgetStateInfo *UNUSED(state), | const uiWidgetStateInfo * /*state*/, | ||||
| int roundboxalign, | int roundboxalign, | ||||
| const float zoom) | const float zoom) | ||||
| { | { | ||||
| Context not available. | |||||
| } | } | ||||
| #if 0 | #if 0 | ||||
| static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) | static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int /*state*/ int roundboxalign) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| const float rad = wcol->roundness * U.widget_unit; | const float rad = wcol->roundness * U.widget_unit; | ||||
| Context not available. | |||||
| wt.wcol_state = &btheme->tui.wcol_state; | wt.wcol_state = &btheme->tui.wcol_state; | ||||
| wt.state = widget_state; | wt.state = widget_state; | ||||
| wt.draw = widget_but; | wt.draw = widget_but; | ||||
| wt.custom = NULL; | wt.custom = nullptr; | ||||
| wt.text = widget_draw_text_icon; | wt.text = widget_draw_text_icon; | ||||
| switch (type) { | switch (type) { | ||||
| Context not available. | |||||
| break; | break; | ||||
| case UI_WTYPE_LABEL: | case UI_WTYPE_LABEL: | ||||
| wt.draw = NULL; | wt.draw = nullptr; | ||||
| wt.state = widget_state_label; | wt.state = widget_state_label; | ||||
| break; | break; | ||||
| Context not available. | |||||
| break; | break; | ||||
| case UI_WTYPE_PREVIEW_TILE: | case UI_WTYPE_PREVIEW_TILE: | ||||
| wt.draw = NULL; | wt.draw = nullptr; | ||||
| /* Drawn via the `custom` callback. */ | /* Drawn via the `custom` callback. */ | ||||
| wt.text = NULL; | wt.text = nullptr; | ||||
| wt.custom = widget_preview_tile; | wt.custom = widget_preview_tile; | ||||
| break; | break; | ||||
| Context not available. | |||||
| /** \name Public API | /** \name Public API | ||||
| * \{ */ | * \{ */ | ||||
| void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBut *but, rcti *rect) | void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but, rcti *rect) | ||||
| { | { | ||||
| bTheme *btheme = UI_GetTheme(); | bTheme *btheme = UI_GetTheme(); | ||||
| const ThemeUI *tui = &btheme->tui; | const ThemeUI *tui = &btheme->tui; | ||||
| const uiFontStyle *fstyle = &style->widget; | const uiFontStyle *fstyle = &style->widget; | ||||
| uiWidgetType *wt = NULL; | uiWidgetType *wt = nullptr; | ||||
| /* handle menus separately */ | /* handle menus separately */ | ||||
| if (but->emboss == UI_EMBOSS_PULLDOWN) { | if (but->emboss == UI_EMBOSS_PULLDOWN) { | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| if (wt == NULL) { | if (wt == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) | void ui_draw_menu_back(uiStyle * /*style*/, uiBlock *block, rcti *rect) | ||||
| { | { | ||||
| uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); | uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); | ||||
| Context not available. | |||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| } | } | ||||
| void ui_draw_popover_back(struct ARegion *region, | void ui_draw_popover_back(ARegion *region, uiStyle * /*style*/, uiBlock *block, rcti *rect) | ||||
| uiStyle *UNUSED(style), | |||||
| uiBlock *block, | |||||
| rcti *rect) | |||||
| { | { | ||||
| uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); | uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); | ||||
| Context not available. | |||||
| pie_radius_external, | pie_radius_external, | ||||
| subd, | subd, | ||||
| btheme->tui.wcol_pie_menu.inner, | btheme->tui.wcol_pie_menu.inner, | ||||
| NULL, | nullptr, | ||||
| false); | false); | ||||
| } | } | ||||
| Context not available. | |||||
| pie_radius_external, | pie_radius_external, | ||||
| subd, | subd, | ||||
| btheme->tui.wcol_pie_menu.inner_sel, | btheme->tui.wcol_pie_menu.inner_sel, | ||||
| NULL, | nullptr, | ||||
| false); | false); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| pie_confirm_external, | pie_confirm_external, | ||||
| subd, | subd, | ||||
| col, | col, | ||||
| NULL, | nullptr, | ||||
| false); | false); | ||||
| } | } | ||||
| Context not available. | |||||
| void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow) | void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow) | ||||
| { | { | ||||
| ui_draw_widget_back_color(UI_WTYPE_MENU_BACK, use_shadow, rect, NULL); | ui_draw_widget_back_color(UI_WTYPE_MENU_BACK, use_shadow, rect, nullptr); | ||||
| } | } | ||||
| void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect) | void ui_draw_tooltip_background(const uiStyle * /*style*/, uiBlock * /*block*/, rcti *rect) | ||||
| { | { | ||||
| uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP); | uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP); | ||||
| wt->state(wt, &STATE_INFO_NULL, UI_EMBOSS_UNDEFINED); | wt->state(wt, &STATE_INFO_NULL, UI_EMBOSS_UNDEFINED); | ||||
| Context not available. | |||||
| const int row_height = BLI_rcti_size_y(rect); | const int row_height = BLI_rcti_size_y(rect); | ||||
| int max_hint_width = INT_MAX; | int max_hint_width = INT_MAX; | ||||
| int padding = 0.25f * row_height; | int padding = 0.25f * row_height; | ||||
| char *cpoin = NULL; | char *cpoin = nullptr; | ||||
| uiWidgetStateInfo state = {0}; | uiWidgetStateInfo state = {0}; | ||||
| state.but_flag = but_flag; | state.but_flag = but_flag; | ||||
| Context not available. | |||||
| /* cut string in 2 parts? */ | /* cut string in 2 parts? */ | ||||
| if (separator_type != UI_MENU_ITEM_SEPARATOR_NONE) { | if (separator_type != UI_MENU_ITEM_SEPARATOR_NONE) { | ||||
| cpoin = strrchr(name, UI_SEP_CHAR); | cpoin = const_cast<char *>(strrchr(name, UI_SEP_CHAR)); | ||||
| if (cpoin) { | if (cpoin) { | ||||
| *cpoin = 0; | *cpoin = 0; | ||||
| Context not available. | |||||
| } | } | ||||
| int xofs = 0, yofs = 0; | int xofs = 0, yofs = 0; | ||||
| struct ResultBLF info; | ResultBLF info; | ||||
| UI_fontstyle_draw_ex(fstyle, | uiFontStyleDraw_Params params{}; | ||||
| rect, | params.align = UI_STYLE_TEXT_LEFT; | ||||
| drawstr, | UI_fontstyle_draw_ex( | ||||
| sizeof(drawstr), | fstyle, rect, drawstr, sizeof(drawstr), wt->wcol.text, ¶ms, &xofs, &yofs, &info); | ||||
| wt->wcol.text, | if (r_xmax != nullptr) { | ||||
| &(struct uiFontStyleDraw_Params){ | |||||
| .align = UI_STYLE_TEXT_LEFT, | |||||
| }, | |||||
| &xofs, | |||||
| &yofs, | |||||
| &info); | |||||
| if (r_xmax != NULL) { | |||||
| *r_xmax = xofs + info.width; | *r_xmax = xofs + info.width; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| rect->xmax = _rect.xmax - 5; | rect->xmax = _rect.xmax - 5; | ||||
| UI_fontstyle_draw(fstyle, | uiFontStyleDraw_Params params{}; | ||||
| rect, | params.align = UI_STYLE_TEXT_RIGHT; | ||||
| hint_drawstr, | UI_fontstyle_draw(fstyle, rect, hint_drawstr, sizeof(hint_drawstr), wt->wcol.text, ¶ms); | ||||
| sizeof(hint_drawstr), | |||||
| wt->wcol.text, | |||||
| &(struct uiFontStyleDraw_Params){ | |||||
| .align = UI_STYLE_TEXT_RIGHT, | |||||
| }); | |||||
| *cpoin = UI_SEP_CHAR; | *cpoin = UI_SEP_CHAR; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| rect->ymin += text_size; | rect->ymin += text_size; | ||||
| } | } | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| widget_draw_preview(iconid, 1.0f, rect); | widget_draw_preview(BIFIconID(iconid), 1.0f, rect); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| if (!has_text) { | if (!has_text) { | ||||
| Context not available. | |||||
| BLI_strncpy(drawstr, name, sizeof(drawstr)); | BLI_strncpy(drawstr, name, sizeof(drawstr)); | ||||
| UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); | UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); | ||||
| UI_fontstyle_draw(fstyle, | uiFontStyleDraw_Params params{}; | ||||
| &trect, | params.align = text_align; | ||||
| drawstr, | UI_fontstyle_draw(fstyle, &trect, drawstr, sizeof(drawstr), text_col, ¶ms); | ||||
| sizeof(drawstr), | |||||
| text_col, | |||||
| &(struct uiFontStyleDraw_Params){ | |||||
| .align = text_align, | |||||
| }); | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||