Add main widget change signal to window

This commit is contained in:
Grim Maple 2022-11-26 13:47:06 +03:00
parent b1badfd618
commit 7895e417d9
1 changed files with 13 additions and 2 deletions

View File

@ -129,6 +129,12 @@ interface OnWindowActivityHandler {
bool onWindowActivityChange(Window window, bool isWindowActive);
}
/// Window main widget changing signal listener
interface OnMainWidgetChange
{
void onMainWidgetChange(Window window, Widget previous, Widget newWidget);
}
/// protected event list
/// references to posted messages can be stored here at least to keep live reference and avoid GC
/// as well, on some platforms it's easy to send id to message queue, but not pointer
@ -264,8 +270,11 @@ class Window : CustomEventTarget {
@property int height() const { return _dy; }
@property uint keyboardModifiers() const { return _keyboardModifiers; }
@property inout(Widget) mainWidget() inout { return _mainWidget; }
@property void mainWidget(Widget widget) {
if (_mainWidget !is null) {
@property void mainWidget(Widget widget)
{
mainWidgetChange(this, _mainWidget, widget);
if (_mainWidget !is null)
{
_mainWidget.window = null;
destroy(_mainWidget);
}
@ -274,6 +283,8 @@ class Window : CustomEventTarget {
_mainWidget.window = this;
}
Signal!OnMainWidgetChange mainWidgetChange;
/// save window state to setting object
void saveWindowState(Setting setting) {
if (!setting)