UI: better widget drawing with thick line width.

When the line width was larger than the UI scale, there was not enough
space for thicker widget outlines to draw properly. Now widgets are made
a little larger to accommodate the thicker outlines.

Differential Revision: https://developer.blender.org/D4368
This commit is contained in:
Harley Acheson
2019-02-21 17:34:48 +01:00
committed by Brecht Van Lommel
parent 86bbadaaee
commit 1de1cedf4c
6 changed files with 17 additions and 11 deletions

View File

@@ -723,7 +723,7 @@ static void ui_item_enum_expand_exec(
if (icon && name[0] && !icon_only)
but = uiDefIconTextButR_prop(block, but_type, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
else if (icon)
but = uiDefIconButR_prop(block, but_type, 0, icon, 0, 0, (is_first) ? itemw : ceilf(itemw - UI_DPI_FAC), h, ptr, prop, -1, 0, value, -1, -1, NULL);
but = uiDefIconButR_prop(block, but_type, 0, icon, 0, 0, (is_first) ? itemw : ceilf(itemw - U.pixelsize), h, ptr, prop, -1, 0, value, -1, -1, NULL);
else
but = uiDefButR_prop(block, but_type, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);

View File

@@ -2504,10 +2504,10 @@ void ED_region_header_init(ARegion *ar)
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
}
/* UI_UNIT_Y is defined as U variable now, depending dpi */
int ED_area_headersize(void)
{
return (int)(HEADERY * UI_DPI_FAC);
/* Accomodate widget and padding. */
return U.widget_unit + (int)(UI_DPI_FAC * HEADER_PADDING_Y);
}
int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback)

View File

@@ -134,10 +134,10 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
0, 0, UI_UNIT_X, UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
TIP_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection"));
uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL,
0, 0, ceilf(UI_UNIT_X - UI_DPI_FAC), UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
0, 0, ceilf(UI_UNIT_X - U.pixelsize), UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
TIP_("Edge select - Shift-Click for multiple modes, Ctrl-Click expands/contracts selection"));
uiDefIconButBitS(block, UI_BTYPE_TOGGLE, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL,
0, 0, ceilf(UI_UNIT_X - UI_DPI_FAC), UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
0, 0, ceilf(UI_UNIT_X - U.pixelsize), UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0,
TIP_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
}
}

View File

@@ -469,9 +469,10 @@ enum {
AREA_FLAG_ACTIONZONES_UPDATE = (1 << 8),
};
#define AREAGRID 4
#define AREAMINX 32
#define HEADERY 26
#define AREAGRID 4
#define AREAMINX 32
#define HEADER_PADDING_Y 6
#define HEADERY (20 + HEADER_PADDING_Y)
/** #bScreen.flag */
enum {

View File

@@ -3713,7 +3713,7 @@ static void rna_def_userdef_view(BlenderRNA *brna)
/* View */
prop = RNA_def_property(srna, "ui_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "UI Scale", "Changes the size of the fonts and buttons in the interface");
RNA_def_property_ui_text(prop, "UI Scale", "Changes the size of the fonts and widgets in the interface");
RNA_def_property_range(prop, 0.25f, 4.0f);
RNA_def_property_ui_range(prop, 0.5f, 2.0f, 1, 2);
RNA_def_property_float_default(prop, 1.0f);
@@ -3722,7 +3722,8 @@ static void rna_def_userdef_view(BlenderRNA *brna)
prop = RNA_def_property(srna, "ui_line_width", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, line_width);
RNA_def_property_ui_text(prop, "UI Line Width",
"Changes the thickness of lines and points in the interface");
"Changes the thickness of widget outlines, lines and points in the interface, "
"for high DPI displays");
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
/* display */

View File

@@ -603,9 +603,13 @@ void WM_window_set_dpi(wmWindow *win)
U.pixelsize = pixelsize;
U.dpi = dpi / pixelsize;
U.virtual_pixel = (pixelsize == 1) ? VIRTUAL_PIXEL_NATIVE : VIRTUAL_PIXEL_DOUBLE;
U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
U.dpi_fac = ((U.pixelsize * (float)U.dpi) / 72.0f);
/* Set user preferences globals for drawing, and for forward compatibility. */
U.widget_unit = (U.pixelsize * U.dpi * 20 + 36) / 72;
/* If line thickness differs from scaling factor then adjustments need to be made */
U.widget_unit += 2 * ((int)U.pixelsize - (int)U.dpi_fac);
/* update font drawing */
BLF_default_dpi(U.pixelsize * U.dpi);
}