diff options
author | Ton Roosendaal <ton@blender.org> | 2012-12-19 19:44:47 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2012-12-19 19:44:47 +0400 |
commit | 9aa6698bd055450b358b191e8ef0bbb823af53e4 (patch) | |
tree | 94524a02ee3668956620da8144a1fd8ba9feb061 /source/blender/editors/screen/area.c | |
parent | cc23d4cd3eb6b98c87f53933510edc53c1513223 (diff) |
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.
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 12 |
1 files changed, 7 insertions, 5 deletions
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) |