Index: release/scripts/startup/bl_ui/space_userpref.py =================================================================== --- release/scripts/startup/bl_ui/space_userpref.py (revision 45048) +++ release/scripts/startup/bl_ui/space_userpref.py (working copy) @@ -627,6 +627,10 @@ ui = theme.user_interface.wcol_menu_back col.label(text="Menu Back:") ui_items_general(col, ui) + + ui = theme.user_interface.wcol_tooltip + col.label(text="Tooltip:") + ui_items_general(col, ui) ui = theme.user_interface.wcol_tooltip col.label(text="Tooltip:") Index: source/blender/editors/interface/resources.c =================================================================== --- source/blender/editors/interface/resources.c (revision 45048) +++ source/blender/editors/interface/resources.c (working copy) @@ -1745,6 +1745,7 @@ for(btheme= U.themes.first; btheme; btheme= btheme->next) { if (btheme->tui.wcol_tooltip.inner[3] == 0) { btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back; + rgba_char_args_set(btheme->tui.wcol_tooltip.text, 255, 255, 255, 255); } } } Index: source/blender/editors/interface/interface_intern.h =================================================================== --- source/blender/editors/interface/interface_intern.h (revision 45048) +++ source/blender/editors/interface/interface_intern.h (working copy) @@ -466,7 +466,8 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); -void ui_draw_tooltip(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); +uiWidgetColors* ui_tooltip_get_theme(void); +void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol); void ui_draw_link_bezier(rcti *rect); Index: source/blender/editors/interface/interface_regions.c =================================================================== --- source/blender/editors/interface/interface_regions.c (revision 45048) +++ source/blender/editors/interface/interface_regions.c (working copy) @@ -308,13 +308,19 @@ /************************* Creating Tooltips **********************/ +typedef enum{ + UI_TIP_LC_NORMAL, + UI_TIP_LC_PYTHON, + UI_TIP_LC_ALERT, + UI_TIP_LC_SUBMENU +} uiTooltipLineColour; + #define MAX_TOOLTIP_LINES 8 - typedef struct uiTooltipData { rcti bbox; uiFontStyle fstyle; char lines[MAX_TOOLTIP_LINES][512]; - unsigned int color[MAX_TOOLTIP_LINES]; + uiTooltipLineColour line_brightness[MAX_TOOLTIP_LINES]; int totline; int toth, spaceh, lineh; } uiTooltipData; @@ -322,23 +328,81 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) { uiTooltipData *data= ar->regiondata; + uiWidgetColors* theme = ui_tooltip_get_theme(); rcti bbox= data->bbox; - int a; + char alert_colour[3] = {102, 102, 255}; + float normal_colour[3]; + float submenu_colour[3]; + float python_colour[3]; + float background_colour[3]; + float white[3] = {1.0f, 1.0f, 1.0f}; + char colour_char[3]; + float background_colour_mag, text_colour_mag, mag_diff; + int e; + int a, i; - ui_draw_tooltip(UI_GetStyle(), NULL, &data->bbox); + /*draw background*/ + ui_draw_tooltip_background(UI_GetStyle(), NULL, &bbox); + /*set background_colour*/ + rgb_uchar_to_float(background_colour, (const unsigned char*)theme->inner); + /*calculate normal_colour*/ + rgb_uchar_to_float(normal_colour, (const unsigned char*)theme->text); + /*find the brightness difference between background and text colours*/ + background_colour_mag = len_v3(background_colour); + text_colour_mag = len_v3(normal_colour); + mag_diff = text_colour_mag - background_colour_mag; - /* draw text */ - uiStyleFontSet(&data->fstyle); + if(mag_diff >= 0.0f){ + /*tint from dark to light*/ + /*calculate submenu_colour*/ + copy_v3_v3(submenu_colour, normal_colour); + mul_v3_fl(submenu_colour, 0.82222); + /*calculate python_clolour*/ + copy_v3_v3(python_colour, normal_colour); + mul_v3_fl(python_colour, 0.58888); + }else{ + /*tint from light to dark*/ + /*calculate submenu_colour*/ + copy_v3_v3(submenu_colour, normal_colour); + sub_v3_v3v3(submenu_colour, white, submenu_colour); + mul_v3_fl(submenu_colour, 0.3); + add_v3_v3(submenu_colour, normal_colour); + /*calculate python_clolour*/ + copy_v3_v3(python_colour, normal_colour); + sub_v3_v3v3(python_colour, white, python_colour); + mul_v3_fl(python_colour, 0.39); + add_v3_v3(python_colour, normal_colour); + } + + /* draw text */ + uiStyleFontSet(&data->fstyle); + bbox.ymax= bbox.ymax - 0.5f*((bbox.ymax - bbox.ymin) - data->toth); bbox.ymin= bbox.ymax - data->lineh; for(a=0; atotline; a++) { - cpack(data->color[a]); + switch(data->line_brightness[a]){ + case UI_TIP_LC_ALERT: + glColor3ubv((unsigned char*)alert_colour); + break; + case UI_TIP_LC_NORMAL: + rgb_float_to_uchar((unsigned char*)colour_char, normal_colour); + glColor3ubv((unsigned char*)colour_char); + break; + case UI_TIP_LC_SUBMENU: + rgb_float_to_uchar((unsigned char*)colour_char, submenu_colour); + glColor3ubv((unsigned char*)colour_char); + break; + case UI_TIP_LC_PYTHON: + rgb_float_to_uchar((unsigned char*)colour_char, python_colour); + glColor3ubv((unsigned char*)colour_char); + break; + } uiStyleFontDraw(&data->fstyle, &bbox, data->lines[a]); bbox.ymin -= data->lineh + data->spaceh; bbox.ymax -= data->lineh + data->spaceh; - } + } } static void ui_tooltip_region_free_cb(ARegion *ar) @@ -373,7 +437,7 @@ const char *descr= RNA_property_description(but->rnaprop); if(descr && descr[0]) { BLI_strncpy(data->lines[data->totline], descr, sizeof(data->lines[0])); - data->color[data->totline]= 0xFFFFFF; + data->line_brightness[data->totline]= UI_TIP_LC_NORMAL; data->totline++; } @@ -388,7 +452,7 @@ if(item[i].identifier[0] && item[i].value == value) { if(item[i].description && item[i].description[0]) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "%s: %s", item[i].name, item[i].description); - data->color[data->totline]= 0xDDDDDD; + data->line_brightness[data->totline]= UI_TIP_LC_SUBMENU; data->totline++; } break; @@ -403,7 +467,7 @@ if(but->tip && but->tip[0] != '\0') { BLI_strncpy(data->lines[data->totline], but->tip, sizeof(data->lines[0])); - data->color[data->totline]= 0xFFFFFF; + data->line_brightness[data->totline]= UI_TIP_LC_NORMAL; data->totline++; } @@ -415,7 +479,7 @@ buf, sizeof(buf))) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } } @@ -425,7 +489,7 @@ ui_get_but_string(but, buf, sizeof(buf)); if(buf[0]) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Value: %s"), buf); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } } @@ -437,7 +501,7 @@ if (RNA_property_type(but->rnaprop) == PROP_FLOAT) { float value= RNA_property_array_check(but->rnaprop) ? RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex) : RNA_property_float_get(&but->rnapoin, but->rnaprop); BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Radians: %f"), value); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } } @@ -446,7 +510,7 @@ if(ui_but_anim_expression_get(but, buf, sizeof(buf))) { /* expression */ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Expression: %s"), buf); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } } @@ -454,7 +518,7 @@ /* rna info */ if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s.%s"), RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop)); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } @@ -462,7 +526,7 @@ ID *id= but->rnapoin.id.data; if(id->lib && id->lib->name) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Library: %s"), id->lib->name); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } } @@ -477,7 +541,7 @@ /* operator info */ if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), str); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } @@ -491,7 +555,7 @@ poll_msg= CTX_wm_operator_poll_msg_get(C); if(poll_msg) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg); - data->color[data->totline]= 0x6666ff; /* alert */ + data->line_brightness[data->totline]= UI_TIP_LC_ALERT; /* alert */ data->totline++; } } @@ -501,7 +565,7 @@ MenuType *mt= uiButGetMenuType(but); if (mt) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), mt->idname); - data->color[data->totline]= 0x888888; + data->line_brightness[data->totline]= UI_TIP_LC_PYTHON; data->totline++; } } Index: source/blender/editors/interface/interface_widgets.c =================================================================== --- source/blender/editors/interface/interface_widgets.c (revision 45057) +++ source/blender/editors/interface/interface_widgets.c (working copy) @@ -3226,7 +3226,12 @@ } } -void ui_draw_tooltip(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect) +uiWidgetColors* ui_tooltip_get_theme(void){ + uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP); + return wt->wcol_theme; +} + +void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect) { uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP); wt->state(wt, 0);