UI: Remove "Widget Label" Text Style
This PR removes the "Widget Label" text style, found in Preferences / Themes / Text Style. This results in both labels and the text found in input boxes sharing settings. This results in a slight loss of customization but it isn't that useful to have these things separate and results in code complication and errors. Pull Request: https://projects.blender.org/blender/blender/pulls/122898
This commit is contained in:
committed by
Harley Acheson
parent
cdf66f5711
commit
108b71047a
@@ -1241,11 +1241,6 @@ class USERPREF_PT_theme_text_style(ThemePanel, CenterAlignMixIn, Panel):
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.label(text="Widget Label")
|
||||
self._ui_font_style(layout, style.widget_label)
|
||||
|
||||
layout.separator()
|
||||
|
||||
layout.label(text="Widget")
|
||||
self._ui_font_style(layout, style.widget)
|
||||
|
||||
|
||||
@@ -947,7 +947,6 @@ void blo_do_versions_userdef(UserDef *userdef)
|
||||
LISTBASE_FOREACH (uiStyle *, style, &userdef->uistyles) {
|
||||
style->paneltitle.character_weight = 400;
|
||||
style->grouplabel.character_weight = 400;
|
||||
style->widgetlabel.character_weight = 400;
|
||||
style->widget.character_weight = 400;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static void drw_text_cache_draw_ex(DRWTextStore *dt, ARegion *region)
|
||||
GPU_matrix_push();
|
||||
GPU_matrix_identity_set();
|
||||
|
||||
BLF_default_size(UI_style_get()->widgetlabel.points);
|
||||
BLF_default_size(UI_style_get()->widget.points);
|
||||
const int font_id = BLF_set_default();
|
||||
|
||||
float shadow_color[4] = {0, 0, 0, 0.8f};
|
||||
|
||||
@@ -3424,7 +3424,6 @@ ARegion *UI_tooltip_create_from_search_item_generic(bContext *C,
|
||||
|
||||
/* Typical UI text */
|
||||
#define UI_FSTYLE_WIDGET (const uiFontStyle *)&(UI_style_get()->widget)
|
||||
#define UI_FSTYLE_WIDGET_LABEL (const uiFontStyle *)&(UI_style_get()->widgetlabel)
|
||||
|
||||
/**
|
||||
* Returns the best "UI" precision for given floating value,
|
||||
|
||||
@@ -2044,7 +2044,6 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
/* scale fonts */
|
||||
ui_fontscale(&style.paneltitle.points, block->aspect);
|
||||
ui_fontscale(&style.grouplabel.points, block->aspect);
|
||||
ui_fontscale(&style.widgetlabel.points, block->aspect);
|
||||
ui_fontscale(&style.widget.points, block->aspect);
|
||||
|
||||
/* scale block min/max to rect */
|
||||
@@ -4268,7 +4267,7 @@ static void ui_def_but_rna__menu(bContext *C, uiLayout *layout, void *but_p)
|
||||
const int max_rows = (win->sizey - (4 * row_height)) / row_height;
|
||||
float text_width = 0.0f;
|
||||
|
||||
BLF_size(BLF_default(), UI_style_get()->widgetlabel.points * UI_SCALE_FAC);
|
||||
BLF_size(BLF_default(), UI_style_get()->widget.points * UI_SCALE_FAC);
|
||||
int col_rows = 0;
|
||||
float col_width = 0.0f;
|
||||
|
||||
@@ -6660,7 +6659,6 @@ void UI_update_text_styles()
|
||||
const int weight = BLF_default_weight(0);
|
||||
style->paneltitle.character_weight = weight;
|
||||
style->grouplabel.character_weight = weight;
|
||||
style->widgetlabel.character_weight = weight;
|
||||
style->widget.character_weight = weight;
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,7 +1040,7 @@ static uiBut *ui_item_with_label(uiLayout *layout,
|
||||
* Use a default width for property button(s). */
|
||||
prop_but_width = UI_UNIT_X * 5;
|
||||
w_label = ui_text_icon_width_ex(
|
||||
layout, name, ICON_NONE, ui_text_pad_none, UI_FSTYLE_WIDGET_LABEL);
|
||||
layout, name, ICON_NONE, ui_text_pad_none, UI_FSTYLE_WIDGET);
|
||||
}
|
||||
else {
|
||||
w_label = w_hint / 3;
|
||||
@@ -3268,8 +3268,7 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
|
||||
icon = ICON_BLANK1;
|
||||
}
|
||||
|
||||
const int w = ui_text_icon_width_ex(
|
||||
layout, name, icon, ui_text_pad_none, UI_FSTYLE_WIDGET_LABEL);
|
||||
const int w = ui_text_icon_width_ex(layout, name, icon, ui_text_pad_none, UI_FSTYLE_WIDGET);
|
||||
uiBut *but;
|
||||
if (icon && name[0]) {
|
||||
but = uiDefIconTextBut(
|
||||
@@ -6444,8 +6443,7 @@ uiLayout *uiItemsAlertBox(uiBlock *block, const int size, const eAlertIcon icon)
|
||||
{
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const short icon_size = 64 * UI_SCALE_FAC;
|
||||
const int text_points_max = std::max(style->widget.points, style->widgetlabel.points);
|
||||
const int dialog_width = icon_size + (text_points_max * size * UI_SCALE_FAC);
|
||||
const int dialog_width = icon_size + (style->widget.points * size * UI_SCALE_FAC);
|
||||
return uiItemsAlertBox(block, style, dialog_width, icon, icon_size);
|
||||
}
|
||||
|
||||
|
||||
@@ -1099,7 +1099,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style,
|
||||
const bool region_search_filter_active)
|
||||
{
|
||||
const bool is_subpanel = panel->type->parent != nullptr;
|
||||
const uiFontStyle *fontstyle = (is_subpanel) ? &style->widgetlabel : &style->paneltitle;
|
||||
const uiFontStyle *fontstyle = (is_subpanel) ? &style->widget : &style->paneltitle;
|
||||
|
||||
const int header_height = BLI_rcti_size_y(header_rect);
|
||||
const int scaled_unit = round_fl_to_int(UI_UNIT_X / aspect);
|
||||
|
||||
@@ -81,15 +81,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id
|
||||
style->grouplabel.shadowalpha = 0.5f;
|
||||
style->grouplabel.shadowcolor = 0.0f;
|
||||
|
||||
style->widgetlabel.uifont_id = uifont_id;
|
||||
style->widgetlabel.points = UI_DEFAULT_TEXT_POINTS;
|
||||
style->widgetlabel.character_weight = 400;
|
||||
style->widgetlabel.shadow = 3;
|
||||
style->widgetlabel.shadx = 0;
|
||||
style->widgetlabel.shady = -1;
|
||||
style->widgetlabel.shadowalpha = 0.5f;
|
||||
style->widgetlabel.shadowcolor = 0.0f;
|
||||
|
||||
style->widget.uifont_id = uifont_id;
|
||||
style->widget.points = UI_DEFAULT_TEXT_POINTS;
|
||||
style->widget.character_weight = 400;
|
||||
@@ -326,8 +317,8 @@ const uiStyle *UI_style_get_dpi()
|
||||
_style.paneltitle.shady = short(UI_SCALE_FAC * _style.paneltitle.shady);
|
||||
_style.grouplabel.shadx = short(UI_SCALE_FAC * _style.grouplabel.shadx);
|
||||
_style.grouplabel.shady = short(UI_SCALE_FAC * _style.grouplabel.shady);
|
||||
_style.widgetlabel.shadx = short(UI_SCALE_FAC * _style.widgetlabel.shadx);
|
||||
_style.widgetlabel.shady = short(UI_SCALE_FAC * _style.widgetlabel.shady);
|
||||
_style.widget.shadx = short(UI_SCALE_FAC * _style.widget.shadx);
|
||||
_style.widget.shady = short(UI_SCALE_FAC * _style.widget.shady);
|
||||
|
||||
_style.columnspace = short(UI_SCALE_FAC * _style.columnspace);
|
||||
_style.templatespace = short(UI_SCALE_FAC * _style.templatespace);
|
||||
@@ -422,7 +413,7 @@ void uiStyleInit()
|
||||
|
||||
BLF_cache_flush_set_fn(UI_widgetbase_draw_cache_flush);
|
||||
|
||||
BLF_default_size(style->widgetlabel.points);
|
||||
BLF_default_size(style->widget.points);
|
||||
|
||||
/* XXX, this should be moved into a style,
|
||||
* but for now best only load the monospaced font once. */
|
||||
|
||||
@@ -4807,7 +4807,7 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but,
|
||||
if (but->emboss == UI_EMBOSS_PULLDOWN) {
|
||||
switch (but->type) {
|
||||
case UI_BTYPE_LABEL:
|
||||
widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
|
||||
widget_draw_text_icon(&style->widget, &tui->wcol_menu_back, but, rect);
|
||||
break;
|
||||
case UI_BTYPE_SEPR:
|
||||
break;
|
||||
@@ -4852,7 +4852,6 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but,
|
||||
switch (but->type) {
|
||||
case UI_BTYPE_LABEL:
|
||||
wt = widget_type(UI_WTYPE_LABEL);
|
||||
fstyle = &style->widgetlabel;
|
||||
if (but->drawflag & UI_BUT_BOX_ITEM) {
|
||||
wt->wcol_theme = &tui->wcol_box;
|
||||
wt->state = widget_state;
|
||||
@@ -5051,12 +5050,10 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but,
|
||||
|
||||
case UI_BTYPE_PROGRESS:
|
||||
wt = widget_type(UI_WTYPE_PROGRESS);
|
||||
fstyle = &style->widgetlabel;
|
||||
break;
|
||||
|
||||
case UI_BTYPE_VIEW_ITEM:
|
||||
wt = widget_type(UI_WTYPE_VIEW_ITEM);
|
||||
fstyle = &style->widgetlabel;
|
||||
break;
|
||||
|
||||
case UI_BTYPE_SCROLL:
|
||||
|
||||
@@ -268,9 +268,8 @@ uiPopupBlockHandle *ui_popover_panel_create(bContext *C,
|
||||
const int ui_units_x = (panel_type->ui_units_x == 0) ? UI_POPOVER_WIDTH_UNITS :
|
||||
panel_type->ui_units_x;
|
||||
/* Scale width by changes to Text Style point size. */
|
||||
const int text_points_max = std::max(style->widget.points, style->widgetlabel.points);
|
||||
pup->ui_size_x = ui_units_x * U.widget_unit *
|
||||
(text_points_max / float(UI_DEFAULT_TEXT_POINTS));
|
||||
(style->widget.points / float(UI_DEFAULT_TEXT_POINTS));
|
||||
}
|
||||
|
||||
pup->popover_func = popover_func;
|
||||
|
||||
@@ -6290,8 +6290,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
|
||||
add_v3_uchar_clamped(report_icon_color, brighten_amount);
|
||||
}
|
||||
|
||||
UI_fontstyle_set(&style->widgetlabel);
|
||||
int width = BLF_width(style->widgetlabel.uifont_id, report->message, report->len);
|
||||
UI_fontstyle_set(&style->widget);
|
||||
int width = BLF_width(style->widget.uifont_id, report->message, report->len);
|
||||
width = min_ii(int(rti->widthfac * width), width);
|
||||
width = max_ii(width, 10 * UI_SCALE_FAC);
|
||||
|
||||
@@ -6546,11 +6546,10 @@ void uiTemplateStatusInfo(uiLayout *layout, bContext *C)
|
||||
uiBlock *block = uiLayoutGetBlock(ui_abs);
|
||||
eUIEmbossType previous_emboss = UI_block_emboss_get(block);
|
||||
|
||||
UI_fontstyle_set(&style->widgetlabel);
|
||||
const int width = max_ii(int(BLF_width(style->widgetlabel.uifont_id,
|
||||
warning_message.c_str(),
|
||||
warning_message.size())),
|
||||
int(10 * UI_SCALE_FAC));
|
||||
UI_fontstyle_set(&style->widget);
|
||||
const int width = max_ii(
|
||||
int(BLF_width(style->widget.uifont_id, warning_message.c_str(), warning_message.size())),
|
||||
int(10 * UI_SCALE_FAC));
|
||||
|
||||
UI_block_align_begin(block);
|
||||
|
||||
|
||||
@@ -4049,7 +4049,7 @@ static void frame_node_draw_label(TreeDrawContext &tree_draw_ctx,
|
||||
{
|
||||
const float aspect = snode.runtime->aspect;
|
||||
/* XXX font id is crap design */
|
||||
const int fontid = UI_style_get()->widgetlabel.uifont_id;
|
||||
const int fontid = UI_style_get()->widget.uifont_id;
|
||||
const NodeFrame *data = (const NodeFrame *)node.storage;
|
||||
const float font_size = data->label_size / aspect;
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ using blender::float4;
|
||||
|
||||
#define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
|
||||
|
||||
#define VIEW3D_OVERLAY_LINEHEIGHT (UI_style_get()->widgetlabel.points * UI_SCALE_FAC * 1.6f)
|
||||
#define VIEW3D_OVERLAY_LINEHEIGHT (UI_style_get()->widget.points * UI_SCALE_FAC * 1.6f)
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name General Functions
|
||||
@@ -1496,7 +1496,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *region)
|
||||
int xoffset = rect->xmin + (0.5f * U.widget_unit);
|
||||
int yoffset = rect->ymax - (0.1f * U.widget_unit);
|
||||
|
||||
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET_LABEL;
|
||||
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
|
||||
UI_fontstyle_set(fstyle);
|
||||
BLF_default_size(fstyle->points);
|
||||
BLF_set_default();
|
||||
@@ -1540,7 +1540,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *region)
|
||||
}
|
||||
|
||||
/* Set the size back to the default hard-coded size. Otherwise anyone drawing after this,
|
||||
* without setting explicit size, will draw with widgetlabel size. That is probably ideal,
|
||||
* without setting explicit size, will draw with widget size. That is probably ideal,
|
||||
* but size should be set at the calling site not just carried over from here. */
|
||||
BLF_default_size(UI_DEFAULT_TEXT_POINTS);
|
||||
BLF_disable(font_id, BLF_SHADOW);
|
||||
|
||||
@@ -889,7 +889,7 @@ void ED_region_image_metadata_draw(
|
||||
GPU_matrix_translate_2f(x, y);
|
||||
GPU_matrix_scale_2f(zoomx, zoomy);
|
||||
|
||||
BLF_size(blf_mono_font, style->widgetlabel.points * UI_SCALE_FAC);
|
||||
BLF_size(blf_mono_font, style->widget.points * UI_SCALE_FAC);
|
||||
|
||||
/* *** upper box*** */
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@ typedef struct uiStyle {
|
||||
|
||||
uiFontStyle paneltitle;
|
||||
uiFontStyle grouplabel;
|
||||
uiFontStyle widgetlabel;
|
||||
uiFontStyle widget;
|
||||
|
||||
float panelzoom;
|
||||
|
||||
@@ -276,7 +276,7 @@ static void rna_userdef_theme_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
static void rna_userdef_theme_text_style_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
||||
{
|
||||
const uiStyle *style = UI_style_get();
|
||||
BLF_default_size(style->widgetlabel.points);
|
||||
BLF_default_size(style->widget.points);
|
||||
|
||||
rna_userdef_update(bmain, scene, ptr);
|
||||
}
|
||||
@@ -1521,13 +1521,6 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Panel Title Font", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
prop = RNA_def_property(srna, "widget_label", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "widgetlabel");
|
||||
RNA_def_property_struct_type(prop, "ThemeFontStyle");
|
||||
RNA_def_property_ui_text(prop, "Widget Label Style", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
prop = RNA_def_property(srna, "widget", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
||||
RNA_def_property_pointer_sdna(prop, nullptr, "widget");
|
||||
|
||||
@@ -1729,7 +1729,7 @@ int WM_operator_confirm_ex(bContext *C,
|
||||
|
||||
/* Larger dialog needs a wider minimum width to balance with the big icon. */
|
||||
const float min_width = (message == nullptr) ? 180.0f : 230.0f;
|
||||
data->width = int(min_width * UI_SCALE_FAC * UI_style_get()->widgetlabel.points /
|
||||
data->width = int(min_width * UI_SCALE_FAC * UI_style_get()->widget.points /
|
||||
UI_DEFAULT_TEXT_POINTS);
|
||||
|
||||
data->free_op = true;
|
||||
@@ -1839,7 +1839,7 @@ int WM_operator_props_dialog_popup(bContext *C,
|
||||
{
|
||||
wmOpPopUp *data = MEM_new<wmOpPopUp>(__func__);
|
||||
data->op = op;
|
||||
data->width = int(float(width) * UI_SCALE_FAC * UI_style_get()->widgetlabel.points /
|
||||
data->width = int(float(width) * UI_SCALE_FAC * UI_style_get()->widget.points /
|
||||
UI_DEFAULT_TEXT_POINTS);
|
||||
data->free_op = true; /* If this runs and gets registered we may want not to free it. */
|
||||
data->title = title ? std::move(*title) : WM_operatortype_name(op->type, op->ptr);
|
||||
|
||||
@@ -208,8 +208,7 @@ static uiBlock *wm_block_splash_create(bContext *C, ARegion *region, void * /*ar
|
||||
UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
|
||||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
|
||||
const int text_points_max = std::max(style->widget.points, style->widgetlabel.points);
|
||||
int splash_width = text_points_max * 45 * UI_SCALE_FAC;
|
||||
int splash_width = style->widget.points * 45 * UI_SCALE_FAC;
|
||||
CLAMP_MAX(splash_width, CTX_wm_window(C)->sizex * 0.7f);
|
||||
int splash_height;
|
||||
|
||||
@@ -300,8 +299,7 @@ void WM_OT_splash(wmOperatorType *ot)
|
||||
static uiBlock *wm_block_about_create(bContext *C, ARegion *region, void * /*arg*/)
|
||||
{
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const int text_points_max = std::max(style->widget.points, style->widgetlabel.points);
|
||||
const int dialog_width = text_points_max * 42 * UI_SCALE_FAC;
|
||||
const int dialog_width = style->widget.points * 42 * UI_SCALE_FAC;
|
||||
|
||||
uiBlock *block = UI_block_begin(C, region, "about", UI_EMBOSS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user