Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.c
| Show First 20 Lines • Show All 1,614 Lines • ▼ Show 20 Lines | static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *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_but_text_password_hide(password_str, but, true); | ui_but_text_password_hide(password_str, but, true); | ||||
| /* if a widget uses font shadow it has to be deactivated now */ | |||||
| BLF_disable(fstyle->uifont_id, BLF_SHADOW); | |||||
| } | } | ||||
| #undef UI_TEXT_CLIP_MARGIN | #undef UI_TEXT_CLIP_MARGIN | ||||
| /* *********************** widget types ************************************* */ | /* *********************** widget types ************************************* */ | ||||
| static struct uiWidgetStateColors wcol_state_colors = { | static struct uiWidgetStateColors wcol_state_colors = { | ||||
| ▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | static struct uiWidgetColors wcol_list_item = { | ||||
| {0, 0, 0, 255}, | {0, 0, 0, 255}, | ||||
| {0, 0, 0, 255}, | {0, 0, 0, 255}, | ||||
| 0, | 0, | ||||
| 0, 0 | 0, 0 | ||||
| }; | }; | ||||
| struct uiWidgetColors wcol_tab = { | |||||
| {255, 255, 255, 255}, | |||||
| {83, 83, 83, 255}, | |||||
| {114, 114, 114, 255}, | |||||
| {90, 90, 90, 255}, | |||||
| {0, 0, 0, 255}, | |||||
| {0, 0, 0, 255}, | |||||
| 0, | |||||
| 0, 0 | |||||
| }; | |||||
| /* free wcol struct to play with */ | /* free wcol struct to play with */ | ||||
| static struct uiWidgetColors wcol_tmp = { | static struct uiWidgetColors wcol_tmp = { | ||||
| {0, 0, 0, 255}, | {0, 0, 0, 255}, | ||||
| {128, 128, 128, 255}, | {128, 128, 128, 255}, | ||||
| {100, 100, 100, 255}, | {100, 100, 100, 255}, | ||||
| {25, 25, 25, 255}, | {25, 25, 25, 255}, | ||||
| {0, 0, 0, 255}, | {0, 0, 0, 255}, | ||||
| {255, 255, 255, 255}, | {255, 255, 255, 255}, | ||||
| 0, | 0, | ||||
| 0, 0 | 0, 0 | ||||
| }; | }; | ||||
| /* called for theme init (new theme) and versions */ | /* called for theme init (new theme) and versions */ | ||||
| void ui_widget_color_init(ThemeUI *tui) | void ui_widget_color_init(ThemeUI *tui) | ||||
| { | { | ||||
| tui->wcol_regular = wcol_regular; | tui->wcol_regular = wcol_regular; | ||||
| tui->wcol_tool = wcol_tool; | tui->wcol_tool = wcol_tool; | ||||
| tui->wcol_text = wcol_text; | tui->wcol_text = wcol_text; | ||||
| tui->wcol_radio = wcol_radio; | tui->wcol_radio = wcol_radio; | ||||
| tui->wcol_tab = wcol_tab; | |||||
| tui->wcol_option = wcol_option; | tui->wcol_option = wcol_option; | ||||
| tui->wcol_toggle = wcol_toggle; | tui->wcol_toggle = wcol_toggle; | ||||
| tui->wcol_num = wcol_num; | tui->wcol_num = wcol_num; | ||||
| tui->wcol_numslider = wcol_numslider; | tui->wcol_numslider = wcol_numslider; | ||||
| tui->wcol_menu = wcol_menu; | tui->wcol_menu = wcol_menu; | ||||
| tui->wcol_pulldown = wcol_pulldown; | tui->wcol_pulldown = wcol_pulldown; | ||||
| tui->wcol_menu_back = wcol_menu_back; | tui->wcol_menu_back = wcol_menu_back; | ||||
| tui->wcol_pie_menu = wcol_pie_menu; | tui->wcol_pie_menu = wcol_pie_menu; | ||||
| ▲ Show 20 Lines • Show All 1,430 Lines • ▼ Show 20 Lines | static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) | ||||
| widget_init(&wtb); | widget_init(&wtb); | ||||
| /* half rounded */ | /* half rounded */ | ||||
| round_box_edges(&wtb, roundboxalign, rect, rad); | round_box_edges(&wtb, roundboxalign, rect, rad); | ||||
| widgetbase_draw(&wtb, wcol); | widgetbase_draw(&wtb, wcol); | ||||
| } | } | ||||
| static void widget_tab(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) | |||||
| { | |||||
| const uiStyle *style = UI_style_get(); | |||||
| const float rad = 0.15f * U.widget_unit; | |||||
| const int fontid = style->widget.uifont_id; | |||||
| const bool is_active = but->flag & UI_SELECT; | |||||
| uiWidgetBase wtb; | |||||
| unsigned char theme_col_tab_highlight[3]; | |||||
| /* create outline highlight colors */ | |||||
| if (is_active) { | |||||
| interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner_sel, | |||||
| (unsigned char *)wcol->outline, 0.2f); | |||||
| } | |||||
| else { | |||||
| interp_v3_v3v3_uchar(theme_col_tab_highlight, (unsigned char *)wcol->inner, | |||||
| (unsigned char *)wcol->outline, 0.12f); | |||||
| } | |||||
| widget_init(&wtb); | |||||
| /* half rounded */ | |||||
| round_box_edges(&wtb, roundboxalign, rect, rad); | |||||
| /* draw inner */ | |||||
| wtb.draw_outline = 0; | |||||
| widgetbase_draw(&wtb, wcol); | |||||
| /* draw outline (3d look) */ | |||||
| ui_draw_but_TAB_outline(rect, rad, roundboxalign, theme_col_tab_highlight, | |||||
| is_active ? (unsigned char *)wcol->inner_sel : (unsigned char *)wcol->inner); | |||||
| /* text shadow */ | |||||
| BLF_enable(fontid, BLF_SHADOW); | |||||
| BLF_shadow(fontid, 3, 1.0f, 1.0f, 1.0f, 0.25f); | |||||
| BLF_shadow_offset(fontid, 0, -1); | |||||
| } | |||||
| static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect) | static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect) | ||||
| { | { | ||||
| uiWidgetBase wtb; | uiWidgetBase wtb; | ||||
| const float rad = 0.25f * U.widget_unit; | const float rad = 0.25f * U.widget_unit; | ||||
| unsigned char col[4]; | unsigned char col[4]; | ||||
| /* state copy! */ | /* state copy! */ | ||||
| wt->wcol = *(wt->wcol_theme); | wt->wcol = *(wt->wcol_theme); | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | case UI_WTYPE_SLIDER: | ||||
| wt.state = widget_state_numslider; | wt.state = widget_state_numslider; | ||||
| break; | break; | ||||
| case UI_WTYPE_EXEC: | case UI_WTYPE_EXEC: | ||||
| wt.wcol_theme = &btheme->tui.wcol_tool; | wt.wcol_theme = &btheme->tui.wcol_tool; | ||||
| wt.draw = widget_roundbut; | wt.draw = widget_roundbut; | ||||
| break; | break; | ||||
| case UI_WTYPE_TAB: | |||||
| wt.custom = widget_tab; | |||||
| wt.wcol_theme = &btheme->tui.wcol_tab; | |||||
| break; | |||||
| case UI_WTYPE_TOOLTIP: | case UI_WTYPE_TOOLTIP: | ||||
| wt.wcol_theme = &btheme->tui.wcol_tooltip; | wt.wcol_theme = &btheme->tui.wcol_tooltip; | ||||
| wt.draw = widget_menu_back; | wt.draw = widget_menu_back; | ||||
| break; | break; | ||||
| /* strings */ | /* strings */ | ||||
| case UI_WTYPE_NAME: | case UI_WTYPE_NAME: | ||||
| ▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | switch (but->type) { | ||||
| wt = widget_type(UI_WTYPE_NAME); | wt = widget_type(UI_WTYPE_NAME); | ||||
| break; | break; | ||||
| case UI_BTYPE_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 UI_BTYPE_TAB: | |||||
| wt = widget_type(UI_WTYPE_TAB); | |||||
| break; | |||||
| case UI_BTYPE_BUT_TOGGLE: | case UI_BTYPE_BUT_TOGGLE: | ||||
| case UI_BTYPE_TOGGLE: | case UI_BTYPE_TOGGLE: | ||||
| case UI_BTYPE_TOGGLE_N: | case UI_BTYPE_TOGGLE_N: | ||||
| wt = widget_type(UI_WTYPE_TOGGLE); | wt = widget_type(UI_WTYPE_TOGGLE); | ||||
| break; | break; | ||||
| case UI_BTYPE_CHECKBOX: | case UI_BTYPE_CHECKBOX: | ||||
| case UI_BTYPE_CHECKBOX_N: | case UI_BTYPE_CHECKBOX_N: | ||||
| ▲ Show 20 Lines • Show All 472 Lines • Show Last 20 Lines | |||||