mirror of https://github.com/buggins/dlangui.git
fix console support for progressBar, Switch, Grid, Slider - fix #309
This commit is contained in:
parent
691ba3411f
commit
c26de67d6f
|
@ -421,7 +421,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
// most of controls example
|
// most of controls example
|
||||||
{
|
{
|
||||||
LinearLayout controls = new VerticalLayout("controls");
|
LinearLayout controls = new VerticalLayout("controls");
|
||||||
controls.padding = Rect(5,5,5,5);
|
controls.padding = Rect(12.pointsToPixels,12.pointsToPixels,12.pointsToPixels,12.pointsToPixels);
|
||||||
|
|
||||||
HorizontalLayout line1 = new HorizontalLayout();
|
HorizontalLayout line1 = new HorizontalLayout();
|
||||||
controls.addChild(line1);
|
controls.addChild(line1);
|
||||||
|
@ -522,6 +522,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
grid.setRowTitle(y, to!dstring(y+1));
|
grid.setRowTitle(y, to!dstring(y+1));
|
||||||
//grid.alignment = Align.Right;
|
//grid.alignment = Align.Right;
|
||||||
grid.setColWidth(0, 30.pointsToPixels);
|
grid.setColWidth(0, 30.pointsToPixels);
|
||||||
|
grid.autoFit();
|
||||||
import std.random;
|
import std.random;
|
||||||
import std.string;
|
import std.string;
|
||||||
for (int x = 0; x < 12; x++) {
|
for (int x = 0; x < 12; x++) {
|
||||||
|
|
|
@ -622,6 +622,8 @@ static if (BACKEND_CONSOLE) {
|
||||||
if (srcx < 0 || srcx >= _width || srcy < 0 || srcy >= _height)
|
if (srcx < 0 || srcx >= _width || srcy < 0 || srcy >= _height)
|
||||||
return;
|
return;
|
||||||
int index = srcy * _width + srcx;
|
int index = srcy * _width + srcx;
|
||||||
|
if (_textColors[index].isFullyTransparentColor && _bgColors[index].isFullyTransparentColor)
|
||||||
|
return; // do not draw
|
||||||
buf.drawChar(dstx, dsty, _text[index], _textColors[index], _bgColors[index]);
|
buf.drawChar(dstx, dsty, _text[index], _textColors[index], _bgColors[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,11 +214,14 @@ extern (C) void initLogs() {
|
||||||
static import std.stdio;
|
static import std.stdio;
|
||||||
debug {
|
debug {
|
||||||
Log.setFileLogger(new std.stdio.File("ui.log", "w"));
|
Log.setFileLogger(new std.stdio.File("ui.log", "w"));
|
||||||
|
Log.i("Debug build. Logging to file ui.log");
|
||||||
|
Log.setLogLevel(LogLevel.Trace);
|
||||||
} else {
|
} else {
|
||||||
// no logging unless version ForceLogs is set
|
// no logging unless version ForceLogs is set
|
||||||
version(ForceLogs) {
|
version(ForceLogs) {
|
||||||
Log.setFileLogger(new std.stdio.File("ui.log", "w"));
|
Log.setFileLogger(new std.stdio.File("ui.log", "w"));
|
||||||
Log.i("Logging to file ui.log");
|
Log.i("Logging to file ui.log");
|
||||||
|
//Log.setLogLevel(LogLevel.Trace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -52,6 +52,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.grid;
|
module dlangui.widgets.grid;
|
||||||
|
|
||||||
|
import dlangui.core.config;
|
||||||
import dlangui.widgets.widget;
|
import dlangui.widgets.widget;
|
||||||
import dlangui.widgets.controls;
|
import dlangui.widgets.controls;
|
||||||
import dlangui.widgets.scroll;
|
import dlangui.widgets.scroll;
|
||||||
|
@ -1301,6 +1302,9 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
if (!colVisible(x))
|
if (!colVisible(x))
|
||||||
continue;
|
continue;
|
||||||
Rect cellRect = cellRectScroll(x, y);
|
Rect cellRect = cellRectScroll(x, y);
|
||||||
|
if (BACKEND_CONSOLE && phase == 1) {
|
||||||
|
cellRect.right--;
|
||||||
|
}
|
||||||
Rect clippedCellRect = cellRect;
|
Rect clippedCellRect = cellRect;
|
||||||
if (x >= nscols && cellRect.left < nspixels.x)
|
if (x >= nscols && cellRect.left < nspixels.x)
|
||||||
clippedCellRect.left = nspixels.x; // clip scrolled left
|
clippedCellRect.left = nspixels.x; // clip scrolled left
|
||||||
|
@ -1362,9 +1366,13 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
if (m < sz.x)
|
if (m < sz.x)
|
||||||
m = sz.x;
|
m = sz.x;
|
||||||
}
|
}
|
||||||
|
Log.d("measureColWidth ", x, " = ", m);
|
||||||
static if (BACKEND_GUI) {
|
static if (BACKEND_GUI) {
|
||||||
if (m < 10)
|
if (m < 10)
|
||||||
m = 10; // TODO: use min size
|
m = 10; // TODO: use min size
|
||||||
|
} else {
|
||||||
|
if (m < 3)
|
||||||
|
m = 3; // TODO: use min size
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -1384,7 +1392,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
void autoFitColumnWidth(int i) {
|
void autoFitColumnWidth(int i) {
|
||||||
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (BACKEND_CONSOLE ? 1 : 3.pointsToPixels);
|
_colWidths[i] = (i < _headerCols && !_showRowHeaders) ? 0 : measureColWidth(i) + (BACKEND_CONSOLE ? 3 : 3.pointsToPixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// extend specified column width to fit client area if grid width
|
/// extend specified column width to fit client area if grid width
|
||||||
|
@ -1416,6 +1424,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
void autoFit() {
|
void autoFit() {
|
||||||
autoFitColumnWidths();
|
autoFitColumnWidths();
|
||||||
autoFitRowHeights();
|
autoFitRowHeights();
|
||||||
|
updateCumulativeSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
this(string ID = null, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) {
|
this(string ID = null, ScrollBarMode hscrollbarMode = ScrollBarMode.Visible, ScrollBarMode vscrollbarMode = ScrollBarMode.Visible) {
|
||||||
|
@ -1423,7 +1432,7 @@ class GridWidgetBase : ScrollWidgetBase, GridModelAdapter, MenuItemActionHandler
|
||||||
_headerCols = 1;
|
_headerCols = 1;
|
||||||
_headerRows = 1;
|
_headerRows = 1;
|
||||||
_defRowHeight = BACKEND_CONSOLE ? 1 : pointsToPixels(16);
|
_defRowHeight = BACKEND_CONSOLE ? 1 : pointsToPixels(16);
|
||||||
_defColumnWidth = BACKEND_CONSOLE ? 5 : 100;
|
_defColumnWidth = BACKEND_CONSOLE ? 7 : 100;
|
||||||
|
|
||||||
_showColHeaders = true;
|
_showColHeaders = true;
|
||||||
_showRowHeaders = true;
|
_showRowHeaders = true;
|
||||||
|
|
|
@ -87,9 +87,18 @@
|
||||||
align="Center"
|
align="Center"
|
||||||
/>
|
/>
|
||||||
<style id="SWITCH"
|
<style id="SWITCH"
|
||||||
|
backgroundImageId="{'▄▄▄▄▄ ' ' On ' '▀▀▀▀▀ ' tc 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 0x00FF00 0x00FF00 0x00FF00 0x00FF00 0x00FF00 0x00FF00 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 bc 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF ninepatch 5 1 0 1 padding 5 1 1 1}"
|
||||||
align="Center"
|
align="Center"
|
||||||
backgroundImageId="switch"
|
textFlags="UnderlineHotKeys"
|
||||||
/>
|
textColor="#FFFFFF"
|
||||||
|
margins="0,0,1,0"
|
||||||
|
padding="1,0,1,0"
|
||||||
|
>
|
||||||
|
<state state_enabled="false" state_checked="true" textColor="#C0C0C0" backgroundImageId="{'▄▄▄▄▄ ' ' On ' '▀▀▀▀▀ ' tc 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 0x008000 0x008000 0x008000 0x008000 0x008000 0x008000 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 bc 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0x808080 0x808080 0x808080 0x808080 0x808080 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF ninepatch 5 1 0 1 padding 5 1 1 1}"/>
|
||||||
|
<state state_enabled="false" state_checked="false" textColor="#C0C0C0" backgroundImageId="{'▄▄▄▄▄ ' ' Off ' '▀▀▀▀▀ ' tc 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 0x800000 0x800000 0x800000 0x800000 0x800000 0x800000 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 bc 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0x808080 0x808080 0x808080 0x808080 0x808080 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF ninepatch 5 1 0 1 padding 5 1 1 1}"/>
|
||||||
|
<state state_enabled="true" state_checked="true" textColor="#C0C0C0" backgroundImageId="{'▄▄▄▄▄ ' ' On ' '▀▀▀▀▀ ' tc 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 0x00FF00 0x00FF00 0x00FF00 0x00FF00 0x00FF00 0x00FF00 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 bc 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0x808080 0x808080 0x808080 0x808080 0x808080 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF ninepatch 5 1 0 1 padding 5 1 1 1}"/>
|
||||||
|
<state state_enabled="true" state_checked="false" textColor="#C0C0C0" backgroundImageId="{'▄▄▄▄▄ ' ' Off ' '▀▀▀▀▀ ' tc 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 0xFF0000 0xFF0000 0xFF0000 0xFF0000 0xFF0000 0xFF0000 0x808080 0x808080 0x808080 0x808080 0x808080 0x808080 bc 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0x808080 0x808080 0x808080 0x808080 0x808080 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF ninepatch 5 1 0 1 padding 5 1 1 1}"/>
|
||||||
|
</style>
|
||||||
<style id="CHECKBOX"
|
<style id="CHECKBOX"
|
||||||
backgroundImageId="@null"
|
backgroundImageId="@null"
|
||||||
margins="0,0,0,0"
|
margins="0,0,0,0"
|
||||||
|
@ -169,13 +178,9 @@
|
||||||
backgroundImageId="{'░' 0x808000 stretch}"
|
backgroundImageId="{'░' 0x808000 stretch}"
|
||||||
align="Center"
|
align="Center"
|
||||||
/>
|
/>
|
||||||
<style id="SLIDER"
|
|
||||||
/>
|
|
||||||
<style id="PAGE_SCROLL"
|
<style id="PAGE_SCROLL"
|
||||||
backgroundImageId="{'░' 0x808000 stretch}"
|
backgroundImageId="@null"
|
||||||
>
|
>
|
||||||
<state state_pressed="true" backgroundImageId="{'░' 0x808080 stretch}"/>
|
|
||||||
<state state_hovered="true" backgroundImageId="{'░' 0x808000 stretch}"/>
|
|
||||||
</style>
|
</style>
|
||||||
<style id="TAB_UP_DARK"
|
<style id="TAB_UP_DARK"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
|
@ -533,5 +538,39 @@
|
||||||
<state state_selected="true" backgroundColor="#808080"/>
|
<state state_selected="true" backgroundColor="#808080"/>
|
||||||
<state state_hovered="true" backgroundColor="#808000"/>
|
<state state_hovered="true" backgroundColor="#808000"/>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<style id="GROUP_BOX"
|
||||||
|
textColor="#C0C0C0"
|
||||||
|
minHeight="3"
|
||||||
|
>
|
||||||
|
<drawable id="group_box_frame_up_left" value="{'┌─' 0x808080 bc 0xFFFFFFFF ninepatch 1 0 0 0 padding 0 0 0 0}"/>
|
||||||
|
<drawable id="group_box_frame_up_right" value="{'─┐' 0x808080 bc 0xFFFFFFFF ninepatch 0 0 1 0 padding 0 0 0 0}"/>
|
||||||
|
<drawable id="group_box_frame_bottom" value="{'│ │' '└─┘' 0x808080 0xFFFFFFFF 0x808080 0x808080 0x808080 0x808080 bc 0xFFFFFFFF ninepatch 1 0 1 1 padding 1 0 1 1}"/>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style id="GROUP_BOX_CAPTION"
|
||||||
|
align="Left|VCenter"
|
||||||
|
textColor="#C0C0C0"
|
||||||
|
padding="0,0,0,0">
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style id="PROGRESS_BAR"
|
||||||
|
minWidth="10"
|
||||||
|
minHeight="1"
|
||||||
|
backgroundImageId="{'░' 0x808000 stretch}"
|
||||||
|
>
|
||||||
|
<drawable id="progress_bar_gauge" value="{'■' 0x808080 bc 0x0000FF stretch}"/>
|
||||||
|
<drawable id="progress_bar_gauge_animation" value="@none"/>
|
||||||
|
<drawable id="progress_bar_indeterminate" value="{'░' 0x808000 stretch}"/>
|
||||||
|
<drawable id="progress_bar_indeterminate_animation" value="@none"/>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style id="SLIDER"
|
||||||
|
backgroundImageId="{'═' 0x808080 stretch}"
|
||||||
|
align="Center">
|
||||||
|
<drawable id="scrollbar_indicator_vertical" value="{'■' #000000 bc #FFFF00}"/>
|
||||||
|
<drawable id="scrollbar_indicator_horizontal" value="{'■' #000000 bc #FFFF00}"/>
|
||||||
|
</style>
|
||||||
</theme>
|
</theme>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue