From b239ba0b844c6b09163048e062d98e26dad0997c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 24 Nov 2012 17:12:29 +0100 Subject: [PATCH] filebrowser: make size, time and mode fields scale with fontsize --- src/gui/filebrowser.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index d69a8757b..180bbd25b 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -1233,7 +1233,7 @@ void CFileBrowser::hide() void CFileBrowser::paintItem(unsigned int pos) { - int colwidth1, colwidth2, colwidth3, colwidth1_dir, colwidth2_dir; + int colwidth1, colwidth2, colwidth3; int c_rad_small; uint8_t color; fb_pixel_t bgcolor; @@ -1241,9 +1241,6 @@ void CFileBrowser::paintItem(unsigned int pos) CFile * actual_file = NULL; std::string fileicon; - colwidth2_dir = 180; - colwidth1_dir = width - 35 - colwidth2_dir - 10; - if (liststart + pos == selected) { color = COL_MENUCONTENTSELECTED; @@ -1271,15 +1268,10 @@ void CFileBrowser::paintItem(unsigned int pos) } if (g_settings.filebrowser_showrights == 0 && S_ISREG(actual_file->Mode)) - { colwidth2 = 0; - colwidth3 = 90; - } else - { - colwidth2 = 90; - colwidth3 = 90; - } + colwidth2 = fnt_item->getRenderWidth("rwxrwxrwx"); + colwidth3 = fnt_item->getRenderWidth("222.222G"); colwidth1 = width - 35 - colwidth2 - colwidth3 - 10; if ( actual_file->Name.length() > 0 ) @@ -1325,7 +1317,7 @@ void CFileBrowser::paintItem(unsigned int pos) } modestring[9] = 0; - fnt_item->RenderString(x + 35 + colwidth1 , ypos+ fheight, colwidth2 - 10, modestring, color, 0, true); // UTF-8 + fnt_item->RenderString(x + width - 25 - colwidth3 - colwidth2 , ypos+ fheight, colwidth2, modestring, color, 0, true); // UTF-8 } #define GIGABYTE 1073741824LL @@ -1358,18 +1350,20 @@ void CFileBrowser::paintItem(unsigned int pos) else snprintf(tmpstr,sizeof(tmpstr),"%d", (int)actual_file->Size); - fnt_item->RenderString(x + 35 + colwidth1 + colwidth2, ypos+ fheight, colwidth3 - 10, tmpstr, color); + /* right align file size */ + int sz_w = fnt_item->getRenderWidth(tmpstr); + fnt_item->RenderString(x + width - sz_w - 25, ypos+ fheight, sz_w, tmpstr, color); } if( S_ISDIR(actual_file->Mode) ) { char timestring[18]; time_t rawtime; - rawtime = actual_file->Time; strftime(timestring, 18, "%d-%m-%Y %H:%M", gmtime(&rawtime)); - - fnt_item->RenderString(x + 35 + colwidth1_dir, ypos+ fheight, colwidth2_dir - 10, timestring, color); + /* right align directory time */ + int time_w = fnt_item->getRenderWidth(timestring); + fnt_item->RenderString(x + width - time_w - 25, ypos+ fheight, time_w, timestring, color); } } }