DPI: add back option to control line width, tweak default width.
Adds thin/default/thick modes to add -1/0/1 to the auto detected line width, while leaving the overall UI scale unchanged. Also tweaks the default line width threshold, so thicker lines start from slightly high UI scales. Differential Revision: https://developer.blender.org/D2778
This commit is contained in:
parent
e786ea6419
commit
017b7ee273
|
@ -218,6 +218,7 @@ class USERPREF_PT_interface(Panel):
|
|||
col = row.column()
|
||||
col.label(text="Display:")
|
||||
col.prop(view, "ui_scale", text="Scale")
|
||||
col.prop(view, "ui_line_width", text="Line Width")
|
||||
col.prop(view, "show_tooltips")
|
||||
col.prop(view, "show_tooltips_python")
|
||||
col.prop(view, "show_object_info", text="Object Info")
|
||||
|
|
|
@ -473,7 +473,7 @@ typedef struct UserDef {
|
|||
int scrollback; /* console scrollback limit */
|
||||
int dpi; /* range 48-128? */
|
||||
float ui_scale; /* interface scale */
|
||||
int pad1;
|
||||
int ui_line_width; /* interface line width */
|
||||
char node_margin; /* node insert offset (aka auto-offset) margin, but might be useful for later stuff as well */
|
||||
char pad2;
|
||||
short transopts; /* eUserpref_Translation_Flags */
|
||||
|
|
|
@ -3304,6 +3304,13 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
|||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem line_width[] = {
|
||||
{-1, "THIN", 0, "Thin", "Thinner lines than the default"},
|
||||
{ 0, "AUTO", 0, "Auto", "Automatic line width based on UI scale"},
|
||||
{ 1, "THICK", 0, "Thick", "Thicker lines than the default"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
PropertyRNA *prop;
|
||||
StructRNA *srna;
|
||||
|
||||
|
@ -3321,6 +3328,12 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
|||
RNA_def_property_float_default(prop, 1.0f);
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
|
||||
|
||||
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");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
|
||||
|
||||
/* display */
|
||||
prop = RNA_def_property(srna, "show_tooltips", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_TOOLTIPS);
|
||||
|
|
|
@ -377,12 +377,12 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win)
|
|||
|
||||
void WM_window_set_dpi(wmWindow *win)
|
||||
{
|
||||
int auto_dpi = GHOST_GetDPIHint(win->ghostwin);
|
||||
float auto_dpi = GHOST_GetDPIHint(win->ghostwin);
|
||||
|
||||
/* Clamp auto DPI to 96, since our font/interface drawing does not work well
|
||||
* with lower sizes. The main case we are interested in supporting is higher
|
||||
* DPI. If a smaller UI is desired it is still possible to adjust UI scale. */
|
||||
auto_dpi = MAX2(auto_dpi, 96);
|
||||
auto_dpi = max_ff(auto_dpi, 96.0f);
|
||||
|
||||
/* Lazily init UI scale size, preserving backwards compatibility by
|
||||
* computing UI scale from ratio of previous DPI and auto DPI */
|
||||
|
@ -402,13 +402,16 @@ void WM_window_set_dpi(wmWindow *win)
|
|||
/* Blender's UI drawing assumes DPI 72 as a good default following macOS
|
||||
* while Windows and Linux use DPI 96. GHOST assumes a default 96 so we
|
||||
* remap the DPI to Blender's convention. */
|
||||
auto_dpi *= GHOST_GetNativePixelSize(win->ghostwin);
|
||||
int dpi = auto_dpi * U.ui_scale * (72.0 / 96.0f);
|
||||
|
||||
/* Automatically set larger pixel size for high DPI. */
|
||||
int pixelsize = MAX2(1, dpi / 54);
|
||||
int pixelsize = max_ii(1, (int)(dpi / 64));
|
||||
/* User adjustment for pixel size. */
|
||||
pixelsize = max_ii(1, pixelsize + U.ui_line_width);
|
||||
|
||||
/* Set user preferences globals for drawing, and for forward compatibility. */
|
||||
U.pixelsize = GHOST_GetNativePixelSize(win->ghostwin) * pixelsize;
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue