Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.c
| Show All 36 Lines | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "ED_node.h" | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "interface_intern.h" | #include "interface_intern.h" | ||||
| #include "GPU_batch.h" | #include "GPU_batch.h" | ||||
| #include "GPU_batch_presets.h" | #include "GPU_batch_presets.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| ▲ Show 20 Lines • Show All 2,349 Lines • ▼ Show 20 Lines | for (uiButExtraOpIcon *op_icon = but->extra_op_icons.last; op_icon; op_icon = op_icon->prev) { | ||||
| 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, op_icon->icon, alpha, &temp, wcol->text); | widget_draw_icon(but, op_icon->icon, alpha, &temp, wcol->text); | ||||
| rect->xmax -= ICON_SIZE_FROM_BUTRECT(rect); | rect->xmax -= ICON_SIZE_FROM_BUTRECT(rect); | ||||
| } | } | ||||
| } | } | ||||
| static void widget_draw_node_link_socket(const uiWidgetColors *wcol, | |||||
| const rcti *rect, | |||||
| uiBut *but, | |||||
| float alpha) | |||||
| { | |||||
| if (but->custom_data) { | |||||
| const float scale = 0.9f / but->block->aspect; | |||||
| float col[4]; | |||||
| rgba_uchar_to_float(col, but->col); | |||||
| col[3] *= alpha; | |||||
| GPU_blend(true); | |||||
| UI_widgetbase_draw_cache_flush(); | |||||
| GPU_blend(false); | |||||
| /* See UI_but_node_link_set() */ | |||||
| ED_node_socket_draw(but->custom_data, rect, col, scale); | |||||
| } | |||||
| else { | |||||
| widget_draw_icon(but, ICON_LAYER_USED, alpha, rect, wcol->text); | |||||
| } | |||||
| } | |||||
| /* draws text and icons for buttons */ | /* draws text and icons for buttons */ | ||||
| static void widget_draw_text_icon(const uiFontStyle *fstyle, | static void widget_draw_text_icon(const uiFontStyle *fstyle, | ||||
| const uiWidgetColors *wcol, | const uiWidgetColors *wcol, | ||||
| uiBut *but, | uiBut *but, | ||||
| rcti *rect) | 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]; | ||||
| bool no_text_padding = false; | |||||
| ui_but_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 (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & UI_BUT_NODE_LINK)) { | if (ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_POPOVER) && (but->flag & UI_BUT_NODE_LINK)) { | ||||
| rcti temp = *rect; | rcti temp = *rect; | ||||
| temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; | const int size = BLI_rcti_size_y(rect) + 1; /* Not the icon size! */ | ||||
| widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, wcol->text); | |||||
| if (but->drawflag & UI_BUT_ICON_LEFT) { | |||||
| temp.xmax = rect->xmin + size; | |||||
| rect->xmin = temp.xmax; | |||||
| /* Further padding looks off. */ | |||||
| no_text_padding = true; | |||||
| } | |||||
| else { | |||||
| temp.xmin = rect->xmax - size; | |||||
| rect->xmax = temp.xmin; | rect->xmax = temp.xmin; | ||||
| } | } | ||||
| widget_draw_node_link_socket(wcol, &temp, but, alpha); | |||||
| } | |||||
| /* 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 */ | ||||
| /* 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 = widget_icon_id(but); | const BIFIconID icon = widget_icon_id(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; | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
| #ifdef USE_UI_TOOLBAR_HACK | #ifdef USE_UI_TOOLBAR_HACK | ||||
| but->block->aspect = aspect_orig; | but->block->aspect = aspect_orig; | ||||
| #endif | #endif | ||||
| rect->xmin += icon_size + icon_padding; | rect->xmin += icon_size + icon_padding; | ||||
| } | } | ||||
| if (!no_text_padding) { | |||||
| int text_padding = (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; | int text_padding = (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; | ||||
| if (but->editstr) { | if (but->editstr) { | ||||
| rect->xmin += text_padding; | rect->xmin += text_padding; | ||||
| } | } | ||||
| else if (but->flag & UI_BUT_DRAG_MULTI) { | else if (but->flag & UI_BUT_DRAG_MULTI) { | ||||
| bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL; | bool text_is_edited = ui_but_drag_multi_edit_get(but) != NULL; | ||||
| if (text_is_edited) { | if (text_is_edited) { | ||||
| rect->xmin += text_padding; | rect->xmin += text_padding; | ||||
| } | } | ||||
| } | } | ||||
| else if (but->drawflag & UI_BUT_TEXT_LEFT) { | else if (but->drawflag & UI_BUT_TEXT_LEFT) { | ||||
| /* Reduce the left padding for labels without an icon. */ | /* Reduce the left padding for labels without an icon. */ | ||||
| if ((but->type == UI_BTYPE_LABEL) && !(but->flag & UI_HAS_ICON) && | if ((but->type == UI_BTYPE_LABEL) && !(but->flag & UI_HAS_ICON) && | ||||
| !ui_block_is_menu(but->block)) { | !ui_block_is_menu(but->block)) { | ||||
| text_padding /= 2; | text_padding /= 2; | ||||
| } | } | ||||
| rect->xmin += text_padding; | rect->xmin += text_padding; | ||||
| } | } | ||||
| else if (but->drawflag & UI_BUT_TEXT_RIGHT) { | else if (but->drawflag & UI_BUT_TEXT_RIGHT) { | ||||
| rect->xmax -= text_padding; | rect->xmax -= text_padding; | ||||
| } | } | ||||
| } | |||||
| /* Menu contains sub-menu items with triangle icon on their right. Shortcut | /* Menu contains sub-menu items with triangle icon on their right. Shortcut | ||||
| * strings should be drawn with some padding to the right then. */ | * strings should be drawn with some padding to the right then. */ | ||||
| if (ui_block_is_menu(but->block) && | if (ui_block_is_menu(but->block) && | ||||
| (but->block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT)) { | (but->block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT)) { | ||||
| rect->xmax -= UI_MENU_SUBMENU_PADDING; | rect->xmax -= UI_MENU_SUBMENU_PADDING; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,870 Lines • Show Last 20 Lines | |||||