fix console theme and drawing

This commit is contained in:
Vadim Lopatin 2016-09-08 22:37:55 +03:00
parent 7df1155322
commit 6cde450fee
5 changed files with 51 additions and 27 deletions

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{002A2DE9-8BB6-484D-9802-7E4AD4084715}") = "dlangui", "dlangui-msvc.visualdproj", "{52A2ABB9-2CF7-4D5F-AE8C-75B21F8585A5}"
EndProject
@ -163,10 +163,10 @@ Global
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|Win32.Build.0 = Release|Win32
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|x64.ActiveCfg = Release|x64
{954B6A84-1EEC-42B0-B215-2A17842B1101}.Unittest|x64.Build.0 = Release|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|Win32.ActiveCfg = ConsoleDebug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|Win32.Build.0 = ConsoleDebug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|x64.ActiveCfg = ConsoleDebug|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|x64.Build.0 = ConsoleDebug|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|Win32.ActiveCfg = Debug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|Win32.Build.0 = Debug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|x64.ActiveCfg = Debug|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.ConsoleDebug|x64.Build.0 = Debug|x64
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Debug|Win32.ActiveCfg = Debug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Debug|Win32.Build.0 = Debug|Win32
{DA4E9F22-21EB-4A71-AF1F-3B5BC370CBA0}.Debug|x64.ActiveCfg = Debug|x64

View File

