Revision: 53184
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53184
Author:   ton
Date:     2012-12-19 15:44:47 +0000 (Wed, 19 Dec 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/screen/area.c
    trunk/blender/source/blender/editors/screen/screen_edit.c
    trunk/blender/source/blender/editors/screen/screen_ops.c

Modified: trunk/blender/source/blender/editors/screen/area.c
===================================================================
--- trunk/blender/source/blender/editors/screen/area.c  2012-12-19 15:22:39 UTC 
(rev 53183)
+++ trunk/blender/source/blender/editors/screen/area.c  2012-12-19 15:44:47 UTC 
(rev 53184)
@@ -943,8 +943,9 @@
        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 @@
                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 @@
        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)

Modified: trunk/blender/source/blender/editors/screen/screen_edit.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_edit.c   2012-12-19 
15:22:39 UTC (rev 53183)
+++ trunk/blender/source/blender/editors/screen/screen_edit.c   2012-12-19 
15:44:47 UTC (rev 53184)
@@ -672,30 +672,7 @@
 
                        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... */

Modified: trunk/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- trunk/blender/source/blender/editors/screen/screen_ops.c    2012-12-19 
15:22:39 UTC (rev 53183)
+++ trunk/blender/source/blender/editors/screen/screen_ops.c    2012-12-19 
15:44:47 UTC (rev 53184)
@@ -1759,7 +1759,7 @@
        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 @@
                                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 @@
                                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);
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to