implement #423 - sort order indicators in file dialog

This commit is contained in:
Vadim Lopatin 2017-09-08 10:07:03 +03:00
parent b22b951af8
commit 31d6a09990
4 changed files with 98 additions and 56 deletions

View File

@ -279,6 +279,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
if (currentRow >= 0 && currentRow < _entries.length) {
selectedItemPath = _entries[currentRow].name;
}
updateColumnHeaders();
sortEntries();
entriesToCells(selectedItemPath);
requestLayout();
@ -769,9 +770,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
_fileList.fullRowOnTop(false);
_fileList.resize(4, 3);
_fileList.setColTitle(0, " "d);
_fileList.setColTitle(1, UIString.fromId("COL_NAME"c).value);
_fileList.setColTitle(2, UIString.fromId("COL_SIZE"c).value);
_fileList.setColTitle(3, UIString.fromId("COL_MODIFIED"c).value);
updateColumnHeaders();
_fileList.showRowHeaders = false;
_fileList.rowSelect = true;
_fileList.multiSelect = _allowMultipleFiles;
@ -817,6 +816,21 @@ class FileDialog : Dialog, CustomGridCellAdapter {
}
/// get sort order suffix for column title
protected dstring appendSortOrderSuffix(dstring columnName, FileListSortOrder arrowUp, FileListSortOrder arrowDown) {
if (_sortOrder == arrowUp)
return columnName ~ " ▲";
if (_sortOrder == arrowDown)
return columnName ~ " ▼";
return columnName;
}
protected void updateColumnHeaders() {
_fileList.setColTitle(1, appendSortOrderSuffix(UIString.fromId("COL_NAME"c).value, FileListSortOrder.NAME_DESC, FileListSortOrder.NAME));
_fileList.setColTitle(2, appendSortOrderSuffix(UIString.fromId("COL_SIZE"c).value, FileListSortOrder.SIZE_DESC, FileListSortOrder.SIZE));
_fileList.setColTitle(3, appendSortOrderSuffix(UIString.fromId("COL_MODIFIED"c).value, FileListSortOrder.TIMESTAMP_DESC, FileListSortOrder.TIMESTAMP));
}
protected void onHeaderCellClicked(GridWidgetBase source, int col, int row) {
debug Log.d("onHeaderCellClicked col=", col, " row=", row);
if (row == 0 && col >= 2 && col <= 4) {

View File

@ -926,5 +926,66 @@ private:
double _gamma = 1.0;
}
/// find some suitable replacement for important characters missing in font
dchar getReplacementChar(dchar code) {
switch (code) {
case UNICODE_SOFT_HYPHEN_CODE:
return '-';
case 0x0401: // CYRILLIC CAPITAL LETTER IO
return 0x0415; //CYRILLIC CAPITAL LETTER IE
case 0x0451: // CYRILLIC SMALL LETTER IO
return 0x0435; // CYRILLIC SMALL LETTER IE
case UNICODE_NO_BREAK_SPACE:
return ' ';
case 0x2010:
case 0x2011:
case 0x2012:
case 0x2013:
case 0x2014:
case 0x2015:
return '-';
case 0x2018:
case 0x2019:
case 0x201a:
case 0x201b:
return '\'';
case 0x201c:
case 0x201d:
case 0x201e:
case 0x201f:
case 0x00ab:
case 0x00bb:
return '\"';
case 0x2039:
return '<';
case 0x203A:
case '‣':
case '►':
return '>';
case 0x2044:
return '/';
case 0x2022: // css_lst_disc:
return '*';
case 0x26AA: // css_lst_disc:
case 0x25E6: // css_lst_disc:
case 0x25CF: // css_lst_disc:
return 'o';
case 0x25CB: // css_lst_circle:
return '*';
case 0x25A0: // css_lst_square:
return '-';
case '↑': //
return '▲';
case '↓': //
return '▼';
case '▲': //
return '^';
case '▼': //
return 'v';
default:
return 0;
}
}
__gshared glyph_gamma_table!65 _gamma65;
__gshared glyph_gamma_table!256 _gamma256;

View File

@ -195,58 +195,6 @@ class FreeTypeFontFile {
return true; // successfully opened
}
/// find some suitable replacement for important characters missing in font
static dchar getReplacementChar(dchar code) {
switch (code) {
case UNICODE_SOFT_HYPHEN_CODE:
return '-';
case 0x0401: // CYRILLIC CAPITAL LETTER IO
return 0x0415; //CYRILLIC CAPITAL LETTER IE
case 0x0451: // CYRILLIC SMALL LETTER IO
return 0x0435; // CYRILLIC SMALL LETTER IE
case UNICODE_NO_BREAK_SPACE:
return ' ';
case 0x2010:
case 0x2011:
case 0x2012:
case 0x2013:
case 0x2014:
case 0x2015:
return '-';
case 0x2018:
case 0x2019:
case 0x201a:
case 0x201b:
return '\'';
case 0x201c:
case 0x201d:
case 0x201e:
case 0x201f:
case 0x00ab:
case 0x00bb:
return '\"';
case 0x2039:
return '<';
case 0x203A:
case '‣':
case '►':
return '>';
case 0x2044:
return '/';
case 0x2022: // css_lst_disc:
return '*';
case 0x26AA: // css_lst_disc:
case 0x25E6: // css_lst_disc:
case 0x25CF: // css_lst_disc:
return 'o';
case 0x25CB: // css_lst_circle:
return '*';
case 0x25A0: // css_lst_square:
return '-';
default:
return 0;
}
}
/// find glyph index for character
FT_UInt getCharIndex(dchar code, dchar def_char = 0) {
@ -255,8 +203,15 @@ class FreeTypeFontFile {
FT_UInt ch_glyph_index = FT_Get_Char_Index(_face, code);
if (ch_glyph_index == 0) {
dchar replacement = getReplacementChar(code);
if (replacement)
if (replacement) {
ch_glyph_index = FT_Get_Char_Index(_face, replacement);
if (ch_glyph_index == 0) {
dchar replacement = getReplacementChar(replacement);
if (replacement) {
ch_glyph_index = FT_Get_Char_Index(_face, replacement);
}
}
}
if (ch_glyph_index == 0 && def_char)
ch_glyph_index = FT_Get_Char_Index( _face, def_char );
}

View File

@ -270,6 +270,18 @@ class Win32Font : Font {
if (found !is null)
return found;
uint glyphIndex = getGlyphIndex(ch);
if (!glyphIndex) {
ch = getReplacementChar(ch);
if (!ch)
return null;
glyphIndex = getGlyphIndex(ch);
if (!glyphIndex) {
ch = getReplacementChar(ch);
if (!ch)
return null;
glyphIndex = getGlyphIndex(ch);
}
}
if (!glyphIndex)
return null;
if (glyphIndex >= 0xFFFF)