@ -85,14 +85,18 @@ struct FileFilterEntry {
}
}
version (Windows) {
static if (BACKEND_SDL) {
__gshared bool SHOW_FILE_DIALOG_IN_POPUP = false;
static if (BACKEND_CONSOLE) {
__gshared bool SHOW_FILE_DIALOG_IN_POPUP = true;
} else {
version (Windows) {
static if (BACKEND_SDL) {
__gshared bool SHOW_FILE_DIALOG_IN_POPUP = false;
} else {
__gshared bool SHOW_FILE_DIALOG_IN_POPUP = false;
}
} else {
__gshared bool SHOW_FILE_DIALOG_IN_POPUP = false;
}
} else {
__gshared bool SHOW_FILE_DIALOG_IN_POPUP = false;
}
/// File open / save dialog
@ -314,6 +318,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
WidgetListAdapter adapter = new WidgetListAdapter();
foreach(ref RootEntry root; _roots) {
ImageTextButton btn = new ImageTextButton(null, root.icon, root.label);
static if (BACKEND_CONSOLE) btn.margins = Rect(1, 1, 0, 0);
btn.orientation = Orientation.Vertical;
btn.styleId = STYLE_TRANSPARENT_BUTTON_BACKGROUND;
btn.focusable = false;
@ -433,7 +438,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
override void initialize() {
_roots = getRootPaths() ~ getBookmarkPaths();
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).minWidth(600);
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).minWidth(BACKEND_CONSOLE ? 50 : 600);
//minHeight = 400;
LinearLayout content = new HorizontalLayout("dlgcontent");
@ -442,7 +447,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
leftPanel = new VerticalLayout("places");
leftPanel.addChild(createRootsList());
leftPanel.layoutHeight(FILL_PARENT).minWidth(40);
leftPanel.layoutHeight(FILL_PARENT).minWidth(BACKEND_CONSOLE ? 7 : 40);
rightPanel = new VerticalLayout("main");
rightPanel.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT);
@ -659,6 +664,8 @@ class FilePathPanelButtons : WidgetGroupDefaultDrawing {
int reservedForEmptySpace = parentWidth / 20;
if (reservedForEmptySpace > 40)
reservedForEmptySpace = 40;
if (reservedForEmptySpace < 4)
reservedForEmptySpace = 4;
Point sz;
sz.x += reservedForEmptySpace;
@ -694,6 +701,8 @@ class FilePathPanelButtons : WidgetGroupDefaultDrawing {
int reservedForEmptySpace = rc.width / 20;
if (reservedForEmptySpace > 40)
reservedForEmptySpace = 40;
if (reservedForEmptySpace < 4)
reservedForEmptySpace = 4;
int maxw = rc.width - reservedForEmptySpace;
int totalw = 0;
int visibleItems = 0;
@ -813,7 +822,7 @@ class FileNameEditLine : HorizontalLayout {
this(string ID = null) {
super(ID);
_edFileName = new EditLine("FileNameEditLine_edFileName");
_edFileName.minWidth(200);
_edFileName.minWidth(BACKEND_CONSOLE ? 16 : 200);
_btn = new Button("FileNameEditLine_btnFile", "..."d);
_btn.styleId = STYLE_BUTTON_NOMARGINS;
_btn.layoutWeight = 0;

View File

@ -1155,7 +1155,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
protected Point measureCell(int x, int y) {
// override it!
return Point(80, 20);
return Point(BACKEND_CONSOLE ? 5 : 80, BACKEND_CONSOLE ? 1 : 20);
}
protected int measureColWidth(int x) {
@ -1165,8 +1165,10 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
if (m < sz.x)
m = sz.x;
}
if (m < 10)
m = 10; // TODO: use min size
static if (BACKEND_GUI) {
if (m < 10)
m = 10; // TODO: use min size
}
return m;
}
@ -1177,13 +1179,15 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
if (m < sz.y)
m = sz.y;
}
if (m < 12)
m = 12; // TODO: use min size
static if (BACKEND_GUI) {
if (m < 12)
m = 12; // TODO: use min size
}
return m;
}
void autoFitColumnWidth(int i) {
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + 5;
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (BACKEND_CONSOLE ? 1 : 5);
}
/// extend specified column width to fit client area if grid width
@ -1204,7 +1208,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
}
void autoFitRowHeight(int i) {
_rowHeights[i] = (i < _headerRows && !_showColHeaders) ? 0 : measureRowHeight(i) + 2;
_rowHeights[i] = (i < _headerRows && !_showColHeaders) ? 0 : measureRowHeight(i) + (BACKEND_CONSOLE ? 0 : 2);
}
void autoFitRowHeights() {
@ -1221,8 +1225,9 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
super(ID, hscrollbarMode, vscrollbarMode);
_headerCols = 1;
_headerRows = 1;
_defRowHeight = pointsToPixels(16);
_defColumnWidth = 100;
_defRowHeight = BACKEND_CONSOLE ? 1 : pointsToPixels(16);
_defColumnWidth = BACKEND_CONSOLE ? 5 : 100;
_showColHeaders = true;
_showRowHeaders = true;
acceleratorMap.add( [
@ -1375,19 +1380,26 @@ class StringGridWidget : StringGridWidgetBase {
if (_customCellAdapter && _customCellAdapter.isCustomCell(col, row)) {
return _customCellAdapter.drawCell(buf, rc, col, row);
}
rc.shrink(2, 1);
if (BACKEND_GUI)
rc.shrink(2, 1);
else
rc.right--;
FontRef fnt = font;
dstring txt = cellText(col, row);
Point sz = fnt.textSize(txt);
Align ha = Align.Left;
//if (sz.y < rc.height)
// applyAlign(rc, sz, ha, Align.VCenter);
fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, textColor);
int offset = BACKEND_CONSOLE ? 0 : 1;
fnt.drawText(buf, rc.left + offset, rc.top + offset, txt, textColor);
}
/// draw cell content
protected override void drawHeaderCell(DrawBuf buf, Rect rc, int col, int row) {
rc.shrink(2, 1);
if (BACKEND_GUI)
rc.shrink(2, 1);
else
rc.right--;
FontRef fnt = font;
dstring txt;
if (row < 0 && col >= 0)
@ -1403,7 +1415,8 @@ class StringGridWidget : StringGridWidgetBase {
if (row < 0)
ha = Align.HCenter;
applyAlign(rc, sz, ha, Align.VCenter);
fnt.drawText(buf, rc.left + 1, rc.top + 1, txt, textColor);
int offset = BACKEND_CONSOLE ? 0 : 1;
fnt.drawText(buf, rc.left + offset, rc.top + offset, txt, textColor);
}
/// draw cell background

View File

@ -1,3 +1,5 @@
res/i18n/std_en.ini
res/i18n/std_ru.ini
res/console_theme_default.xml
res/scrollbar_btn_left.tim
res/scrollbar_btn_right.tim

View File

@ -370,7 +370,7 @@
margins="0,0,0,0"
/>
<style id="FLOATING_WINDOW"
backgroundImageId="popup_window_background"
backgroundImageId="{'╔═╗' '║ ║' '╚═╝' bc 0x000000 tc 0xC0C0C0 ninepatch 1 1 1 1 padding 2 2 2 2}"
layoutWidth="FILL_PARENT"
layoutHeight="FILL_PARENT"
padding="0,0,0,0"