Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.c
| Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad, bool use_alpha) | ||||
| if (use_alpha) { | if (use_alpha) { | ||||
| color[3] = 0.5f; | color[3] = 0.5f; | ||||
| } | } | ||||
| color[3] *= 0.125f; | color[3] *= 0.125f; | ||||
| glColor4fv(color); | glColor4fv(color); | ||||
| for (j = 0; j < WIDGET_AA_JITTER; j++) { | for (j = 0; j < WIDGET_AA_JITTER; j++) { | ||||
| glTranslatef(jit[j][0], jit[j][1], 0.0f); | glTranslatef(jit[j][0], jit[j][1], 0.0f); | ||||
| uiDrawBox(mode, minx, miny, maxx, maxy, rad); | UI_draw_roundbox_gl_mode(mode, minx, miny, maxx, maxy, rad); | ||||
| glTranslatef(-jit[j][0], -jit[j][1], 0.0f); | glTranslatef(-jit[j][0], -jit[j][1], 0.0f); | ||||
| } | } | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| static void widget_init(uiWidgetBase *wtb) | static void widget_init(uiWidgetBase *wtb) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | if (size > 0) { | ||||
| UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, size); | UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, size); | ||||
| } | } | ||||
| } | } | ||||
| static int ui_but_draw_menu_icon(const uiBut *but) | static int ui_but_draw_menu_icon(const uiBut *but) | ||||
| { | { | ||||
| return (but->flag & UI_ICON_SUBMENU) && (but->dt == UI_EMBOSSP); | return (but->flag & UI_BUT_ICON_SUBMENU) && (but->dt == UI_EMBOSS_PULLDOWN); | ||||
| } | } | ||||
| /* icons have been standardized... and this call draws in untransformed coordinates */ | /* icons have been standardized... and this call draws in untransformed coordinates */ | ||||
| static void widget_draw_icon(const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, | static void widget_draw_icon(const uiBut *but, BIFIconID icon, float alpha, const rcti *rect, | ||||
| const bool show_menu_icon) | const bool show_menu_icon) | ||||
| { | { | ||||
| float xs = 0.0f, ys = 0.0f; | float xs = 0.0f, ys = 0.0f; | ||||
| float aspect, height; | float aspect, height; | ||||
| if (but->flag & UI_ICON_PREVIEW) { | if (but->flag & UI_BUT_ICON_PREVIEW) { | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| widget_draw_preview(icon, alpha, rect); | widget_draw_preview(icon, alpha, rect); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| return; | return; | ||||
| } | } | ||||
| /* this icon doesn't need draw... */ | /* this icon doesn't need draw... */ | ||||
| if (icon == ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU) == 0) return; | if (icon == ICON_BLANK1 && (but->flag & UI_BUT_ICON_SUBMENU) == 0) return; | ||||
| aspect = but->block->aspect / UI_DPI_FAC; | aspect = but->block->aspect / UI_DPI_FAC; | ||||
| height = ICON_DEFAULT_HEIGHT / aspect; | height = ICON_DEFAULT_HEIGHT / aspect; | ||||
| /* calculate blend color */ | /* calculate blend color */ | ||||
| if (ELEM(but->type, TOG, ROW, TOGN, LISTROW)) { | if (ELEM(but->type, UI_BTYPE_TOGGLE, UI_BTYPE_ROW, UI_BTYPE_TOGGLE_N, UI_BTYPE_LISTROW)) { | ||||
| if (but->flag & UI_SELECT) {} | if (but->flag & UI_SELECT) {} | ||||
| else if (but->flag & UI_ACTIVE) {} | else if (but->flag & UI_ACTIVE) {} | ||||
| else alpha = 0.5f; | else alpha = 0.5f; | ||||
| } | } | ||||
| /* extra feature allows more alpha blending */ | /* extra feature allows more alpha blending */ | ||||
| if ((but->type == LABEL) && but->a1 == 1.0f) | if ((but->type == UI_BTYPE_LABEL) && but->a1 == 1.0f) | ||||
| alpha *= but->a2; | alpha *= but->a2; | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| if (icon && icon != ICON_BLANK1) { | if (icon && icon != ICON_BLANK1) { | ||||
| float ofs = 1.0f / aspect; | float ofs = 1.0f / aspect; | ||||
| if (but->drawflag & UI_BUT_ICON_LEFT) { | if (but->drawflag & UI_BUT_ICON_LEFT) { | ||||
| if (but->block->flag & UI_BLOCK_LOOP) { | if (but->block->flag & UI_BLOCK_LOOP) { | ||||
| if (ELEM(but->type, SEARCH_MENU, SEARCH_MENU_UNLINK)) | if (ELEM(but->type, UI_BTYPE_SEARCH_MENU, UI_BTYPE_SEARCH_MENU_UNLINK)) | ||||
| xs = rect->xmin + 4.0f * ofs; | xs = rect->xmin + 4.0f * ofs; | ||||
| else | else | ||||
| xs = rect->xmin + ofs; | xs = rect->xmin + ofs; | ||||
| } | } | ||||
| else { | else { | ||||
| xs = rect->xmin + 4.0f * ofs; | xs = rect->xmin + 4.0f * ofs; | ||||
| } | } | ||||
| ys = (rect->ymin + rect->ymax - height) / 2.0f; | ys = (rect->ymin + rect->ymax - height) / 2.0f; | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
| static float ui_text_clip_middle_ex(uiFontStyle *fstyle, char *str, float okwidth, const float minwidth, | static float ui_text_clip_middle_ex(uiFontStyle *fstyle, char *str, float okwidth, const float minwidth, | ||||
| const size_t max_len, const char *rpart_sep) | const size_t max_len, const char *rpart_sep) | ||||
| { | { | ||||
| float strwidth; | float strwidth; | ||||
| BLI_assert(str[0]); | BLI_assert(str[0]); | ||||
| /* need to set this first */ | /* need to set this first */ | ||||
| uiStyleFontSet(fstyle); | UI_fontstyle_set(fstyle); | ||||
| if (fstyle->kerning == 1) { /* for BLF_width */ | if (fstyle->kerning == 1) { /* for BLF_width */ | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| } | } | ||||
| strwidth = BLF_width(fstyle->uifont_id, str, max_len); | strwidth = BLF_width(fstyle->uifont_id, str, max_len); | ||||
| if ((okwidth > 0.0f) && (strwidth > okwidth)) { | if ((okwidth > 0.0f) && (strwidth > okwidth)) { | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** | /** | ||||
| * Wrapper around ui_text_clip_middle_ex. | * Wrapper around ui_text_clip_middle_ex. | ||||
| */ | */ | ||||
| static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rect) | static void ui_text_clip_middle(uiFontStyle *fstyle, uiBut *but, const rcti *rect) | ||||
| { | { | ||||
| /* No margin for labels! */ | /* No margin for labels! */ | ||||
| const int border = ELEM(but->type, LABEL, MENU) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f); | const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f); | ||||
| const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0); | const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0); | ||||
| const size_t max_len = sizeof(but->drawstr); | const size_t max_len = sizeof(but->drawstr); | ||||
| const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f; | const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f; | ||||
| but->ofs = 0; | but->ofs = 0; | ||||
| but->strwidth = ui_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, NULL); | but->strwidth = ui_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, NULL); | ||||
| } | } | ||||
| /** | /** | ||||
| * Like ui_text_clip_middle(), but protect/preserve at all cost the right part of the string after sep. | * Like ui_text_clip_middle(), but protect/preserve at all cost the right part of the string after sep. | ||||
| * Useful for strings with shortcuts (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O'). | * Useful for strings with shortcuts (like 'AVeryLongFooBarLabelForMenuEntry|Ctrl O' -> 'AVeryLong...MenuEntry|Ctrl O'). | ||||
| */ | */ | ||||
| static void ui_text_clip_middle_protect_right(uiFontStyle *fstyle, uiBut *but, const rcti *rect, const char *rsep) | static void ui_text_clip_middle_protect_right(uiFontStyle *fstyle, uiBut *but, const rcti *rect, const char *rsep) | ||||
| { | { | ||||
| /* No margin for labels! */ | /* No margin for labels! */ | ||||
| const int border = ELEM(but->type, LABEL, MENU) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f); | const int border = ELEM(but->type, UI_BTYPE_LABEL, UI_BTYPE_MENU) ? 0 : (int)(UI_TEXT_CLIP_MARGIN + 0.5f); | ||||
| const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0); | const float okwidth = (float)max_ii(BLI_rcti_size_x(rect) - border, 0); | ||||
| const size_t max_len = sizeof(but->drawstr); | const size_t max_len = sizeof(but->drawstr); | ||||
| const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f; | const float minwidth = (float)(UI_DPI_ICON_SIZE) / but->block->aspect * 2.0f; | ||||
| but->ofs = 0; | but->ofs = 0; | ||||
| but->strwidth = ui_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, rsep); | but->strwidth = ui_text_clip_middle_ex(fstyle, but->drawstr, okwidth, minwidth, max_len, rsep); | ||||
| } | } | ||||
| /** | /** | ||||
| * Cut off the text, taking into account the cursor location (text display while editing). | * Cut off the text, taking into account the cursor location (text display while editing). | ||||
| */ | */ | ||||
| static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rect) | static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rect) | ||||
| { | { | ||||
| const int border = (int)(UI_TEXT_CLIP_MARGIN + 0.5f); | const int border = (int)(UI_TEXT_CLIP_MARGIN + 0.5f); | ||||
| const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0); | const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0); | ||||
| BLI_assert(but->editstr && but->pos >= 0); | BLI_assert(but->editstr && but->pos >= 0); | ||||
| /* need to set this first */ | /* need to set this first */ | ||||
| uiStyleFontSet(fstyle); | UI_fontstyle_set(fstyle); | ||||
| if (fstyle->kerning == 1) /* for BLF_width */ | if (fstyle->kerning == 1) /* for BLF_width */ | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| /* define ofs dynamically */ | /* define ofs dynamically */ | ||||
| if (but->ofs > but->pos) | if (but->ofs > but->pos) | ||||
| but->ofs = but->pos; | but->ofs = but->pos; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| const int border = UI_TEXT_CLIP_MARGIN + 1; | const int border = UI_TEXT_CLIP_MARGIN + 1; | ||||
| const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0); | const int okwidth = max_ii(BLI_rcti_size_x(rect) - border, 0); | ||||
| char *cpoin = NULL; | char *cpoin = NULL; | ||||
| int drawstr_len = strlen(but->drawstr); | int drawstr_len = strlen(but->drawstr); | ||||
| const char *cpend = but->drawstr + drawstr_len; | const char *cpend = but->drawstr + drawstr_len; | ||||
| /* need to set this first */ | /* need to set this first */ | ||||
| uiStyleFontSet(fstyle); | UI_fontstyle_set(fstyle); | ||||
| if (fstyle->kerning == 1) /* for BLF_width */ | if (fstyle->kerning == 1) /* for BLF_width */ | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr)); | but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr, sizeof(but->drawstr)); | ||||
| but->ofs = 0; | but->ofs = 0; | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) | static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) | ||||
| { | { | ||||
| 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 = NULL; | ||||
| bool use_right_only = false; | bool use_right_only = false; | ||||
| uiStyleFontSet(fstyle); | UI_fontstyle_set(fstyle); | ||||
| if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) | if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) | ||||
| fstyle->align = UI_STYLE_TEXT_LEFT; | fstyle->align = UI_STYLE_TEXT_LEFT; | ||||
| else if (but->drawflag & UI_BUT_TEXT_RIGHT) | else if (but->drawflag & UI_BUT_TEXT_RIGHT) | ||||
| fstyle->align = UI_STYLE_TEXT_RIGHT; | fstyle->align = UI_STYLE_TEXT_RIGHT; | ||||
| else | else | ||||
| fstyle->align = UI_STYLE_TEXT_CENTER; | fstyle->align = UI_STYLE_TEXT_CENTER; | ||||
| if (fstyle->kerning == 1) /* for BLF_width */ | if (fstyle->kerning == 1) /* for BLF_width */ | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| /* Special case: when we're entering text for multiple buttons, | /* Special case: when we're entering text for multiple buttons, | ||||
| * don't draw the text for any of the multi-editing buttons */ | * don't draw the text for any of the multi-editing buttons */ | ||||
| if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) { | if (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI)) { | ||||
| uiBut *but_edit = ui_get_but_drag_multi_edit(but); | uiBut *but_edit = ui_but_drag_multi_edit_get(but); | ||||
| if (but_edit) { | if (but_edit) { | ||||
| drawstr = but_edit->editstr; | drawstr = but_edit->editstr; | ||||
| fstyle->align = UI_STYLE_TEXT_LEFT; | fstyle->align = UI_STYLE_TEXT_LEFT; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (but->editstr) { | if (but->editstr) { | ||||
| /* max length isn't used in this case, | /* max length isn't used in this case, | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | if (but->flag & UI_BUT_HAS_SEP_CHAR) { | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| drawstr_left_len = (drawstr_right - drawstr); | drawstr_left_len = (drawstr_right - drawstr); | ||||
| drawstr_right++; | drawstr_right++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #ifdef USE_NUMBUTS_LR_ALIGN | #ifdef USE_NUMBUTS_LR_ALIGN | ||||
| if (!drawstr_right && ELEM(but->type, NUM, NUMSLI) && | if (!drawstr_right && 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 == NULL) && (drawstr == but->drawstr)) | ||||
| { | { | ||||
| drawstr_right = strchr(drawstr + but->ofs, ':'); | drawstr_right = strchr(drawstr + but->ofs, ':'); | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| drawstr_right++; | drawstr_right++; | ||||
| drawstr_left_len = (drawstr_right - drawstr); | drawstr_left_len = (drawstr_right - drawstr); | ||||
| Show All 10 Lines | |||||
| #endif | #endif | ||||
| glColor4ubv((unsigned char *)wcol->text); | glColor4ubv((unsigned char *)wcol->text); | ||||
| if (!use_right_only) { | if (!use_right_only) { | ||||
| /* for underline drawing */ | /* for underline drawing */ | ||||
| float font_xofs, font_yofs; | float font_xofs, font_yofs; | ||||
| uiStyleFontDrawExt(fstyle, rect, drawstr + but->ofs, | UI_fontstyle_draw_ex(fstyle, rect, drawstr + but->ofs, | ||||
| drawstr_left_len - but->ofs, &font_xofs, &font_yofs); | drawstr_left_len - but->ofs, &font_xofs, &font_yofs); | ||||
| if (but->menu_key != '\0') { | if (but->menu_key != '\0') { | ||||
| char fixedbuf[128]; | char fixedbuf[128]; | ||||
| const char *str; | const char *str; | ||||
| BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len)); | BLI_strncpy(fixedbuf, drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len)); | ||||
| Show All 23 Lines | if (but->menu_key != '\0') { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* part text right aligned */ | /* part text right aligned */ | ||||
| if (drawstr_right) { | if (drawstr_right) { | ||||
| fstyle->align = UI_STYLE_TEXT_RIGHT; | fstyle->align = UI_STYLE_TEXT_RIGHT; | ||||
| rect->xmax -= UI_TEXT_CLIP_MARGIN; | rect->xmax -= UI_TEXT_CLIP_MARGIN; | ||||
| uiStyleFontDraw(fstyle, rect, drawstr_right); | UI_fontstyle_draw(fstyle, rect, drawstr_right); | ||||
| } | } | ||||
| } | } | ||||
| /* draws text and icons for buttons */ | /* draws text and icons for buttons */ | ||||
| static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) | static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) | ||||
| { | { | ||||
| const bool show_menu_icon = ui_but_draw_menu_icon(but); | const bool show_menu_icon = ui_but_draw_menu_icon(but); | ||||
| float alpha = (float)wcol->text[3] / 255.0f; | float alpha = (float)wcol->text[3] / 255.0f; | ||||
| char password_str[UI_MAX_DRAW_STR]; | char password_str[UI_MAX_DRAW_STR]; | ||||
| ui_button_text_password_hide(password_str, but, false); | ui_but_text_password_hide(password_str, but, false); | ||||
| /* check for button text label */ | /* check for button text label */ | ||||
| if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) { | if (but->type == UI_BTYPE_MENU && (but->flag & UI_BUT_NODE_LINK)) { | ||||
| rcti temp = *rect; | rcti temp = *rect; | ||||
| temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; | temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; | ||||
| widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false); | widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false); | ||||
| } | } | ||||
| /* If there's an icon too (made with uiDefIconTextBut) then draw the icon | /* If there's an icon too (made with uiDefIconTextBut) then draw the icon | ||||
| * and offset the text label to accommodate it */ | * and offset the text label to accommodate it */ | ||||
| Show All 18 Lines | static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) | ||||
| if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { | if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { | ||||
| rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; | rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; | ||||
| } | } | ||||
| else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) { | else if ((but->drawflag & UI_BUT_TEXT_RIGHT)) { | ||||
| rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; | rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; | ||||
| } | } | ||||
| /* unlink icon for this button type */ | /* unlink icon for this button type */ | ||||
| if ((but->type == SEARCH_MENU_UNLINK) && ui_is_but_search_unlink_visible(but)) { | if ((but->type == UI_BTYPE_SEARCH_MENU_UNLINK) && ui_but_is_search_unlink_visible(but)) { | ||||
| rcti temp = *rect; | rcti temp = *rect; | ||||
| temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f); | temp.xmin = temp.xmax - (BLI_rcti_size_y(rect) * 1.08f); | ||||
| widget_draw_icon(but, ICON_X, alpha, &temp, false); | widget_draw_icon(but, ICON_X, alpha, &temp, false); | ||||
| rect->xmax -= ICON_SIZE_FROM_BUTRECT(rect); | rect->xmax -= ICON_SIZE_FROM_BUTRECT(rect); | ||||
| } | } | ||||
| /* clip but->drawstr to fit in available space */ | /* clip but->drawstr to fit in available space */ | ||||
| if (but->editstr && but->pos >= 0) { | if (but->editstr && but->pos >= 0) { | ||||
| ui_text_clip_cursor(fstyle, but, rect); | ui_text_clip_cursor(fstyle, but, rect); | ||||
| } | } | ||||
| else if (but->drawstr[0] == '\0') { | else if (but->drawstr[0] == '\0') { | ||||
| /* bypass text clipping on icon buttons */ | /* bypass text clipping on icon buttons */ | ||||
| but->ofs = 0; | but->ofs = 0; | ||||
| but->strwidth = 0; | but->strwidth = 0; | ||||
| } | } | ||||
| else if (ELEM(but->type, NUM, NUMSLI)) { | else if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER)) { | ||||
| ui_text_clip_right_label(fstyle, but, rect); | ui_text_clip_right_label(fstyle, but, rect); | ||||
| } | } | ||||
| else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) { | else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == UI_BTYPE_BUT)) { | ||||
| /* Clip middle, but protect in all case right part containing the shortcut, if any. */ | /* Clip middle, but protect in all case right part containing the shortcut, if any. */ | ||||
| ui_text_clip_middle_protect_right(fstyle, but, rect, "|"); | ui_text_clip_middle_protect_right(fstyle, but, rect, "|"); | ||||
| } | } | ||||
| else { | else { | ||||
| ui_text_clip_middle(fstyle, but, rect); | ui_text_clip_middle(fstyle, but, rect); | ||||
| } | } | ||||
| /* always draw text for textbutton cursor */ | /* always draw text for textbutton cursor */ | ||||
| widget_draw_text(fstyle, wcol, but, rect); | widget_draw_text(fstyle, wcol, but, rect); | ||||
| ui_button_text_password_hide(password_str, but, true); | ui_but_text_password_hide(password_str, but, true); | ||||
| } | } | ||||
| #undef UI_TEXT_CLIP_MARGIN | #undef UI_TEXT_CLIP_MARGIN | ||||
| /* *********************** widget types ************************************* */ | /* *********************** widget types ************************************* */ | ||||
| ▲ Show 20 Lines • Show All 555 Lines • ▼ Show 20 Lines | static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction) | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| /* menu is 2nd level or deeper */ | /* menu is 2nd level or deeper */ | ||||
| if (flag & UI_BLOCK_POPUP) { | if (flag & UI_BLOCK_POPUP) { | ||||
| //rect->ymin -= 4.0; | //rect->ymin -= 4.0; | ||||
| //rect->ymax += 4.0; | //rect->ymax += 4.0; | ||||
| } | } | ||||
| else if (direction == UI_DOWN) { | else if (direction == UI_DIR_DOWN) { | ||||
| roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); | roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); | ||||
| rect->ymin -= 0.1f * U.widget_unit; | rect->ymin -= 0.1f * U.widget_unit; | ||||
| } | } | ||||
| else if (direction == UI_TOP) { | else if (direction == UI_DIR_UP) { | ||||
| roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT; | roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT; | ||||
| rect->ymax += 0.1f * U.widget_unit; | rect->ymax += 0.1f * U.widget_unit; | ||||
| } | } | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit); | widget_softshadow(rect, roundboxalign, 0.25f * U.widget_unit); | ||||
| round_box_edges(&wtb, roundboxalign, rect, 0.25f * U.widget_unit); | round_box_edges(&wtb, roundboxalign, rect, 0.25f * U.widget_unit); | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *rect) | ||||
| float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; | float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; | ||||
| /* gouraud triangle fan */ | /* gouraud triangle fan */ | ||||
| ColorPicker *cpicker = but->custom_data; | ColorPicker *cpicker = but->custom_data; | ||||
| const float *hsv_ptr = cpicker->color_data; | const float *hsv_ptr = cpicker->color_data; | ||||
| float xpos, ypos, ang = 0.0f; | float xpos, ypos, ang = 0.0f; | ||||
| float rgb[3], hsvo[3], hsv[3], col[3], colcent[3]; | float rgb[3], hsvo[3], hsv[3], col[3], colcent[3]; | ||||
| int a; | int a; | ||||
| bool color_profile = ui_color_picker_use_display_colorspace(but); | bool color_profile = ui_but_is_colorpicker_display_space(but); | ||||
| /* color */ | /* color */ | ||||
| ui_get_but_vectorf(but, rgb); | ui_but_v3_get(but, rgb); | ||||
| /* since we use compat functions on both 'hsv' and 'hsvo', they need to be initialized */ | /* since we use compat functions on both 'hsv' and 'hsvo', they need to be initialized */ | ||||
| hsvo[0] = hsv[0] = hsv_ptr[0]; | hsvo[0] = hsv[0] = hsv_ptr[0]; | ||||
| hsvo[1] = hsv[1] = hsv_ptr[1]; | hsvo[1] = hsv[1] = hsv_ptr[1]; | ||||
| hsvo[2] = hsv[2] = hsv_ptr[2]; | hsvo[2] = hsv[2] = hsv_ptr[2]; | ||||
| if (color_profile) | if (color_profile) | ||||
| ui_block_to_display_space_v3(but->block, rgb); | ui_block_cm_to_display_space_v3(but->block, rgb); | ||||
| ui_rgb_to_color_picker_compat_v(rgb, hsv); | ui_rgb_to_color_picker_compat_v(rgb, hsv); | ||||
| copy_v3_v3(hsvo, hsv); | copy_v3_v3(hsvo, hsv); | ||||
| CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */ | CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */ | ||||
| /* exception: if 'lock' is set | /* exception: if 'lock' is set | ||||
| * lock the value of the color wheel to 1. | * lock the value of the color wheel to 1. | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */ | ||||
| } | } | ||||
| glEnd(); | glEnd(); | ||||
| } | } | ||||
| glShadeModel(GL_FLAT); | glShadeModel(GL_FLAT); | ||||
| } | } | ||||
| bool ui_color_picker_use_display_colorspace(uiBut *but) | bool ui_but_is_colorpicker_display_space(uiBut *but) | ||||
| { | { | ||||
| bool color_profile = but->block->color_profile; | bool color_profile = but->block->color_profile; | ||||
| if (but->rnaprop) { | if (but->rnaprop) { | ||||
| if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) | if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) | ||||
| color_profile = false; | color_profile = false; | ||||
| } | } | ||||
| Show All 37 Lines | |||||
| static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) | static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) | ||||
| { | { | ||||
| 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 = but->custom_data; | ||||
| float *hsv = cpicker->color_data; | float *hsv = cpicker->color_data; | ||||
| float hsv_n[3]; | float hsv_n[3]; | ||||
| bool use_display_colorspace = ui_color_picker_use_display_colorspace(but); | bool use_display_colorspace = ui_but_is_colorpicker_display_space(but); | ||||
| copy_v3_v3(hsv_n, hsv); | copy_v3_v3(hsv_n, hsv); | ||||
| ui_get_but_vectorf(but, rgb); | ui_but_v3_get(but, rgb); | ||||
| if (use_display_colorspace) | if (use_display_colorspace) | ||||
| ui_block_to_display_space_v3(but->block, rgb); | ui_block_cm_to_display_space_v3(but->block, rgb); | ||||
| rgb_to_hsv_compat_v(rgb, hsv_n); | rgb_to_hsv_compat_v(rgb, hsv_n); | ||||
| ui_draw_gradient(rect, hsv_n, but->a1, 1.0f); | ui_draw_gradient(rect, hsv_n, but->a1, 1.0f); | ||||
| ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y); | ui_hsvcube_pos_from_vals(but, rect, hsv_n, &x, &y); | ||||
| CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); | CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f); | ||||
| CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); | CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f); | ||||
| Show All 12 Lines | static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) | ||||
| const float rad = 0.5f * BLI_rcti_size_x(rect); | const float rad = 0.5f * BLI_rcti_size_x(rect); | ||||
| float x, y; | float x, y; | ||||
| float rgb[3], hsv[3], v; | float rgb[3], hsv[3], v; | ||||
| bool color_profile = but->block->color_profile; | bool color_profile = but->block->color_profile; | ||||
| if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) | if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) | ||||
| color_profile = false; | color_profile = false; | ||||
| ui_get_but_vectorf(but, rgb); | ui_but_v3_get(but, rgb); | ||||
| if (color_profile) | if (color_profile) | ||||
| ui_block_to_display_space_v3(but->block, rgb); | ui_block_cm_to_display_space_v3(but->block, rgb); | ||||
| if (but->a1 == UI_GRAD_L_ALT) | if (but->a1 == UI_GRAD_L_ALT) | ||||
| rgb_to_hsl_v(rgb, hsv); | rgb_to_hsl_v(rgb, hsv); | ||||
| else | else | ||||
| rgb_to_hsv_v(rgb, hsv); | rgb_to_hsv_v(rgb, hsv); | ||||
| v = hsv[2]; | v = hsv[2]; | ||||
| /* map v from property range to [0,1] */ | /* map v from property range to [0,1] */ | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| } | } | ||||
| } | } | ||||
| /* function in use for buttons and for view2d sliders */ | /* function in use for buttons and for view2d sliders */ | ||||
| void uiWidgetScrollDraw(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state) | void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| int horizontal; | int horizontal; | ||||
| float rad; | float rad; | ||||
| bool outline = false; | bool outline = false; | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| 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)) | ||||
| { | { | ||||
| rcti rect1; | rcti rect1; | ||||
| double value; | double value; | ||||
| float fac, size, min; | float fac, size, min; | ||||
| int horizontal; | int horizontal; | ||||
| /* calculate slider part */ | /* calculate slider part */ | ||||
| value = ui_get_but_val(but); | value = ui_but_value_get(but); | ||||
| size = (but->softmax + but->a1 - but->softmin); | size = (but->softmax + but->a1 - but->softmin); | ||||
| size = max_ff(size, 2.0f); | size = max_ff(size, 2.0f); | ||||
| /* position */ | /* position */ | ||||
| rect1 = *rect; | rect1 = *rect; | ||||
| /* determine horizontal/vertical */ | /* determine horizontal/vertical */ | ||||
| Show All 33 Lines | if (BLI_rcti_size_y(&rect1) < min) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (state & UI_SELECT) | if (state & UI_SELECT) | ||||
| state = UI_SCROLL_PRESSED; | state = UI_SCROLL_PRESSED; | ||||
| else | else | ||||
| state = 0; | state = 0; | ||||
| uiWidgetScrollDraw(wcol, rect, &rect1, state); | UI_draw_widget_scroll(wcol, rect, &rect1, state); | ||||
| } | } | ||||
| static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign)) | static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int UNUSED(roundboxalign)) | ||||
| { | { | ||||
| rcti rect_prog = *rect, rect_bar = *rect; | rcti rect_prog = *rect, rect_bar = *rect; | ||||
| float value = but->a1; | float value = but->a1; | ||||
| float w, min; | float w, min; | ||||
| /* make the progress bar a proportion of the original height */ | /* make the progress bar a proportion of the original height */ | ||||
| /* hardcoded 4px high for now */ | /* hardcoded 4px high for now */ | ||||
| rect_prog.ymax = rect_prog.ymin + 4 * UI_DPI_FAC; | rect_prog.ymax = rect_prog.ymin + 4 * UI_DPI_FAC; | ||||
| rect_bar.ymax = rect_bar.ymin + 4 * UI_DPI_FAC; | rect_bar.ymax = rect_bar.ymin + 4 * UI_DPI_FAC; | ||||
| w = value * BLI_rcti_size_x(&rect_prog); | w = value * BLI_rcti_size_x(&rect_prog); | ||||
| /* ensure minimium size */ | /* ensure minimium size */ | ||||
| min = BLI_rcti_size_y(&rect_prog); | min = BLI_rcti_size_y(&rect_prog); | ||||
| w = MAX2(w, min); | w = MAX2(w, min); | ||||
| rect_bar.xmax = rect_bar.xmin + w; | rect_bar.xmax = rect_bar.xmin + w; | ||||
| uiWidgetScrollDraw(wcol, &rect_prog, &rect_bar, UI_SCROLL_NO_OUTLINE); | UI_draw_widget_scroll(wcol, &rect_prog, &rect_bar, UI_SCROLL_NO_OUTLINE); | ||||
| /* raise text a bit */ | /* raise text a bit */ | ||||
| rect->ymin += 6 * UI_DPI_FAC; | rect->ymin += 6 * UI_DPI_FAC; | ||||
| rect->xmin -= 6 * UI_DPI_FAC; | rect->xmin -= 6 * UI_DPI_FAC; | ||||
| } | } | ||||
| static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, int UNUSED(state), int UNUSED(roundboxalign)) | static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, int UNUSED(state), int UNUSED(roundboxalign)) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (!(state & UI_TEXTINPUT)) { | ||||
| copy_v3_v3_char(wcol->outline, wcol->item); | copy_v3_v3_char(wcol->outline, wcol->item); | ||||
| copy_v3_v3_char(wcol->inner, wcol->item); | copy_v3_v3_char(wcol->inner, wcol->item); | ||||
| if (!(state & UI_SELECT)) | if (!(state & UI_SELECT)) | ||||
| SWAP(short, wcol->shadetop, wcol->shadedown); | SWAP(short, wcol->shadetop, wcol->shadedown); | ||||
| rect1 = *rect; | rect1 = *rect; | ||||
| value = ui_get_but_val(but); | value = ui_but_value_get(but); | ||||
| fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin); | fac = ((float)value - but->softmin) * (BLI_rcti_size_x(&rect1) - offs) / (but->softmax - but->softmin); | ||||
| /* left part of slider, always rounded */ | /* left part of slider, always rounded */ | ||||
| rect1.xmax = rect1.xmin + ceil(offs + U.pixelsize); | rect1.xmax = rect1.xmin + ceil(offs + U.pixelsize); | ||||
| round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs); | round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs); | ||||
| wtb1.outline = 0; | wtb1.outline = 0; | ||||
| widgetbase_draw(&wtb1, wcol); | widgetbase_draw(&wtb1, wcol); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) | ||||
| } | } | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| /* half rounded */ | /* half rounded */ | ||||
| rad = 0.25f * U.widget_unit; | rad = 0.25f * U.widget_unit; | ||||
| round_box_edges(&wtb, roundboxalign, rect, rad); | round_box_edges(&wtb, roundboxalign, rect, rad); | ||||
| ui_get_but_vectorf(but, col); | ui_but_v3_get(but, col); | ||||
| if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { | if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { | ||||
| /* draw based on state - color for keyed etc */ | /* draw based on state - color for keyed etc */ | ||||
| widgetbase_draw(&wtb, wcol); | widgetbase_draw(&wtb, wcol); | ||||
| /* inset to draw swatch color */ | /* inset to draw swatch color */ | ||||
| rect->xmin += SWATCH_KEYED_BORDER; | rect->xmin += SWATCH_KEYED_BORDER; | ||||
| rect->xmax -= SWATCH_KEYED_BORDER; | rect->xmax -= SWATCH_KEYED_BORDER; | ||||
| rect->ymin += SWATCH_KEYED_BORDER; | rect->ymin += SWATCH_KEYED_BORDER; | ||||
| rect->ymax -= SWATCH_KEYED_BORDER; | rect->ymax -= SWATCH_KEYED_BORDER; | ||||
| round_box_edges(&wtb, roundboxalign, rect, rad); | round_box_edges(&wtb, roundboxalign, rect, rad); | ||||
| } | } | ||||
| if (color_profile) | if (color_profile) | ||||
| ui_block_to_display_space_v3(but->block, col); | ui_block_cm_to_display_space_v3(but->block, col); | ||||
| rgba_float_to_uchar((unsigned char *)wcol->inner, col); | rgba_float_to_uchar((unsigned char *)wcol->inner, col); | ||||
| wcol->shaded = 0; | wcol->shaded = 0; | ||||
| wcol->alpha_check = (wcol->inner[3] < 255); | wcol->alpha_check = (wcol->inner[3] < 255); | ||||
| widgetbase_draw(&wtb, wcol); | widgetbase_draw(&wtb, wcol); | ||||
| Show All 12 Lines | if (but->a1 == UI_PALETTE_COLOR && ((Palette *)but->rnapoin.id.data)->active_color == (int)but->a2) { | ||||
| glBegin(GL_TRIANGLES); | glBegin(GL_TRIANGLES); | ||||
| glVertex2f(rect->xmin + 0.1f * width, rect->ymin + 0.9f * height); | glVertex2f(rect->xmin + 0.1f * width, rect->ymin + 0.9f * height); | ||||
| glVertex2f(rect->xmin + 0.1f * width, rect->ymin + 0.5f * height); | glVertex2f(rect->xmin + 0.1f * width, rect->ymin + 0.5f * height); | ||||
| glVertex2f(rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); | glVertex2f(rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); | ||||
| glEnd(); | glEnd(); | ||||
| } | } | ||||
| } | } | ||||
| static void widget_normal(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)) | ||||
| { | { | ||||
| ui_draw_but_NORMAL(but, wcol, rect); | ui_draw_but_UNITVEC(but, wcol, rect); | ||||
| } | } | ||||
| static void widget_icon_has_anim(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) | static void widget_icon_has_anim(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) | ||||
| { | { | ||||
| if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { | if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| float rad; | float rad; | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| wtb.outline = 0; | wtb.outline = 0; | ||||
| /* rounded */ | /* rounded */ | ||||
| rad = 0.5f * BLI_rcti_size_y(rect); | rad = 0.5f * BLI_rcti_size_y(rect); | ||||
| round_box_edges(&wtb, UI_CNR_ALL, rect, rad); | round_box_edges(&wtb, UI_CNR_ALL, rect, rad); | ||||
| widgetbase_draw(&wtb, wcol); | widgetbase_draw(&wtb, wcol); | ||||
| } | } | ||||
| else if (but->type == NUM) { | else if (but->type == UI_BTYPE_NUM) { | ||||
| /* Draw number buttons still with left/right | /* Draw number buttons still with left/right | ||||
| * triangles when field is not embossed */ | * triangles when field is not embossed */ | ||||
| widget_numbut_embossn(but, wcol, rect, state, roundboxalign); | widget_numbut_embossn(but, wcol, rect, state, roundboxalign); | ||||
| } | } | ||||
| } | } | ||||
| static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) | static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) | ||||
| ▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Lines | case UI_WTYPE_LABEL: | ||||
| wt.draw = NULL; | wt.draw = NULL; | ||||
| wt.state = widget_state_label; | wt.state = widget_state_label; | ||||
| break; | break; | ||||
| case UI_WTYPE_TOGGLE: | case UI_WTYPE_TOGGLE: | ||||
| wt.wcol_theme = &btheme->tui.wcol_toggle; | wt.wcol_theme = &btheme->tui.wcol_toggle; | ||||
| break; | break; | ||||
| case UI_WTYPE_OPTION: | case UI_WTYPE_CHECKBOX: | ||||
| wt.wcol_theme = &btheme->tui.wcol_option; | wt.wcol_theme = &btheme->tui.wcol_option; | ||||
| wt.draw = widget_optionbut; | wt.draw = widget_optionbut; | ||||
| break; | break; | ||||
| case UI_WTYPE_RADIO: | case UI_WTYPE_RADIO: | ||||
| wt.wcol_theme = &btheme->tui.wcol_radio; | wt.wcol_theme = &btheme->tui.wcol_radio; | ||||
| wt.draw = widget_radiobut; | wt.draw = widget_radiobut; | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | switch (type) { | ||||
| case UI_WTYPE_BOX: | case UI_WTYPE_BOX: | ||||
| wt.custom = widget_box; | wt.custom = widget_box; | ||||
| wt.wcol_theme = &btheme->tui.wcol_box; | wt.wcol_theme = &btheme->tui.wcol_box; | ||||
| break; | break; | ||||
| case UI_WTYPE_RGB_PICKER: | case UI_WTYPE_RGB_PICKER: | ||||
| break; | break; | ||||
| case UI_WTYPE_NORMAL: | case UI_WTYPE_UNITVEC: | ||||
| wt.custom = widget_normal; | wt.custom = widget_unitvec; | ||||
| break; | break; | ||||
| case UI_WTYPE_SCROLL: | case UI_WTYPE_SCROLL: | ||||
| wt.wcol_theme = &btheme->tui.wcol_scroll; | wt.wcol_theme = &btheme->tui.wcol_scroll; | ||||
| wt.state = widget_state_nothing; | wt.state = widget_state_nothing; | ||||
| wt.custom = widget_scroll; | wt.custom = widget_scroll; | ||||
| break; | break; | ||||
| Show All 18 Lines | |||||
| } | } | ||||
| static int widget_roundbox_set(uiBut *but, rcti *rect) | static int widget_roundbox_set(uiBut *but, rcti *rect) | ||||
| { | { | ||||
| int roundbox = UI_CNR_ALL; | int roundbox = UI_CNR_ALL; | ||||
| /* alignment */ | /* alignment */ | ||||
| if ((but->drawflag & UI_BUT_ALIGN) && but->type != PULLDOWN) { | if ((but->drawflag & UI_BUT_ALIGN) && but->type != UI_BTYPE_PULLDOWN) { | ||||
| /* ui_block_position has this correction too, keep in sync */ | /* ui_block_position has this correction too, keep in sync */ | ||||
| if (but->drawflag & UI_BUT_ALIGN_TOP) | if (but->drawflag & UI_BUT_ALIGN_TOP) | ||||
| rect->ymax += U.pixelsize; | rect->ymax += U.pixelsize; | ||||
| if (but->drawflag & UI_BUT_ALIGN_LEFT) | if (but->drawflag & UI_BUT_ALIGN_LEFT) | ||||
| rect->xmin -= U.pixelsize; | rect->xmin -= U.pixelsize; | ||||
| switch (but->drawflag & UI_BUT_ALIGN) { | switch (but->drawflag & UI_BUT_ALIGN) { | ||||
| Show All 24 Lines | switch (but->drawflag & UI_BUT_ALIGN) { | ||||
| default: | default: | ||||
| roundbox = 0; | roundbox = 0; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* align with open menu */ | /* align with open menu */ | ||||
| if (but->active) { | if (but->active) { | ||||
| int direction = ui_button_open_menu_direction(but); | int direction = ui_but_menu_direction(but); | ||||
| if (direction == UI_TOP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT); | if (direction == UI_DIR_UP) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT); | ||||
| else if (direction == UI_DOWN) roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); | else if (direction == UI_DIR_DOWN) roundbox &= ~(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); | ||||
| else if (direction == UI_LEFT) roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); | else if (direction == UI_DIR_LEFT) roundbox &= ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); | ||||
| else if (direction == UI_RIGHT) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); | else if (direction == UI_DIR_RIGHT) roundbox &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); | ||||
| } | } | ||||
| return roundbox; | return roundbox; | ||||
| } | } | ||||
| /* put all widget colors on half alpha, use local storage */ | /* put all widget colors on half alpha, use local storage */ | ||||
| static void ui_widget_color_disabled(uiWidgetType *wt) | static void ui_widget_color_disabled(uiWidgetType *wt) | ||||
| { | { | ||||
| Show All 15 Lines | |||||
| void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) | void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) | ||||
| { | { | ||||
| bTheme *btheme = UI_GetTheme(); | bTheme *btheme = UI_GetTheme(); | ||||
| ThemeUI *tui = &btheme->tui; | ThemeUI *tui = &btheme->tui; | ||||
| uiFontStyle *fstyle = &style->widget; | uiFontStyle *fstyle = &style->widget; | ||||
| uiWidgetType *wt = NULL; | uiWidgetType *wt = NULL; | ||||
| /* handle menus separately */ | /* handle menus separately */ | ||||
| if (but->dt == UI_EMBOSSP) { | if (but->dt == UI_EMBOSS_PULLDOWN) { | ||||
| switch (but->type) { | switch (but->type) { | ||||
| case LABEL: | case UI_BTYPE_LABEL: | ||||
| widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); | widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); | ||||
| break; | break; | ||||
| case SEPRLINE: | case UI_BTYPE_SEPR_LINE: | ||||
| ui_draw_separator(rect, &tui->wcol_menu_item); | ui_draw_separator(rect, &tui->wcol_menu_item); | ||||
| break; | break; | ||||
| default: | default: | ||||
| wt = widget_type(UI_WTYPE_MENU_ITEM); | wt = widget_type(UI_WTYPE_MENU_ITEM); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| else if (but->dt == UI_EMBOSSN) { | else if (but->dt == UI_EMBOSS_NONE) { | ||||
| /* "nothing" */ | /* "nothing" */ | ||||
| wt = widget_type(UI_WTYPE_ICON); | wt = widget_type(UI_WTYPE_ICON); | ||||
| } | } | ||||
| else if (but->dt == UI_EMBOSSR) { | else if (but->dt == UI_EMBOSS_RADIAL) { | ||||
| wt = widget_type(UI_WTYPE_MENU_ITEM_RADIAL); | wt = widget_type(UI_WTYPE_MENU_ITEM_RADIAL); | ||||
| } | } | ||||
| else { | else { | ||||
| switch (but->type) { | switch (but->type) { | ||||
| case LABEL: | case UI_BTYPE_LABEL: | ||||
| if (but->block->flag & UI_BLOCK_LOOP) | if (but->block->flag & UI_BLOCK_LOOP) | ||||
| widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); | widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); | ||||
| else { | else { | ||||
| wt = widget_type(UI_WTYPE_LABEL); | wt = widget_type(UI_WTYPE_LABEL); | ||||
| fstyle = &style->widgetlabel; | fstyle = &style->widgetlabel; | ||||
| } | } | ||||
| break; | break; | ||||
| case SEPR: | case UI_BTYPE_SEPR: | ||||
| case SEPRLINE: | case UI_BTYPE_SEPR_LINE: | ||||
| break; | break; | ||||
| case BUT: | case UI_BTYPE_BUT: | ||||
| wt = widget_type(UI_WTYPE_EXEC); | wt = widget_type(UI_WTYPE_EXEC); | ||||
| break; | break; | ||||
| case NUM: | case UI_BTYPE_NUM: | ||||
| wt = widget_type(UI_WTYPE_NUMBER); | wt = widget_type(UI_WTYPE_NUMBER); | ||||
| break; | break; | ||||
| case NUMSLI: | case UI_BTYPE_NUM_SLIDER: | ||||
| wt = widget_type(UI_WTYPE_SLIDER); | wt = widget_type(UI_WTYPE_SLIDER); | ||||
| break; | break; | ||||
| case ROW: | case UI_BTYPE_ROW: | ||||
| wt = widget_type(UI_WTYPE_RADIO); | wt = widget_type(UI_WTYPE_RADIO); | ||||
| break; | break; | ||||
| case LISTROW: | case UI_BTYPE_LISTROW: | ||||
| wt = widget_type(UI_WTYPE_LISTITEM); | wt = widget_type(UI_WTYPE_LISTITEM); | ||||
| break; | break; | ||||
| case TEX: | case UI_BTYPE_TEXT: | ||||
| wt = widget_type(UI_WTYPE_NAME); | wt = widget_type(UI_WTYPE_NAME); | ||||
| break; | break; | ||||
| case SEARCH_MENU_UNLINK: | case UI_BTYPE_SEARCH_MENU_UNLINK: | ||||
| case SEARCH_MENU: | case UI_BTYPE_SEARCH_MENU: | ||||
| wt = widget_type(UI_WTYPE_NAME); | wt = widget_type(UI_WTYPE_NAME); | ||||
| if (but->block->flag & UI_BLOCK_LOOP) | if (but->block->flag & UI_BLOCK_LOOP) | ||||
| wt->wcol_theme = &btheme->tui.wcol_menu_back; | wt->wcol_theme = &btheme->tui.wcol_menu_back; | ||||
| break; | break; | ||||
| case TOGBUT: | case UI_BTYPE_BUT_TOGGLE: | ||||
| case TOG: | case UI_BTYPE_TOGGLE: | ||||
| case TOGN: | case UI_BTYPE_TOGGLE_N: | ||||
| wt = widget_type(UI_WTYPE_TOGGLE); | wt = widget_type(UI_WTYPE_TOGGLE); | ||||
| break; | break; | ||||
| case OPTION: | case UI_BTYPE_CHECKBOX: | ||||
| case OPTIONN: | case UI_BTYPE_CHECKBOX_N: | ||||
| if (!(but->flag & UI_HAS_ICON)) { | if (!(but->flag & UI_HAS_ICON)) { | ||||
| wt = widget_type(UI_WTYPE_OPTION); | wt = widget_type(UI_WTYPE_CHECKBOX); | ||||
| but->drawflag |= UI_BUT_TEXT_LEFT; | but->drawflag |= UI_BUT_TEXT_LEFT; | ||||
| } | } | ||||
| else | else | ||||
| wt = widget_type(UI_WTYPE_TOGGLE); | wt = widget_type(UI_WTYPE_TOGGLE); | ||||
| /* option buttons have strings outside, on menus use different colors */ | /* option buttons have strings outside, on menus use different colors */ | ||||
| if (but->block->flag & UI_BLOCK_LOOP) | if (but->block->flag & UI_BLOCK_LOOP) | ||||
| wt->state = widget_state_option_menu; | wt->state = widget_state_option_menu; | ||||
| break; | break; | ||||
| case MENU: | case UI_BTYPE_MENU: | ||||
| case BLOCK: | case UI_BTYPE_BLOCK: | ||||
| if (but->flag & UI_BUT_NODE_LINK) { | if (but->flag & UI_BUT_NODE_LINK) { | ||||
| /* new node-link button, not active yet XXX */ | /* new node-link button, not active yet XXX */ | ||||
| wt = widget_type(UI_WTYPE_MENU_NODE_LINK); | wt = widget_type(UI_WTYPE_MENU_NODE_LINK); | ||||
| } | } | ||||
| else { | else { | ||||
| /* with menu arrows */ | /* with menu arrows */ | ||||
| /* we could use a flag for this, but for now just check size, | /* we could use a flag for this, but for now just check size, | ||||
| * add updown arrows if there is room. */ | * add updown arrows if there is room. */ | ||||
| if ((!but->str[0] && but->icon && (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect) + 2)) || | if ((!but->str[0] && but->icon && (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect) + 2)) || | ||||
| /* disable for brushes also */ | /* disable for brushes also */ | ||||
| (but->flag & UI_ICON_PREVIEW)) | (but->flag & UI_BUT_ICON_PREVIEW)) | ||||
| { | { | ||||
| /* no arrows */ | /* no arrows */ | ||||
| wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); | wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); | ||||
| } | } | ||||
| else { | else { | ||||
| wt = widget_type(UI_WTYPE_MENU_RADIO); | wt = widget_type(UI_WTYPE_MENU_RADIO); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case PULLDOWN: | case UI_BTYPE_PULLDOWN: | ||||
| wt = widget_type(UI_WTYPE_PULLDOWN); | wt = widget_type(UI_WTYPE_PULLDOWN); | ||||
| break; | break; | ||||
| case BUTM: | case UI_BTYPE_BUT_MENU: | ||||
| wt = widget_type(UI_WTYPE_MENU_ITEM); | wt = widget_type(UI_WTYPE_MENU_ITEM); | ||||
| break; | break; | ||||
| case COLOR: | case UI_BTYPE_COLOR: | ||||
| wt = widget_type(UI_WTYPE_SWATCH); | wt = widget_type(UI_WTYPE_SWATCH); | ||||
| break; | break; | ||||
| case ROUNDBOX: | case UI_BTYPE_ROUNDBOX: | ||||
| case LISTBOX: | case UI_BTYPE_LISTBOX: | ||||
| wt = widget_type(UI_WTYPE_BOX); | wt = widget_type(UI_WTYPE_BOX); | ||||
| break; | break; | ||||
| case LINK: | case UI_BTYPE_LINK: | ||||
| case INLINK: | case UI_BTYPE_INLINK: | ||||
| wt = widget_type(UI_WTYPE_ICON); | wt = widget_type(UI_WTYPE_ICON); | ||||
| wt->custom = widget_link; | wt->custom = widget_link; | ||||
| break; | break; | ||||
| case BUT_EXTRA: | case UI_BTYPE_EXTRA: | ||||
| widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect); | widget_draw_extra_mask(C, but, widget_type(UI_WTYPE_BOX), rect); | ||||
| break; | break; | ||||
| case HSVCUBE: | case UI_BTYPE_HSVCUBE: | ||||
| if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { /* vertical V slider, uses new widget draw now */ | if (ELEM(but->a1, UI_GRAD_V_ALT, UI_GRAD_L_ALT)) { /* vertical V slider, uses new widget draw now */ | ||||
| ui_draw_but_HSV_v(but, rect); | ui_draw_but_HSV_v(but, rect); | ||||
| } | } | ||||
| else { /* other HSV pickers... */ | else { /* other HSV pickers... */ | ||||
| ui_draw_but_HSVCUBE(but, rect); | ui_draw_but_HSVCUBE(but, rect); | ||||
| } | } | ||||
| break; | break; | ||||
| case HSVCIRCLE: | case UI_BTYPE_HSVCIRCLE: | ||||
| ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect); | ui_draw_but_HSVCIRCLE(but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case BUT_COLORBAND: | case UI_BTYPE_COLORBAND: | ||||
| ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect); | ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case BUT_NORMAL: | case UI_BTYPE_UNITVEC: | ||||
| wt = widget_type(UI_WTYPE_NORMAL); | wt = widget_type(UI_WTYPE_UNITVEC); | ||||
| break; | break; | ||||
| case BUT_IMAGE: | case UI_BTYPE_IMAGE: | ||||
| ui_draw_but_IMAGE(ar, but, &tui->wcol_regular, rect); | ui_draw_but_IMAGE(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case HISTOGRAM: | case UI_BTYPE_HISTOGRAM: | ||||
| ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect); | ui_draw_but_HISTOGRAM(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case WAVEFORM: | case UI_BTYPE_WAVEFORM: | ||||
| ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect); | ui_draw_but_WAVEFORM(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case VECTORSCOPE: | case UI_BTYPE_VECTORSCOPE: | ||||
| ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect); | ui_draw_but_VECTORSCOPE(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case BUT_CURVE: | case UI_BTYPE_CURVE: | ||||
| ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); | ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case PROGRESSBAR: | case UI_BTYPE_PROGRESS_BAR: | ||||
| wt = widget_type(UI_WTYPE_PROGRESSBAR); | wt = widget_type(UI_WTYPE_PROGRESSBAR); | ||||
| fstyle = &style->widgetlabel; | fstyle = &style->widgetlabel; | ||||
| break; | break; | ||||
| case SCROLL: | case UI_BTYPE_SCROLL: | ||||
| wt = widget_type(UI_WTYPE_SCROLL); | wt = widget_type(UI_WTYPE_SCROLL); | ||||
| break; | break; | ||||
| case GRIP: | case UI_BTYPE_GRIP: | ||||
| wt = widget_type(UI_WTYPE_ICON); | wt = widget_type(UI_WTYPE_ICON); | ||||
| break; | break; | ||||
| case TRACKPREVIEW: | case UI_BTYPE_TRACK_PREVIEW: | ||||
| ui_draw_but_TRACKPREVIEW(ar, but, &tui->wcol_regular, rect); | ui_draw_but_TRACKPREVIEW(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| case NODESOCKET: | case UI_BTYPE_NODE_SOCKET: | ||||
| ui_draw_but_NODESOCKET(ar, but, &tui->wcol_regular, rect); | ui_draw_but_NODESOCKET(ar, but, &tui->wcol_regular, rect); | ||||
| break; | break; | ||||
| default: | default: | ||||
| wt = widget_type(UI_WTYPE_REGULAR); | wt = widget_type(UI_WTYPE_REGULAR); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (wt) { | if (wt) { | ||||
| //rcti disablerect = *rect; /* rect gets clipped smaller for text */ | //rcti disablerect = *rect; /* rect gets clipped smaller for text */ | ||||
| int roundboxalign, state; | int roundboxalign, state; | ||||
| bool disabled = false; | bool disabled = false; | ||||
| roundboxalign = widget_roundbox_set(but, rect); | roundboxalign = widget_roundbox_set(but, rect); | ||||
| state = but->flag; | state = but->flag; | ||||
| if ((but->editstr) || | if ((but->editstr) || | ||||
| (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_get_but_drag_multi_edit(but))) | (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_but_drag_multi_edit_get(but))) | ||||
| { | { | ||||
| state |= UI_TEXTINPUT; | state |= UI_TEXTINPUT; | ||||
| } | } | ||||
| if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) | if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) | ||||
| if (but->dt != UI_EMBOSSP) | if (but->dt != UI_EMBOSS_PULLDOWN) | ||||
| disabled = true; | disabled = true; | ||||
| if (disabled) | if (disabled) | ||||
| ui_widget_color_disabled(wt); | ui_widget_color_disabled(wt); | ||||
| wt->state(wt, state); | wt->state(wt, state); | ||||
| if (wt->custom) | if (wt->custom) | ||||
| wt->custom(but, &wt->wcol, rect, state, roundboxalign); | wt->custom(but, &wt->wcol, rect, state, roundboxalign); | ||||
| else if (wt->draw) | else if (wt->draw) | ||||
| wt->draw(&wt->wcol, rect, state, roundboxalign); | wt->draw(&wt->wcol, rect, state, roundboxalign); | ||||
| if (disabled) | if (disabled) | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| wt->text(fstyle, &wt->wcol, but, rect); | wt->text(fstyle, &wt->wcol, but, rect); | ||||
| if (disabled) | if (disabled) | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| // if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) | // if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) | ||||
| // if (but->dt != UI_EMBOSSP) | // if (but->dt != UI_EMBOSS_PULLDOWN) | ||||
| // widget_disabled(&disablerect); | // widget_disabled(&disablerect); | ||||
| } | } | ||||
| } | } | ||||
| void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) | void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) | ||||
| { | { | ||||
| uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); | uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK); | ||||
| wt->state(wt, 0); | wt->state(wt, 0); | ||||
| if (block) | if (block) | ||||
| wt->draw(&wt->wcol, rect, block->flag, block->direction); | wt->draw(&wt->wcol, rect, block->flag, block->direction); | ||||
| else | else | ||||
| wt->draw(&wt->wcol, rect, 0, 0); | wt->draw(&wt->wcol, rect, 0, 0); | ||||
| if (block) { | if (block) { | ||||
| if (block->flag & UI_BLOCK_CLIPTOP) { | if (block->flag & UI_BLOCK_CLIPTOP) { | ||||
| /* XXX no scaling for UI here yet */ | /* XXX no scaling for UI here yet */ | ||||
| glColor3ubv((unsigned char *)wt->wcol.text); | glColor3ubv((unsigned char *)wt->wcol.text); | ||||
| UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymax - 8, 't'); | UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymax - 8, 't'); | ||||
| } | } | ||||
| if (block->flag & UI_BLOCK_CLIPBOTTOM) { | if (block->flag & UI_BLOCK_CLIPBOTTOM) { | ||||
| /* XXX no scaling for UI here yet */ | /* XXX no scaling for UI here yet */ | ||||
| glColor3ubv((unsigned char *)wt->wcol.text); | glColor3ubv((unsigned char *)wt->wcol.text); | ||||
| UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v'); | UI_draw_icon_tri(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v'); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void draw_disk_shaded( | static void draw_disk_shaded( | ||||
| float start, float angle, | float start, float angle, | ||||
| float radius_int, float radius_ext, int subd, | float radius_int, float radius_ext, int subd, | ||||
| const char col1[4], const char col2[4], | const char col1[4], const char col2[4], | ||||
| ▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM); | uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM); | ||||
| rcti _rect = *rect; | rcti _rect = *rect; | ||||
| char *cpoin = NULL; | char *cpoin = NULL; | ||||
| wt->state(wt, state); | wt->state(wt, state); | ||||
| wt->draw(&wt->wcol, rect, 0, 0); | wt->draw(&wt->wcol, rect, 0, 0); | ||||
| uiStyleFontSet(fstyle); | UI_fontstyle_set(fstyle); | ||||
| fstyle->align = UI_STYLE_TEXT_LEFT; | fstyle->align = UI_STYLE_TEXT_LEFT; | ||||
| /* text location offset */ | /* text location offset */ | ||||
| rect->xmin += 0.25f * UI_UNIT_X; | rect->xmin += 0.25f * UI_UNIT_X; | ||||
| if (iconid) rect->xmin += UI_DPI_ICON_SIZE; | if (iconid) rect->xmin += UI_DPI_ICON_SIZE; | ||||
| /* cut string in 2 parts? */ | /* cut string in 2 parts? */ | ||||
| if (use_sep) { | if (use_sep) { | ||||
| cpoin = strchr(name, UI_SEP_CHAR); | cpoin = strchr(name, UI_SEP_CHAR); | ||||
| if (cpoin) { | if (cpoin) { | ||||
| *cpoin = 0; | *cpoin = 0; | ||||
| /* need to set this first */ | /* need to set this first */ | ||||
| uiStyleFontSet(fstyle); | UI_fontstyle_set(fstyle); | ||||
| if (fstyle->kerning == 1) { /* for BLF_width */ | if (fstyle->kerning == 1) { /* for BLF_width */ | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| } | } | ||||
| rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + UI_DPI_ICON_SIZE; | rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1, INT_MAX) + UI_DPI_ICON_SIZE; | ||||
| if (fstyle->kerning == 1) { | if (fstyle->kerning == 1) { | ||||
| BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| char drawstr[UI_MAX_DRAW_STR]; | char drawstr[UI_MAX_DRAW_STR]; | ||||
| const float okwidth = (float)BLI_rcti_size_x(rect); | const float okwidth = (float)BLI_rcti_size_x(rect); | ||||
| const size_t max_len = sizeof(drawstr); | const size_t max_len = sizeof(drawstr); | ||||
| const float minwidth = (float)(UI_DPI_ICON_SIZE); | const float minwidth = (float)(UI_DPI_ICON_SIZE); | ||||
| BLI_strncpy(drawstr, name, sizeof(drawstr)); | BLI_strncpy(drawstr, name, sizeof(drawstr)); | ||||
| ui_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, NULL); | ui_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, NULL); | ||||
| glColor4ubv((unsigned char *)wt->wcol.text); | glColor4ubv((unsigned char *)wt->wcol.text); | ||||
| uiStyleFontDraw(fstyle, rect, drawstr); | UI_fontstyle_draw(fstyle, rect, drawstr); | ||||
| } | } | ||||
| /* part text right aligned */ | /* part text right aligned */ | ||||
| if (use_sep) { | if (use_sep) { | ||||
| if (cpoin) { | if (cpoin) { | ||||
| fstyle->align = UI_STYLE_TEXT_RIGHT; | fstyle->align = UI_STYLE_TEXT_RIGHT; | ||||
| rect->xmax = _rect.xmax - 5; | rect->xmax = _rect.xmax - 5; | ||||
| uiStyleFontDraw(fstyle, rect, cpoin + 1); | UI_fontstyle_draw(fstyle, rect, cpoin + 1); | ||||
| *cpoin = UI_SEP_CHAR; | *cpoin = UI_SEP_CHAR; | ||||
| } | } | ||||
| } | } | ||||
| /* restore rect, was messed with */ | /* restore rect, was messed with */ | ||||
| *rect = _rect; | *rect = _rect; | ||||
| if (iconid) { | if (iconid) { | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | glDisable(GL_BLEND); | ||||
| const float okwidth = (float)BLI_rcti_size_x(&trect); | const float okwidth = (float)BLI_rcti_size_x(&trect); | ||||
| const size_t max_len = sizeof(drawstr); | const size_t max_len = sizeof(drawstr); | ||||
| const float minwidth = (float)(UI_DPI_ICON_SIZE); | const float minwidth = (float)(UI_DPI_ICON_SIZE); | ||||
| BLI_strncpy(drawstr, name, sizeof(drawstr)); | BLI_strncpy(drawstr, name, sizeof(drawstr)); | ||||
| ui_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, NULL); | ui_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, NULL); | ||||
| glColor4ubv((unsigned char *)wt->wcol.text); | glColor4ubv((unsigned char *)wt->wcol.text); | ||||
| uiStyleFontDraw(fstyle, &trect, drawstr); | UI_fontstyle_draw(fstyle, &trect, drawstr); | ||||
| } | } | ||||
| } | } | ||||