diff --git a/examples/example1/main.d b/examples/example1/main.d index f2295107..89bf572b 100644 --- a/examples/example1/main.d +++ b/examples/example1/main.d @@ -54,7 +54,7 @@ extern (C) int UIAppMain(string[] args) { hlayout.addChild((new TextWidget()).text("in horizontal layout")); hlayout.addChild((new ImageWidget()).drawableId("exit").padding(Rect(5,5,5,5)).alignment(Align.Center)); //hlayout.addChild((new Button()).text(">>")); //.textColor(0x40FF4000) - //hlayout.backgroundColor = 0x8080C0; + hlayout.backgroundColor = 0x8080C0; layout.addChild(hlayout); LinearLayout vlayout = new VerticalLayout(); diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index 82d15d61..13966928 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -9,7 +9,10 @@ private import dlangui.graphics.gldrawbuf; class Window { protected int _dx; protected int _dy; + protected uint _backgroundColor; protected Widget _mainWidget; + @property uint backgroundColor() { return _backgroundColor; } + @property void backgroundColor(uint color) { _backgroundColor = color; } @property int width() { return _dx; } @property int height() { return _dy; } @property Widget mainWidget() { return _mainWidget; } @@ -36,6 +39,10 @@ class Window { long lastDrawTs; + this() { + _backgroundColor = 0xFFFFFF; + } + private void animate(Widget root, long interval) { if (root.visibility != Visibility.Visible) return; diff --git a/src/dlangui/platforms/windows/winapp.d b/src/dlangui/platforms/windows/winapp.d index 495c8342..8a1f0db9 100644 --- a/src/dlangui/platforms/windows/winapp.d +++ b/src/dlangui/platforms/windows/winapp.d @@ -218,7 +218,11 @@ class Win32Window : Window { wglMakeCurrent(hdc, _hGLRC); glDisable(GL_DEPTH_TEST); glViewport(0, 0, _dx, _dy); - glClearColor(0.9f, 0.9f, 0.9f, 1.0f); + float a = 1.0f; + float r = ((_backgroundColor >> 16) & 255) / 255.0f; + float g = ((_backgroundColor >> 8) & 255) / 255.0f; + float b = ((_backgroundColor >> 0) & 255) / 255.0f; + glClearColor(r, g, b, a); glClear(GL_COLOR_BUFFER_BIT); GLDrawBuf buf = new GLDrawBuf(_dx, _dy, false); @@ -296,7 +300,7 @@ class Win32Window : Window { scope(exit) EndPaint(_hwnd, &ps); Win32ColorDrawBuf buf = getDrawBuf(); - buf.fill(0x808080); + buf.fill(_backgroundColor); onDraw(buf); buf.drawTo(hdc, 0, 0); } @@ -318,10 +322,8 @@ class Win32Window : Window { protected ButtonDetails _mbutton; protected ButtonDetails _rbutton; - - - bool _mouseTracking; - bool onMouse(uint message, uint flags, short x, short y) { + private bool _mouseTracking; + private bool onMouse(uint message, uint flags, short x, short y) { Log.d("Win32 Mouse Message ", message, " flags=", flags, " x=", x, " y=", y); MouseButton button = MouseButton.None; MouseAction action = MouseAction.ButtonDown; @@ -437,7 +439,7 @@ class Win32Platform : Platform { wndclass.hInstance = _hInstance; wndclass.hIcon = LoadIcon(null, IDI_APPLICATION); wndclass.hCursor = LoadCursor(null, IDC_ARROW); - wndclass.hbrBackground = null; //cast(HBRUSH)GetStockObject(WHITE_BRUSH); + wndclass.hbrBackground = cast(HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = null; wndclass.lpszClassName = toUTF16z(WIN_CLASS_NAME); diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index 278a36c6..f18b76f4 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -433,7 +433,7 @@ class Theme : Style { this(string id) { super(this, id); _parentStyle = null; - _backgroundColor = 0xE0E0E0; // light gray + _backgroundColor = 0xFFFFFFFF; // transparent _textColor = 0x000000; // black _align = Align.TopLeft; _fontSize = 24; // TODO: from settings or screen properties / DPI