diff options
author | Harley Acheson <harley> | 2019-02-21 19:34:48 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-21 20:03:34 +0300 |
commit | 1de1cedf4c2fe3dc460267ea3134f17df508b7d9 (patch) | |
tree | b0d89c5e72b62015f9e40309ff4bd0b8a3271371 /source | |
parent | 86bbadaaee949f39f28436ff65c65ae6b194a3c3 (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 6 |
6 files changed, 17 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index ddf1454d3b7..b0ac22898b6 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -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); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 7c5f13f4f20..b5c7a19b9af 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -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) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index d99681fcd5b..78bda66b8ff 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -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")); } } diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index f67ec090381..e0dca9cd646 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -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 { diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 72f97e7a01f..b12852220a2 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -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 */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 4fc4e391b8a..c432dce0757 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -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); } |