[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54505] trunk/blender/source/blender/ editors/space_file: Fix file editor not properly scaling with DPI, this was not implemented yet.

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Feb 12 18:09:02 CET 2013


Revision: 54505
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54505
Author:   blendix
Date:     2013-02-12 17:09:02 +0000 (Tue, 12 Feb 2013)
Log Message:
-----------
Fix file editor not properly scaling with DPI, this was not implemented yet.
Still todo is high resolution file icons as they look a bit pixelated now.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_file/file_draw.c
    trunk/blender/source/blender/editors/space_file/filesel.c

Modified: trunk/blender/source/blender/editors/space_file/file_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_draw.c	2013-02-12 16:04:58 UTC (rev 54504)
+++ trunk/blender/source/blender/editors/space_file/file_draw.c	2013-02-12 17:09:02 UTC (rev 54505)
@@ -335,7 +335,7 @@
 		float scale;
 		int ex, ey;
 		
-		if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) {
+		if ( (imb->x*UI_DPI_FAC > layout->prv_w) || (imb->y*UI_DPI_FAC > layout->prv_h) ) {
 			if (imb->x > imb->y) {
 				scaledx = (float)layout->prv_w;
 				scaledy =  ( (float)imb->y / (float)imb->x) * layout->prv_w;
@@ -348,10 +348,11 @@
 			}
 		}
 		else {
-			scaledx = (float)imb->x;
-			scaledy = (float)imb->y;
-			scale = 1.0;
+			scaledx = (float)imb->x * UI_DPI_FAC;
+			scaledy = (float)imb->y * UI_DPI_FAC;
+			scale = UI_DPI_FAC;
 		}
+
 		ex = (int)scaledx;
 		ey = (int)scaledy;
 		fx = ((float)layout->prv_w - (float)ex) / 2.0f;
@@ -461,8 +462,8 @@
 	int i;
 	short is_icon;
 	short align;
+	int column_space = 0.6f*UI_UNIT_X;
 
-
 	numfiles = filelist_numfiles(files);
 	
 	if (params->display != FILE_IMGDISPLAY) {
@@ -492,7 +493,7 @@
 
 	for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) {
 		ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
-		sx += (int)(v2d->tot.xmin + 2.0f);
+		sx += (int)(v2d->tot.xmin + 0.1f*UI_UNIT_X);
 		sy = (int)(v2d->tot.ymax - sy);
 
 		file = filelist_file(files, i);
@@ -521,13 +522,13 @@
 		}
 		else {
 			file_draw_icon(block, file->path, sx, sy - (UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE);
-			sx += ICON_DEFAULT_WIDTH_SCALE + 4;
+			sx += ICON_DEFAULT_WIDTH_SCALE + 0.2f*UI_UNIT_X;
 		}
 
 		UI_ThemeColor4(TH_TEXT);
 
 		if (file->selflag & EDITING_FILE) {
-			uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 3,
+			uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 0.15*UI_UNIT_X,
 			                      textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, "");
 			uiButSetRenameFunc(but, renamebutton_cb, file);
 			uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */
@@ -543,39 +544,39 @@
 		}
 
 		if (params->display == FILE_SHORTDISPLAY) {
-			sx += (int)layout->column_widths[COLUMN_NAME] + 12;
+			sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
 			if (!(file->type & S_IFDIR)) {
 				file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
-				sx += (int)layout->column_widths[COLUMN_SIZE] + 12;
+				sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
 			}
 		}
 		else if (params->display == FILE_LONGDISPLAY) {
-			sx += (int)layout->column_widths[COLUMN_NAME] + 12;
+			sx += (int)layout->column_widths[COLUMN_NAME] + column_space;
 
 #ifndef WIN32
 			/* rwx rwx rwx */
 			file_draw_string(sx, sy, file->mode1, layout->column_widths[COLUMN_MODE1], layout->tile_h, align); 
-			sx += layout->column_widths[COLUMN_MODE1] + 12;
+			sx += layout->column_widths[COLUMN_MODE1] + column_space;
 
 			file_draw_string(sx, sy, file->mode2, layout->column_widths[COLUMN_MODE2], layout->tile_h, align);
-			sx += layout->column_widths[COLUMN_MODE2] + 12;
+			sx += layout->column_widths[COLUMN_MODE2] + column_space;
 
 			file_draw_string(sx, sy, file->mode3, layout->column_widths[COLUMN_MODE3], layout->tile_h, align);
-			sx += layout->column_widths[COLUMN_MODE3] + 12;
+			sx += layout->column_widths[COLUMN_MODE3] + column_space;
 
 			file_draw_string(sx, sy, file->owner, layout->column_widths[COLUMN_OWNER], layout->tile_h, align);
-			sx += layout->column_widths[COLUMN_OWNER] + 12;
+			sx += layout->column_widths[COLUMN_OWNER] + column_space;
 #endif
 
 			file_draw_string(sx, sy, file->date, layout->column_widths[COLUMN_DATE], layout->tile_h, align);
-			sx += (int)layout->column_widths[COLUMN_DATE] + 12;
+			sx += (int)layout->column_widths[COLUMN_DATE] + column_space;
 
 			file_draw_string(sx, sy, file->time, layout->column_widths[COLUMN_TIME], layout->tile_h, align);
-			sx += (int)layout->column_widths[COLUMN_TIME] + 12;
+			sx += (int)layout->column_widths[COLUMN_TIME] + column_space;
 
 			if (!(file->type & S_IFDIR)) {
 				file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align);
-				sx += (int)layout->column_widths[COLUMN_SIZE] + 12;
+				sx += (int)layout->column_widths[COLUMN_SIZE] + column_space;
 			}
 		}
 	}

