mirror of https://github.com/buggins/dlangui.git
listeners refactoring
This commit is contained in:
parent
c31d60951b
commit
29bf2c452a
|
@ -53,11 +53,15 @@ class Dialog : VerticalLayout {
|
||||||
protected UIString _caption;
|
protected UIString _caption;
|
||||||
protected uint _flags;
|
protected uint _flags;
|
||||||
protected string _icon;
|
protected string _icon;
|
||||||
|
protected int _initialWidth;
|
||||||
|
protected int _initialHeight;
|
||||||
|
|
||||||
Signal!DialogResultHandler dialogResult;
|
Signal!DialogResultHandler dialogResult;
|
||||||
|
|
||||||
this(UIString caption, Window parentWindow = null, uint flags = DialogFlag.Modal) {
|
this(UIString caption, Window parentWindow = null, uint flags = DialogFlag.Modal, int initialWidth = 0, int initialHeight = 0) {
|
||||||
super("dialog-main-widget");
|
super("dialog-main-widget");
|
||||||
|
_initialWidth = initialWidth;
|
||||||
|
_initialHeight = initialHeight;
|
||||||
_caption = caption;
|
_caption = caption;
|
||||||
_parentWindow = parentWindow;
|
_parentWindow = parentWindow;
|
||||||
_flags = flags;
|
_flags = flags;
|
||||||
|
@ -193,7 +197,7 @@ class Dialog : VerticalLayout {
|
||||||
_popup = _parentWindow.showPopup(_frame);
|
_popup = _parentWindow.showPopup(_frame);
|
||||||
_popup.flags(PopupFlags.Modal);
|
_popup.flags(PopupFlags.Modal);
|
||||||
} else {
|
} else {
|
||||||
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags);
|
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags, _initialWidth, _initialHeight);
|
||||||
if (_window && _icon)
|
if (_window && _icon)
|
||||||
_window.windowIcon = drawableCache.getImage(_icon);
|
_window.windowIcon = drawableCache.getImage(_icon);
|
||||||
_window.mainWidget = this;
|
_window.mainWidget = this;
|
||||||
|
|
|
@ -182,7 +182,7 @@ class NumberEditItem : SettingsItem {
|
||||||
n = _maxValue;
|
n = _maxValue;
|
||||||
setting.integer = cast(long)n;
|
setting.integer = cast(long)n;
|
||||||
ed.text = toUTF32(to!string(n));
|
ed.text = toUTF32(to!string(n));
|
||||||
ed.onContentChangeListener = delegate(EditableContent content) {
|
ed.contentChange = delegate(EditableContent content) {
|
||||||
long v = parseLong(toUTF8(content.text), long.max);
|
long v = parseLong(toUTF8(content.text), long.max);
|
||||||
if (v != long.max) {
|
if (v != long.max) {
|
||||||
if ((_minValue == int.max || v >= _minValue) && (_maxValue == int.max || v <= _maxValue)) {
|
if ((_minValue == int.max || v >= _minValue) && (_maxValue == int.max || v <= _maxValue)) {
|
||||||
|
@ -211,7 +211,7 @@ class StringEditItem : SettingsItem {
|
||||||
string value = setting.strDef(_defaultValue);
|
string value = setting.strDef(_defaultValue);
|
||||||
setting.str = value;
|
setting.str = value;
|
||||||
ed.text = toUTF32(value);
|
ed.text = toUTF32(value);
|
||||||
ed.onContentChangeListener = delegate(EditableContent content) {
|
ed.contentChange = delegate(EditableContent content) {
|
||||||
string value = toUTF8(content.text);
|
string value = toUTF8(content.text);
|
||||||
setting.str = value;
|
setting.str = value;
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,11 +127,11 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
||||||
_popup = null;
|
_popup = null;
|
||||||
_popupList = null;
|
_popupList = null;
|
||||||
};
|
};
|
||||||
_popupList.onItemSelectedListener = delegate(Widget source, int index) {
|
_popupList.itemSelected = delegate(Widget source, int index) {
|
||||||
selectedItemIndex = index;
|
selectedItemIndex = index;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
_popupList.onItemClickListener = delegate(Widget source, int index) {
|
_popupList.itemClick = delegate(Widget source, int index) {
|
||||||
selectedItemIndex = index;
|
selectedItemIndex = index;
|
||||||
if (_popup !is null)
|
if (_popup !is null)
|
||||||
_popup.close();
|
_popup.close();
|
||||||
|
|
|
@ -243,13 +243,9 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
|
|
||||||
/// Modified state change listener (e.g. content has been saved, or first time modified after save)
|
/// Modified state change listener (e.g. content has been saved, or first time modified after save)
|
||||||
Signal!ModifiedStateListener modifiedStateChange;
|
Signal!ModifiedStateListener modifiedStateChange;
|
||||||
/// modifiedStateChange signal alias for backward compatibility; will be deprecated in future
|
|
||||||
alias onModifiedStateChangeListener = modifiedStateChange;
|
|
||||||
|
|
||||||
/// editor content is changed
|
/// editor content is changed
|
||||||
Signal!EditableContentChangeListener contentChange;
|
Signal!EditableContentChangeListener contentChange;
|
||||||
/// contentChange signal alias for backward compatibility; will be deprecated in future
|
|
||||||
alias onContentChangeListener = contentChange;
|
|
||||||
|
|
||||||
/// override to support modification of client rect after change, e.g. apply offset
|
/// override to support modification of client rect after change, e.g. apply offset
|
||||||
override protected void handleClientRectLayout(ref Rect rc) {
|
override protected void handleClientRectLayout(ref Rect rc) {
|
||||||
|
@ -706,15 +702,15 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
requestActionsUpdate();
|
requestActionsUpdate();
|
||||||
}
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
if (onModifiedStateChangeListener.assigned) {
|
if (modifiedStateChange.assigned) {
|
||||||
if (_lastReportedModifiedState != content.modified) {
|
if (_lastReportedModifiedState != content.modified) {
|
||||||
_lastReportedModifiedState = content.modified;
|
_lastReportedModifiedState = content.modified;
|
||||||
onModifiedStateChangeListener(this, content.modified);
|
modifiedStateChange(this, content.modified);
|
||||||
requestActionsUpdate();
|
requestActionsUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (onContentChangeListener.assigned) {
|
if (contentChange.assigned) {
|
||||||
onContentChangeListener(_content);
|
contentChange(_content);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,12 +394,8 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
||||||
|
|
||||||
/** Handle selection change. */
|
/** Handle selection change. */
|
||||||
Signal!OnItemSelectedHandler itemSelected;
|
Signal!OnItemSelectedHandler itemSelected;
|
||||||
/// itemSelected signal alias for backward compatibility; will be deprecated in future
|
|
||||||
alias onItemSelectedListener = itemSelected;
|
|
||||||
/** Handle item click / activation (e.g. Space or Enter key press and mouse double click) */
|
/** Handle item click / activation (e.g. Space or Enter key press and mouse double click) */
|
||||||
Signal!OnItemClickHandler itemClick;
|
Signal!OnItemClickHandler itemClick;
|
||||||
/// itemClick signal alias for backward compatibility; will be deprecated in future
|
|
||||||
alias onItemClickListener = itemClick;
|
|
||||||
|
|
||||||
protected Orientation _orientation = Orientation.Vertical;
|
protected Orientation _orientation = Orientation.Vertical;
|
||||||
/// returns linear layout orientation (Vertical, Horizontal)
|
/// returns linear layout orientation (Vertical, Horizontal)
|
||||||
|
@ -570,14 +566,14 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
||||||
|
|
||||||
/// override to handle change of selection
|
/// override to handle change of selection
|
||||||
protected void selectionChanged(int index, int previouslySelectedItem = -1) {
|
protected void selectionChanged(int index, int previouslySelectedItem = -1) {
|
||||||
if (onItemSelectedListener.assigned)
|
if (itemSelected.assigned)
|
||||||
onItemSelectedListener(this, index);
|
itemSelected(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// override to handle mouse up on item
|
/// override to handle mouse up on item
|
||||||
protected void itemClicked(int index) {
|
protected void itemClicked(int index) {
|
||||||
if (onItemClickListener.assigned)
|
if (itemClick.assigned)
|
||||||
onItemClickListener(this, index);
|
itemClick(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// allow to override state for updating of items
|
/// allow to override state for updating of items
|
||||||
|
|
Loading…
Reference in New Issue