Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2012-12-19 19:44:47 +0400
committerTon Roosendaal <ton@blender.org>2012-12-19 19:44:47 +0400
commit9aa6698bd055450b358b191e8ef0bbb823af53e4 (patch)
tree94524a02ee3668956620da8144a1fd8ba9feb061 /source/blender/editors/screen
parentcc23d4cd3eb6b98c87f53933510edc53c1513223 (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')
-rw-r--r--source/blender/editors/screen/area.c12
-rw-r--r--source/blender/editors/screen/screen_edit.c25
-rw-r--r--source/blender/editors/screen/screen_ops.c8
3 files changed, 15 insertions, 30 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)
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index f71d63e5fef..c827d8c686b 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -672,30 +672,7 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey)
CLAMP(sv->vec.y, 0, winsizey);
}
-
- /* scale prefsizes of regions */
- for (sa = sc->areabase.first; sa; sa = sa->next) {
- ARegion *ar;
-
- for (ar = sa->regionbase.first; ar; ar = ar->next) {
- ar->sizex = (int)((float)ar->sizex * facx);
- ar->sizey = (int)((float)ar->sizey * facy);
- ar->winx = (int)((float)ar->winx * facx);
- ar->winy = (int)((float)ar->winy * facy);
- }
- if (sa->spacedata.first) {
- SpaceLink *sl = sa->spacedata.first;
- for (sl = sl->next; sl; sl = sl->next) {
- for (ar = sl->regionbase.first; ar; ar = ar->next) {
- ar->sizex = (int)((float)ar->sizex * facx);
- ar->sizey = (int)((float)ar->sizey * facy);
- ar->winx = (int)((float)ar->winx * facx);
- ar->winy = (int)((float)ar->winy * facy);
- }
- }
- }
- }
- }
+}
/* test for collapsed areas. This could happen in some blender version... */
/* ton: removed option now, it needs Context... */
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index a26f5e87090..a22faea9eec 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1759,7 +1759,7 @@ static int region_scale_get_maxsize(RegionMoveData *rmd)
int maxsize = 0;
if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) {
- return rmd->sa->winx - UI_UNIT_X;
+ return (int) ( (rmd->sa->winx / UI_DPI_FAC) - UI_UNIT_X);
}
if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) {
@@ -1808,6 +1808,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
delta = event->x - rmd->origx;
if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta;
+ /* region sizes now get multiplied */
+ delta /= UI_DPI_FAC;
+
rmd->ar->sizex = rmd->origval + delta;
CLAMP(rmd->ar->sizex, 0, rmd->maxsize);
@@ -1824,6 +1827,9 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
delta = event->y - rmd->origy;
if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta;
+ /* region sizes now get multiplied */
+ delta /= UI_DPI_FAC;
+
rmd->ar->sizey = rmd->origval + delta;
CLAMP(rmd->ar->sizey, 0, rmd->maxsize);