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 uint _flags;
|
||||
protected string _icon;
|
||||
protected int _initialWidth;
|
||||
protected int _initialHeight;
|
||||
|
||||
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");
|
||||
_initialWidth = initialWidth;
|
||||
_initialHeight = initialHeight;
|
||||
_caption = caption;
|
||||
_parentWindow = parentWindow;
|
||||
_flags = flags;
|
||||
|
@ -193,7 +197,7 @@ class Dialog : VerticalLayout {
|
|||
_popup = _parentWindow.showPopup(_frame);
|
||||
_popup.flags(PopupFlags.Modal);
|
||||
} else {
|
||||
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags);
|
||||
_window = Platform.instance.createWindow(_caption, _parentWindow, wflags, _initialWidth, _initialHeight);
|
||||
if (_window && _icon)
|
||||
_window.windowIcon = drawableCache.getImage(_icon);
|
||||
_window.mainWidget = this;
|
||||
|
|
|
@ -182,7 +182,7 @@ class NumberEditItem : SettingsItem {
|
|||
n = _maxValue;
|
||||
setting.integer = cast(long)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);
|
||||
if (v != long.max) {
|
||||
if ((_minValue == int.max || v >= _minValue) && (_maxValue == int.max || v <= _maxValue)) {
|
||||
|
@ -211,7 +211,7 @@ class StringEditItem : SettingsItem {
|
|||
string value = setting.strDef(_defaultValue);
|
||||
setting.str = value;
|
||||
ed.text = toUTF32(value);
|
||||
ed.onContentChangeListener = delegate(EditableContent content) {
|
||||
ed.contentChange = delegate(EditableContent content) {
|
||||
string value = toUTF8(content.text);
|
||||
setting.str = value;
|
||||
};
|
||||
|
|
|
@ -127,11 +127,11 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
|||
_popup = null;
|
||||
_popupList = null;
|
||||
};
|
||||
_popupList.onItemSelectedListener = delegate(Widget source, int index) {
|
||||
_popupList.itemSelected = delegate(Widget source, int index) {
|
||||
selectedItemIndex = index;
|
||||
return true;
|
||||
};
|
||||
_popupList.onItemClickListener = delegate(Widget source, int index) {
|
||||
_popupList.itemClick = delegate(Widget source, int index) {
|
||||
selectedItemIndex = index;
|
||||
if (_popup !is null)
|
||||
_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)
|
||||
Signal!ModifiedStateListener modifiedStateChange;
|
||||
/// modifiedStateChange signal alias for backward compatibility; will be deprecated in future
|
||||
alias onModifiedStateChangeListener = modifiedStateChange;
|
||||
|
||||
/// editor content is changed
|
||||
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 protected void handleClientRectLayout(ref Rect rc) {
|
||||
|
@ -706,15 +702,15 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
requestActionsUpdate();
|
||||
}
|
||||
invalidate();
|
||||
if (onModifiedStateChangeListener.assigned) {
|
||||
if (modifiedStateChange.assigned) {
|
||||
if (_lastReportedModifiedState != content.modified) {
|
||||
_lastReportedModifiedState = content.modified;
|
||||
onModifiedStateChangeListener(this, content.modified);
|
||||
modifiedStateChange(this, content.modified);
|
||||
requestActionsUpdate();
|
||||
}
|
||||
}
|
||||
if (onContentChangeListener.assigned) {
|
||||
onContentChangeListener(_content);
|
||||
if (contentChange.assigned) {
|
||||
contentChange(_content);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -394,12 +394,8 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
|||
|
||||
/** Handle selection change. */
|
||||
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) */
|
||||
Signal!OnItemClickHandler itemClick;
|
||||
/// itemClick signal alias for backward compatibility; will be deprecated in future
|
||||
alias onItemClickListener = itemClick;
|
||||
|
||||
protected Orientation _orientation = Orientation.Vertical;
|
||||
/// returns linear layout orientation (Vertical, Horizontal)
|
||||
|
@ -570,14 +566,14 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
|||
|
||||
/// override to handle change of selection
|
||||
protected void selectionChanged(int index, int previouslySelectedItem = -1) {
|
||||
if (onItemSelectedListener.assigned)
|
||||
onItemSelectedListener(this, index);
|
||||
if (itemSelected.assigned)
|
||||
itemSelected(this, index);
|
||||
}
|
||||
|
||||
/// override to handle mouse up on item
|
||||
protected void itemClicked(int index) {
|
||||
if (onItemClickListener.assigned)
|
||||
onItemClickListener(this, index);
|
||||
if (itemClick.assigned)
|
||||
itemClick(this, index);
|
||||
}
|
||||
|
||||
/// allow to override state for updating of items
|
||||
|
|
Loading…
Reference in New Issue