Modified: trunk/blender/source/blender/editors/space_file/filesel.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filesel.c	2013-02-12 16:04:58 UTC (rev 54504)
+++ trunk/blender/source/blender/editors/space_file/filesel.c	2013-02-12 17:09:02 UTC (rev 54505)
@@ -500,12 +500,12 @@
 	layout->textheight = textheight;
 
 	if (params->display == FILE_IMGDISPLAY) {
-		layout->prv_w = 96;
-		layout->prv_h = 96;
-		layout->tile_border_x = 6;
-		layout->tile_border_y = 6;
-		layout->prv_border_x = 6;
-		layout->prv_border_y = 6;
+		layout->prv_w = 4.8f*UI_UNIT_X;
+		layout->prv_h = 4.8f*UI_UNIT_Y;
+		layout->tile_border_x = 0.3f*UI_UNIT_X;
+		layout->tile_border_y = 0.3f*UI_UNIT_X;
+		layout->prv_border_x = 0.3f*UI_UNIT_X;
+		layout->prv_border_y = 0.3f*UI_UNIT_Y;
 		layout->tile_w = layout->prv_w + 2 * layout->prv_border_x;
 		layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
 		layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
@@ -520,10 +520,13 @@
 		layout->flag = FILE_LAYOUT_VER;
 	}
 	else {
+		int column_space = 0.6f*UI_UNIT_X;
+		int column_icon_space = 0.2f*UI_UNIT_X;
+
 		layout->prv_w = 0;
 		layout->prv_h = 0;
-		layout->tile_border_x = 8;
-		layout->tile_border_y = 2;
+		layout->tile_border_x = 0.4f*UI_UNIT_X;
+		layout->tile_border_y = 0.1f*UI_UNIT_Y;
 		layout->prv_border_x = 0;
 		layout->prv_border_y = 0;
 		layout->tile_h = textheight * 3 / 2;
@@ -533,22 +536,22 @@
 		column_widths(sfile->files, layout);
 
 		if (params->display == FILE_SHORTDISPLAY) {
-			maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 +
-			         (int)layout->column_widths[COLUMN_NAME] + 12 +
-			         (int)layout->column_widths[COLUMN_SIZE] + 12;
+			maxlen = ICON_DEFAULT_WIDTH_SCALE + column_icon_space +
+			         (int)layout->column_widths[COLUMN_NAME] + column_space +
+			         (int)layout->column_widths[COLUMN_SIZE] + column_space;
 		}
 		else {
-			maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 +
-			         (int)layout->column_widths[COLUMN_NAME] + 12 +
+			maxlen = ICON_DEFAULT_WIDTH_SCALE + column_icon_space +
+			         (int)layout->column_widths[COLUMN_NAME] + column_space +
 #ifndef WIN32
-			         (int)layout->column_widths[COLUMN_MODE1] + 12 +
-			         (int)layout->column_widths[COLUMN_MODE2] + 12 +
-			         (int)layout->column_widths[COLUMN_MODE3] + 12 +
-			         (int)layout->column_widths[COLUMN_OWNER] + 12 +
+			         (int)layout->column_widths[COLUMN_MODE1] + column_space +
+			         (int)layout->column_widths[COLUMN_MODE2] + column_space +
+			         (int)layout->column_widths[COLUMN_MODE3] + column_space +
+			         (int)layout->column_widths[COLUMN_OWNER] + column_space +
 #endif
-			         (int)layout->column_widths[COLUMN_DATE] + 12 +
-			         (int)layout->column_widths[COLUMN_TIME] + 12 +
-			         (int)layout->column_widths[COLUMN_SIZE] + 12;
+			         (int)layout->column_widths[COLUMN_DATE] + column_space +
+			         (int)layout->column_widths[COLUMN_TIME] + column_space +
+			         (int)layout->column_widths[COLUMN_SIZE] + column_space;
 
 		}
 		layout->tile_w = maxlen;




More information about the Bf-blender-cvs mailing list