Fix a few DPI / retina draw issues:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 10 Feb 2013 18:03:01 +0000 (18:03 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sun, 10 Feb 2013 18:03:01 +0000 (18:03 +0000)
* Color picker cursor was too small, and color cirle was not smooth enough.
* Border select gesture cross before first click did not reach to the border
  of the window.
* Buttons were not drawing emboss properly (also for non-retina actually).
  Note it doesn't draw entirely right for aligned buttons, but this was also
  the case before it got broken.

source/blender/editors/interface/interface_widgets.c
source/blender/editors/space_buttons/buttons_header.c
source/blender/windowmanager/intern/wm_gesture.c

index 142ea51..6735c8b 100644 (file)
@@ -646,8 +646,8 @@ static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert
        for (a = 0; a < totvert; a++) {
                quad_strip[a * 2][0] = wtb->outer_v[a][0];
                quad_strip[a * 2][1] = wtb->outer_v[a][1];
-               quad_strip[a * 2 + 1][0] = wtb->inner_v[a][0];
-               quad_strip[a * 2 + 1][1] = wtb->inner_v[a][1];
+               quad_strip[a * 2 + 1][0] = wtb->outer_v[a][0];
+               quad_strip[a * 2 + 1][1] = wtb->outer_v[a][1] - 1.0f;
        }
 }
 
@@ -1900,12 +1900,12 @@ static void ui_hsv_cursor(float x, float y)
        glTranslatef(x, y, 0.0f);
        
        glColor3f(1.0f, 1.0f, 1.0f);
-       glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f, 8);
+       glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f * U.pixelsize, 8);
        
        glEnable(GL_BLEND);
        glEnable(GL_LINE_SMOOTH);
        glColor3f(0.0f, 0.0f, 0.0f);
-       glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f, 12);
+       glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f * U.pixelsize, 12);
        glDisable(GL_BLEND);
        glDisable(GL_LINE_SMOOTH);
        
@@ -1929,7 +1929,7 @@ void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rec
 
 static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
 {
-       const int tot = 32;
+       const int tot = 64;
        const float radstep = 2.0f * (float)M_PI / (float)tot;
 
        const float centx = BLI_rcti_cent_x_fl(rect);
index ebba7d9..701048c 100644 (file)
@@ -97,14 +97,15 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event)
        sbuts->mainbuser = sbuts->mainb;
 }
 
-#define BUT_UNIT_X (UI_UNIT_X + 2)
+#define BUT_UNIT_X (UI_UNIT_X + 2*U.pixelsize)
 
 void buttons_header_buttons(const bContext *C, ARegion *ar)
 {
        SpaceButs *sbuts = CTX_wm_space_buts(C);
        uiBlock *block;
        uiBut *but;
-       int xco, yco = 2;
+       int headery = ED_area_headersize();
+       int xco, yco = 0.5f*(headery - UI_UNIT_Y);
 
        buttons_context_compute(C, sbuts);
        
index 168c231..302bf61 100644 (file)
@@ -309,17 +309,19 @@ static void wm_gesture_draw_lasso(wmGesture *gt)
 static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
 {
        rcti *rect = (rcti *)gt->customdata;
-       
+       int winsizex = WM_window_pixels_x(win);
+       int winsizey = WM_window_pixels_y(win);
+
        glEnable(GL_LINE_STIPPLE);
        glColor3ub(96, 96, 96);
        glLineStipple(1, 0xCCCC);
-       sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin);
-       sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey);
+       sdrawline(rect->xmin - winsizex, rect->ymin, rect->xmin + winsizex, rect->ymin);
+       sdrawline(rect->xmin, rect->ymin - winsizey, rect->xmin, rect->ymin + winsizey);
        
        glColor3ub(255, 255, 255);
        glLineStipple(1, 0x3333);
-       sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin);
-       sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey);
+       sdrawline(rect->xmin - winsizex, rect->ymin, rect->xmin + winsizex, rect->ymin);
+       sdrawline(rect->xmin, rect->ymin - winsizey, rect->xmin, rect->ymin + winsizey);
        glDisable(GL_LINE_STIPPLE);
 }