mirror of https://github.com/buggins/dlangui.git
Implemented #422 - Possibility to set default window icon for new windows.
This commit is contained in:
parent
ce633a7675
commit
20e42ccfac
|
@ -65,7 +65,7 @@ class Dialog : VerticalLayout {
|
||||||
_caption = caption;
|
_caption = caption;
|
||||||
_parentWindow = parentWindow;
|
_parentWindow = parentWindow;
|
||||||
_flags = flags;
|
_flags = flags;
|
||||||
_icon = "dlangui-logo1";
|
_icon = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,9 +88,13 @@ class Dialog : VerticalLayout {
|
||||||
@property Dialog windowIcon(string iconResourceId) {
|
@property Dialog windowIcon(string iconResourceId) {
|
||||||
_icon = iconResourceId;
|
_icon = iconResourceId;
|
||||||
static if (BACKEND_GUI) {
|
static if (BACKEND_GUI) {
|
||||||
if (_window && _icon)
|
if (_window) {
|
||||||
|
if (_icon.length == 0)
|
||||||
|
_window.windowIcon = drawableCache.getImage(Platform.instance.defaultWindowIcon);
|
||||||
|
else
|
||||||
_window.windowIcon = drawableCache.getImage(_icon);
|
_window.windowIcon = drawableCache.getImage(_icon);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,10 +215,7 @@ class Dialog : VerticalLayout {
|
||||||
if (_initialWidth == 0 && _initialHeight == 0)
|
if (_initialWidth == 0 && _initialHeight == 0)
|
||||||
wflags |= WindowFlag.MeasureSize;
|
wflags |= WindowFlag.MeasureSize;
|
||||||
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags, _initialWidth, _initialHeight);
|
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags, _initialWidth, _initialHeight);
|
||||||
static if (BACKEND_GUI) {
|
windowIcon = _icon;
|
||||||
if (_window && _icon)
|
|
||||||
_window.windowIcon = drawableCache.getImage(_icon);
|
|
||||||
}
|
|
||||||
_window.backgroundColor = currentTheme.customColor("dialog_background");
|
_window.backgroundColor = currentTheme.customColor("dialog_background");
|
||||||
_window.mainWidget = this;
|
_window.mainWidget = this;
|
||||||
_window.show();
|
_window.show();
|
||||||
|
|
|
@ -1884,6 +1884,20 @@ class Platform {
|
||||||
// override and call dispatchThemeChange for all windows
|
// override and call dispatchThemeChange for all windows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// default icon for new created windows
|
||||||
|
private string _defaultWindowIcon = "dlangui-logo1";
|
||||||
|
|
||||||
|
/// sets default icon for new created windows
|
||||||
|
@property void defaultWindowIcon(string newIcon) {
|
||||||
|
_defaultWindowIcon = newIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// gets default icon for new created windows
|
||||||
|
@property string defaultWindowIcon() {
|
||||||
|
return _defaultWindowIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get current platform object instance
|
/// get current platform object instance
|
||||||
|
|
|
@ -99,6 +99,9 @@ class SDLWindow : Window {
|
||||||
create(flags);
|
create(flags);
|
||||||
_children.reserve(20);
|
_children.reserve(20);
|
||||||
Log.i(_enableOpengl ? "OpenGL is enabled" : "OpenGL is disabled");
|
Log.i(_enableOpengl ? "OpenGL is enabled" : "OpenGL is disabled");
|
||||||
|
|
||||||
|
if (platform.defaultWindowIcon.length != 0)
|
||||||
|
windowIcon = drawableCache.getImage(platform.defaultWindowIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
|
|
|
@ -307,6 +307,9 @@ class Win32Window : Window {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetWindowRect(_hwnd, &rect);
|
GetWindowRect(_hwnd, &rect);
|
||||||
handleWindowStateChange(WindowState.unspecified, Rect(rect.left, rect.top, _dx, _dy));
|
handleWindowStateChange(WindowState.unspecified, Rect(rect.left, rect.top, _dx, _dy));
|
||||||
|
|
||||||
|
if (platform.defaultWindowIcon.length != 0)
|
||||||
|
windowIcon = drawableCache.getImage(platform.defaultWindowIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
static if (ENABLE_OPENGL) {
|
static if (ENABLE_OPENGL) {
|
||||||
|
|
|
@ -373,6 +373,9 @@ class X11Window : DWindow {
|
||||||
//XFlush(x11display);
|
//XFlush(x11display);
|
||||||
|
|
||||||
handleWindowStateChange(WindowState.unspecified, Rect(0, 0, _dx, _dy));
|
handleWindowStateChange(WindowState.unspecified, Rect(0, 0, _dx, _dy));
|
||||||
|
|
||||||
|
if (platform.defaultWindowIcon.length != 0)
|
||||||
|
windowIcon = drawableCache.getImage(platform.defaultWindowIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
|
|
Loading…
Reference in New Issue