UI: Text Style for Tooltips
This gives users the ability to control the size of tooltip text separately from other text styles. This is an accessibility issue in that users with low vision can choose to make these larger than the working text. Pull Request: https://projects.blender.org/blender/blender/pulls/125147
This commit is contained in:
committed by
Harley Acheson
parent
f7672438bf
commit
5bf44c6eb4
@@ -1244,6 +1244,11 @@ class USERPREF_PT_theme_text_style(ThemePanel, CenterAlignMixIn, Panel):
|
||||
layout.label(text="Widget")
|
||||
self._ui_font_style(layout, style.widget)
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.label(text="Tooltip")
|
||||
self._ui_font_style(layout, style.tooltip)
|
||||
|
||||
|
||||
class USERPREF_PT_theme_bone_color_sets(ThemePanel, CenterAlignMixIn, Panel):
|
||||
bl_label = "Bone Color Sets"
|
||||
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 11
|
||||
#define BLENDER_FILE_SUBVERSION 12
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
||||
@@ -1036,6 +1036,17 @@ void blo_do_versions_userdef(UserDef *userdef)
|
||||
userdef, "VIEW3D_AST_brush_sculpt", "Brushes/Mesh Sculpt/Paint");
|
||||
}
|
||||
|
||||
if (!USER_VERSION_ATLEAST(403, 12)) {
|
||||
LISTBASE_FOREACH (uiStyle *, style, &userdef->uistyles) {
|
||||
style->tooltip.points = 11.0f; /* UI_DEFAULT_TOOLTIP_POINTS */
|
||||
style->tooltip.character_weight = 400;
|
||||
style->tooltip.shadow = 0;
|
||||
style->tooltip.shady = -1;
|
||||
style->tooltip.shadowalpha = 0.5f;
|
||||
style->tooltip.shadowcolor = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a USER_VERSION_ATLEAST check.
|
||||
|
||||
@@ -291,6 +291,9 @@ enum {
|
||||
/** Larger size used for title text. */
|
||||
#define UI_DEFAULT_TITLE_POINTS 11.0f
|
||||
|
||||
/** Size of tooltip text. */
|
||||
#define UI_DEFAULT_TOOLTIP_POINTS 11.0f
|
||||
|
||||
#define UI_PANEL_WIDTH 340
|
||||
#define UI_COMPACT_PANEL_WIDTH 160
|
||||
#define UI_SIDEBAR_PANEL_WIDTH 280
|
||||
|
||||
@@ -2045,6 +2045,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
ui_fontscale(&style.paneltitle.points, block->aspect);
|
||||
ui_fontscale(&style.grouplabel.points, block->aspect);
|
||||
ui_fontscale(&style.widget.points, block->aspect);
|
||||
ui_fontscale(&style.tooltip.points, block->aspect);
|
||||
|
||||
/* scale block min/max to rect */
|
||||
rcti rect;
|
||||
@@ -6660,6 +6661,7 @@ void UI_update_text_styles()
|
||||
style->paneltitle.character_weight = weight;
|
||||
style->grouplabel.character_weight = weight;
|
||||
style->widget.character_weight = weight;
|
||||
style->tooltip.character_weight = weight;
|
||||
}
|
||||
|
||||
void UI_exit()
|
||||
|
||||
@@ -89,6 +89,14 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
|
||||
style->widget.shadowalpha = 0.5f;
|
||||
style->widget.shadowcolor = 0.0f;
|
||||
|
||||
style->tooltip.uifont_id = uifont_id;
|
||||
style->tooltip.points = UI_DEFAULT_TOOLTIP_POINTS;
|
||||
style->tooltip.character_weight = 400;
|
||||
style->tooltip.shadow = 1;
|
||||
style->tooltip.shady = -1;
|
||||
style->tooltip.shadowalpha = 0.5f;
|
||||
style->tooltip.shadowcolor = 0.0f;
|
||||
|
||||
style->columnspace = 8;
|
||||
style->templatespace = 5;
|
||||
style->boxspace = 5;
|
||||
@@ -319,6 +327,8 @@ const uiStyle *UI_style_get_dpi()
|
||||
_style.grouplabel.shady = short(UI_SCALE_FAC * _style.grouplabel.shady);
|
||||
_style.widget.shadx = short(UI_SCALE_FAC * _style.widget.shadx);
|
||||
_style.widget.shady = short(UI_SCALE_FAC * _style.widget.shady);
|
||||
_style.tooltip.shadx = short(UI_SCALE_FAC * _style.tooltip.shadx);
|
||||
_style.tooltip.shady = short(UI_SCALE_FAC * _style.tooltip.shady);
|
||||
|
||||
_style.columnspace = short(UI_SCALE_FAC * _style.columnspace);
|
||||
_style.templatespace = short(UI_SCALE_FAC * _style.templatespace);
|
||||
|
||||
@@ -1059,7 +1059,7 @@ static uiTooltipData *ui_tooltip_data_from_button_or_extra_icon(bContext *C,
|
||||
const std::string hsva_st = fmt::format(
|
||||
"{}: {:.3f} {:.3f} {:.3f} {:.3f}", TIP_("HSVA"), hsva[0], hsva[1], hsva[2], hsva[3]);
|
||||
|
||||
const uiFontStyle *fs = UI_FSTYLE_WIDGET;
|
||||
const uiFontStyle *fs = &UI_style_get()->tooltip;
|
||||
BLF_size(blf_mono_font, fs->points * UI_SCALE_FAC);
|
||||
float w = BLF_width(blf_mono_font, hsva_st.c_str(), hsva_st.size());
|
||||
|
||||
@@ -1234,7 +1234,7 @@ static ARegion *ui_tooltip_create_with_data(bContext *C,
|
||||
region->type = &type;
|
||||
|
||||
/* Set font, get bounding-box. */
|
||||
data->fstyle = style->widget; /* copy struct */
|
||||
data->fstyle = style->tooltip; /* copy struct */
|
||||
|
||||
UI_fontstyle_set(&data->fstyle);
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ typedef struct uiStyle {
|
||||
uiFontStyle paneltitle;
|
||||
uiFontStyle grouplabel;
|
||||
uiFontStyle widget;
|
||||
uiFontStyle tooltip;
|
||||
|
||||
float panelzoom;
|
||||
|
||||
|
||||
@@ -1527,6 +1527,13 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna)
|
||||
RNA_def_property_struct_type(prop, "ThemeFontStyle");
|
||||
RNA_def_property_ui_text(prop, "Widget Style", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
prop = RNA_def_property(srna, "tooltip", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "tooltip");
|
||||
RNA_def_property_struct_type(prop, "ThemeFontStyle");
|
||||
RNA_def_property_ui_text(prop, "Tooltip Style", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
}
|
||||
|
||||
static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna)
|
||||
|
||||
Reference in New Issue
Block a user