diff --git a/examples/helloworld/helloworld-msvc.visualdproj b/examples/helloworld/helloworld-msvc.visualdproj index 65bc6735..29eab26d 100644 --- a/examples/helloworld/helloworld-msvc.visualdproj +++ b/examples/helloworld/helloworld-msvc.visualdproj @@ -412,7 +412,7 @@ 0 0 0 - 2 + 1 0 0 0 @@ -441,7 +441,7 @@ 0 0 0 - 1 + 0 0 0 0 @@ -452,7 +452,7 @@ 0 0 0 - 2.043 + 2 0 0 0 @@ -480,7 +480,7 @@ 0 0 - EmbedStandardResources + USE_CONSOLE EmbedStandardResources ForceLogs 0 0 0 @@ -514,7 +514,7 @@ 0 0 0 - 2 + 1 0 0 0 @@ -554,7 +554,7 @@ 0 0 0 - 2.043 + 2 0 0 0 @@ -582,7 +582,7 @@ 0 0 - EmbedStandardResources + USE_CONSOLE 0 0 0 diff --git a/examples/helloworld/src/helloworld.d b/examples/helloworld/src/helloworld.d index 5b6da665..ed2713d9 100644 --- a/examples/helloworld/src/helloworld.d +++ b/examples/helloworld/src/helloworld.d @@ -8,7 +8,7 @@ mixin APP_ENTRY_POINT; extern (C) int UIAppMain(string[] args) { // load theme from file "theme_default.xml" - Platform.instance.uiTheme = "theme_default"; + //Platform.instance.uiTheme = "theme_default"; // create window Log.d("Creating window"); diff --git a/src/dlangui/platforms/console/consoleapp.d b/src/dlangui/platforms/console/consoleapp.d index eb7d1364..e9be2c54 100644 --- a/src/dlangui/platforms/console/consoleapp.d +++ b/src/dlangui/platforms/console/consoleapp.d @@ -386,6 +386,8 @@ extern(C) int DLANGUImain(string[] args) { initResourceManagers(); currentTheme = createDefaultTheme(); + Platform.instance.uiTheme = "theme_default"; + Log.i("Entering UIAppMain: ", args); int result = -1; try { diff --git a/src/dlangui/platforms/console/consolefont.d b/src/dlangui/platforms/console/consolefont.d index 6f9736ce..d5753e3d 100644 --- a/src/dlangui/platforms/console/consolefont.d +++ b/src/dlangui/platforms/console/consolefont.d @@ -147,7 +147,7 @@ class ConsoleFont : Font { int underlineY = y + _baseline + underlineHeight * 2; buf.console.textColor = ConsoleDrawBuf.toConsoleColor(color); buf.console.backgroundColor = CONSOLE_TRANSPARENT_BACKGROUND; - Log.d("drawText: (", x, ',', y, ") '", text, "', color=", buf.console.textColor); + //Log.d("drawText: (", x, ',', y, ") '", text, "', color=", buf.console.textColor); foreach(int i; 0 .. charsMeasured) { dchar ch = text[i]; if (ch == '&' && (textFlags & (TextFlag.UnderlineHotKeys | TextFlag.HotKeys | TextFlag.UnderlineHotKeysWhenAltPressed))) { @@ -156,17 +156,14 @@ class ConsoleFont : Font { continue; // skip '&' in hot key when measuring } int xx = (i > 0) ? _textSizeBuffer[i - 1] : 0; - if (x + xx > clip.right) + if (x + xx >= clip.right) break; - if (x + xx + 255 < clip.left) + if (x + xx < clip.left) continue; // far at left of clipping region if (underline) { - //int xx2 = _textSizeBuffer[i]; // draw underline buf.console.underline = true; - //if (xx2 > xx) - // buf.fillRect(Rect(x + xx, underlineY, x + xx2, underlineY + underlineHeight), color); // turn off underline after hot key if (!(textFlags & TextFlag.Underline)) { underline = false; @@ -177,7 +174,7 @@ class ConsoleFont : Font { if (ch == ' ' || ch == '\t') continue; int gx = x + xx; - if (gx + 1 < clip.left) + if (gx < clip.left) continue; buf.console.setCursor(gx, y); buf.console.writeText(cast(dstring)(text[i .. i + 1])); @@ -198,9 +195,14 @@ class ConsoleFont : Font { * tabOffset = when string is drawn not from left position, use to move tab stops left/right * textFlags = set of TextFlag bit fields ****************************************************************************************/ - override void drawColoredText(DrawBuf buf, int x, int y, const dchar[] text, const CustomCharProps[] charProps, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) { + override void drawColoredText(DrawBuf drawBuf, int x, int y, const dchar[] text, const CustomCharProps[] charProps, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) { if (text.length == 0) return; // nothing to draw - empty text + + import dlangui.platforms.console.consoleapp; + import dlangui.platforms.console.dconsole; + ConsoleDrawBuf buf = cast(ConsoleDrawBuf)drawBuf; + if (_textSizeBuffer.length < text.length) _textSizeBuffer.length = text.length; int charsMeasured = measureText(text, _textSizeBuffer, MAX_WIDTH_UNSPECIFIED, tabSize, tabOffset, textFlags); @@ -214,47 +216,48 @@ class ConsoleFont : Font { bool underline = (customizedTextFlags & TextFlag.Underline) != 0; int underlineHeight = 1; int underlineY = y + _baseline + underlineHeight * 2; + buf.console.backgroundColor = CONSOLE_TRANSPARENT_BACKGROUND; foreach(int i; 0 .. charsMeasured) { dchar ch = text[i]; uint color = i < charProps.length ? charProps[i].color : charProps[$ - 1].color; + buf.console.textColor = ConsoleDrawBuf.toConsoleColor(color); customizedTextFlags = (i < charProps.length ? charProps[i].textFlags : charProps[$ - 1].textFlags) | textFlags; underline = (customizedTextFlags & TextFlag.Underline) != 0; // turn off underline after hot key if (ch == '&' && (textFlags & (TextFlag.UnderlineHotKeys | TextFlag.HotKeys | TextFlag.UnderlineHotKeysWhenAltPressed))) { - if (textFlags & (TextFlag.UnderlineHotKeys | TextFlag.UnderlineHotKeysWhenAltPressed)) - underline = true; // turn ON underline for hot key + // draw underline + buf.console.underline = true; + // turn off underline after hot key + if (!(textFlags & TextFlag.Underline)) { + underline = false; + buf.console.underline = false; + } continue; // skip '&' in hot key when measuring } int xx = (i > 0) ? _textSizeBuffer[i - 1] : 0; - if (x + xx > clip.right) + if (x + xx >= clip.right) break; - if (x + xx + 255 < clip.left) + if (x + xx < clip.left) continue; // far at left of clipping region if (underline) { - int xx2 = _textSizeBuffer[i]; // draw underline - if (xx2 > xx) - buf.fillRect(Rect(x + xx, underlineY, x + xx2, underlineY + underlineHeight), color); + buf.console.underline = true; // turn off underline after hot key - if (!(customizedTextFlags & TextFlag.Underline)) + if (!(customizedTextFlags & TextFlag.Underline)) { underline = false; + buf.console.underline = false; + } } if (ch == ' ' || ch == '\t') continue; - Glyph * glyph = getCharGlyph(ch); - if (glyph is null) + + int gx = x + xx; + if (gx < clip.left) continue; - if ( glyph.blackBoxX && glyph.blackBoxY ) { - int gx = x + xx + glyph.originX; - if (gx + glyph.correctedBlackBoxX < clip.left) - continue; - buf.drawGlyph( gx, - y + _baseline - glyph.originY, - glyph, - color); - } + buf.console.setCursor(gx, y); + buf.console.writeText(cast(dstring)(text[i .. i + 1])); } } diff --git a/src/dlangui/widgets/combobox.d b/src/dlangui/widgets/combobox.d index 135321d3..c9458ab8 100644 --- a/src/dlangui/widgets/combobox.d +++ b/src/dlangui/widgets/combobox.d @@ -90,7 +90,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler { } protected ImageButton createButton() { - ImageButton res = new ImageButton("COMBOBOX_BUTTON", "scrollbar_btn_down"); + ImageButton res = new ImageButton("COMBOBOX_BUTTON", ATTR_SCROLLBAR_BUTTON_DOWN); res.styleId = STYLE_COMBO_BOX_BUTTON; res.layoutWeight = 0; res.click = this; diff --git a/src/dlangui/widgets/tree.d b/src/dlangui/widgets/tree.d index 21bced70..bb3145d9 100644 --- a/src/dlangui/widgets/tree.d +++ b/src/dlangui/widgets/tree.d @@ -608,7 +608,7 @@ class TreeItemWidget : HorizontalLayout { _label = new TextWidget("label", _item.text); _label.styleId = STYLE_TREE_ITEM_LABEL; _label.setState(State.Parent); - _label.padding(Rect(5, 0, 0, 0)); + _label.padding(Rect(BACKEND_GUI ? 5 : 0, 0, 0, 0)); _body.addChild(_label); // append children addChild(_tab); diff --git a/views/console_standard_resources.list b/views/console_standard_resources.list index f920ffd4..2edd332a 100644 --- a/views/console_standard_resources.list +++ b/views/console_standard_resources.list @@ -1,12 +1,6 @@ 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 -res/scrollbar_btn_up.tim -res/scrollbar_btn_down.tim -res/scrollbar_indicator_horizontal.tim -res/scrollbar_indicator_vertical.tim res/btn_check.xml res/btn_check_on.tim res/btn_check_on_pressed.tim diff --git a/views/res/console_theme_default.xml b/views/res/console_theme_default.xml index 533652dc..099c5c19 100644 --- a/views/res/console_theme_default.xml +++ b/views/res/console_theme_default.xml @@ -6,8 +6,8 @@ textColor="#C0C0C0" > - - + + @@ -22,9 +22,9 @@ - + - + @@ -34,6 +34,17 @@ + + + + + + + + + + + - - - @@ -202,11 +191,18 @@ + + + + @@ -496,7 +505,6 @@ diff --git a/views/res/scrollbar_btn_down.tim b/views/res/scrollbar_btn_down.tim deleted file mode 100644 index 215774b7..00000000 --- a/views/res/scrollbar_btn_down.tim +++ /dev/null @@ -1,6 +0,0 @@ -{ - text: [ - "▼" - ], - textColor: [0xFFFF00], -} diff --git a/views/res/scrollbar_btn_left.tim b/views/res/scrollbar_btn_left.tim deleted file mode 100644 index de0988ba..00000000 --- a/views/res/scrollbar_btn_left.tim +++ /dev/null @@ -1,6 +0,0 @@ -{ - text: [ - "◄" - ], - textColor: [0xFFFF00], -} diff --git a/views/res/scrollbar_btn_right.tim b/views/res/scrollbar_btn_right.tim deleted file mode 100644 index 016721c8..00000000 --- a/views/res/scrollbar_btn_right.tim +++ /dev/null @@ -1,6 +0,0 @@ -{ - text: [ - "►" - ], - textColor: [0xFFFF00], -} diff --git a/views/res/scrollbar_btn_up.tim b/views/res/scrollbar_btn_up.tim deleted file mode 100644 index 573f5239..00000000 --- a/views/res/scrollbar_btn_up.tim +++ /dev/null @@ -1,6 +0,0 @@ -{ - text: [ - "▲" - ], - textColor: [0xFFFF00], -} diff --git a/views/res/scrollbar_indicator_horizontal.tim b/views/res/scrollbar_indicator_horizontal.tim deleted file mode 100644 index 7c865a86..00000000 --- a/views/res/scrollbar_indicator_horizontal.tim +++ /dev/null @@ -1,6 +0,0 @@ -{ - text: [ - " " - ], - textColor: [0xFFFF00], -} diff --git a/views/res/scrollbar_indicator_vertical.tim b/views/res/scrollbar_indicator_vertical.tim deleted file mode 100644 index 8b279c44..00000000 --- a/views/res/scrollbar_indicator_vertical.tim +++ /dev/null @@ -1,7 +0,0 @@ -{ - text: [ - " " - ], - textColor: [0xFFFF00], - ninePatch: [0] -}