From 9aa6698bd055450b358b191e8ef0bbb823af53e4 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 19 Dec 2012 15:44:47 +0000 Subject: UI DPI scaling: Recoded the (2.65.1 version) region scale, which happened on loading files with different saved size windows. Also scaling window itself was affected. Old method: scaled region widths based on area/editor scaling factors. That was leading to too small or too large button regions easily. New method: region width/height now are in DPI control. Much nicer! - On changing dpi, buttons remain visually same widths. - On changing window sizes, the button views and zooms stick to exactly same. Caveat: people who were using Blender with 'extreme' dpi setting, might find the layouts slightly differ. Not sure if this is worth version patching... Todo: overlapping regions that overlap together draw badly. Fix underway. --- source/blender/editors/screen/area.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/screen/area.c') diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index cde94ec46ee..b681416250e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -943,8 +943,9 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT) alignment = RGN_ALIGN_NONE; - /* prefsize, for header we stick to exception */ - prefsizex = ar->sizex > 1 ? ar->sizex : UI_DPI_FAC * ar->type->prefsizex; + /* prefsize, for header we stick to exception (prevent dpi rounding error) */ + prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex); + if (ar->regiontype == RGN_TYPE_HEADER) { prefsizey = ED_area_headersize(); } @@ -952,7 +953,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2); } else { - prefsizey = ar->sizey > 1 ? ar->sizey : UI_DPI_FAC * ar->type->prefsizey; + prefsizey = UI_DPI_FAC * (ar->sizey > 1 ? ar->sizey + 0.5f : ar->type->prefsizey); } @@ -1092,8 +1093,9 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; /* if region opened normally, we store this for hide/reveal usage */ - if (ar->winx > 1) ar->sizex = ar->winx; - if (ar->winy > 1) ar->sizey = ar->winy; + /* prevent rounding errors for UI_DPI_FAC mult and divide */ + if (ar->winx > 1) ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC; + if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC; /* exception for multiple aligned overlapping regions on same spot */ if (ar->overlap) -- cgit v1.2.3