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:
authorCampbell Barton <ideasman42@gmail.com>2011-08-05 14:45:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-05 14:45:32 +0400
commita157112ac5c6465fd8d9518af87ce86a5250eeba (patch)
treea6453aca7729621156b84d7189d97d7ae1cd6aee /source/blender/editors/interface
parentad7ea2f89205dd67b84ec76d70352ad56004293a (diff)
fix for icon scaling with the DPI setting
- icons were scaling by the sqrt(dpi)/8.48528, but infact they only need to be scaled by (dpi/72). - UI_icon_get_width value was being used without multiplying by dpi scale.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_handlers.c2
-rw-r--r--source/blender/editors/interface/interface_icons.c3
-rw-r--r--source/blender/editors/interface/interface_widgets.c15
3 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index c5275ea98b5..b3272a2e3d4 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1290,7 +1290,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
else if(ELEM(but->type, TEX, SEARCH_MENU)) {
startx += 5;
if (but->flag & UI_HAS_ICON)
- startx += 16;
+ startx += UI_DPI_ICON_SIZE;
}
/* mouse dragged outside the widget to the left */
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 3bf2a9ddd02..412c0233c35 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -742,6 +742,7 @@ static DrawInfo *icon_create_drawinfo(void)
return di;
}
+/* note!, returns unscaled by DPI, may need to multiply result by UI_DPI_ICON_FAC */
int UI_icon_get_width(int icon_id)
{
Icon *icon = NULL;
@@ -952,7 +953,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
Icon *icon = NULL;
DrawInfo *di = NULL;
IconImage *iimg;
- float fdraw_size= UI_DPI_FAC*draw_size;
+ float fdraw_size= UI_DPI_ICON_FAC*draw_size;
int w, h;
icon = BKE_icon_get(icon_id);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 25a64994f5c..d235fd0c16a 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -771,7 +771,6 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
/* icons have been standardized... and this call draws in untransformed coordinates */
-#define ICON_HEIGHT UI_DPI_FAC*16.0f
static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect)
{
@@ -791,15 +790,15 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
if(aspect != but->aspect) {
/* prevent scaling up icon in pupmenu */
if (aspect < 1.0f) {
- height= ICON_HEIGHT;
+ height= UI_DPI_ICON_SIZE;
aspect = 1.0f;
}
else
- height= ICON_HEIGHT/aspect;
+ height= UI_DPI_ICON_SIZE/aspect;
}
else
- height= ICON_HEIGHT;
+ height= UI_DPI_ICON_SIZE;
/* calculate blend color */
if ELEM4(but->type, TOG, ROW, TOGN, LISTROW) {
@@ -866,7 +865,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10;
int okwidth= rect->xmax-rect->xmin - border;
- if (but->flag & UI_HAS_ICON) okwidth -= 16;
+ if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
/* need to set this first */
uiStyleFontSet(fstyle);
@@ -1149,7 +1148,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
if (but->flag & UI_HAS_ICON) {
widget_draw_icon(but, but->icon+but->iconadd, 1.0f, rect);
- rect->xmin += UI_icon_get_width(but->icon+but->iconadd);
+ rect->xmin += (int)((float)UI_icon_get_width(but->icon+but->iconadd) * UI_DPI_ICON_FAC);
if(but->editstr || (but->flag & UI_TEXT_LEFT))
rect->xmin += 5;
@@ -3133,7 +3132,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
/* text location offset */
rect->xmin+=5;
- if(iconid) rect->xmin+= ICON_HEIGHT;
+ if(iconid) rect->xmin+= UI_DPI_ICON_SIZE;
/* cut string in 2 parts? */
cpoin= strchr(name, '|');
@@ -3158,7 +3157,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
if(iconid) {
int xs= rect->xmin+4;
- int ys= 1 + (rect->ymin+rect->ymax- ICON_HEIGHT)/2;
+ int ys= 1 + (rect->ymin+rect->ymax- UI_DPI_ICON_SIZE)/2;
glEnable(GL_BLEND);
UI_icon_draw_aspect(xs, ys, iconid, 1.2f, 0.5f); /* XXX scale weak get from fstyle? */
glDisable(GL_BLEND);