mirror of https://github.com/buggins/dlangui.git
fixed Signal opAssign with null
This commit is contained in:
parent
71a1e4cc78
commit
adac2b3c8d
20
README.md
20
README.md
|
@ -3,6 +3,8 @@ Dlang UI
|
|||
|
||||
GUI for D programming language, written in D.
|
||||
|
||||
Alpha stage of development.
|
||||
|
||||
* Crossplatform (Win32 and Linux are supported in current version)
|
||||
* Mostly inspired by Android UI API (layouts, styles, two phase layout, ...)
|
||||
* Supports highly customizable UI themes and styles
|
||||
|
@ -13,6 +15,24 @@ GUI for D programming language, written in D.
|
|||
* Almost ready for 2D games development
|
||||
* Goal: provide set of widgets suitable for building of IDE.
|
||||
|
||||
Widgets
|
||||
-------
|
||||
|
||||
Currently implemented widgets:
|
||||
|
||||
* TextWidget - simple static text (TODO: implement multiline formatting)
|
||||
* ImageWidget - static image
|
||||
* Button - simple button with text label
|
||||
* ImageButton - image only button
|
||||
* TextImageButton - button with icon and label
|
||||
* CheckBox - check button with label
|
||||
* RadioButton - radio button with label
|
||||
* VSpacer - vertical spacer - just an empty widget with layoutHeight == FILL_PARENT, to fill vertical space in layouts
|
||||
* HSpacer - horizontal spacer - just an empty widget with layoutWidth == FILL_PARENT, to fill horizontal space in layouts
|
||||
* ScrollBar - scroll bar
|
||||
|
||||
Layouts
|
||||
-------
|
||||
|
||||
Win32 builds
|
||||
------------
|
||||
|
|
|
@ -177,7 +177,8 @@ struct Signal(T1) if (is(T1 == interface) && __traits(allMembers, T1).length ==
|
|||
/// replace all previously assigned listeners with new one (if null passed, remove all listeners)
|
||||
final void opAssign(slot_t listener) {
|
||||
_listeners.clear();
|
||||
_listeners ~= listener;
|
||||
if (listener !is null)
|
||||
_listeners ~= listener;
|
||||
}
|
||||
/// call all listeners; for signals having non-void return type, stop iterating when first return value is nonzero
|
||||
static if (is (return_t == void)) {
|
||||
|
@ -225,9 +226,11 @@ struct Signal(RETURN_T, T1...)
|
|||
final bool assigned() {
|
||||
return _listeners.length > 0;
|
||||
}
|
||||
/// replace all previously assigned listeners with new one (if null passed, remove all listeners)
|
||||
final void opAssign(slot_t listener) {
|
||||
_listeners.clear();
|
||||
_listeners ~= listener;
|
||||
if (listener !is null)
|
||||
_listeners ~= listener;
|
||||
}
|
||||
/// call all listeners; for signals having non-void return type, stop iterating when first return value is nonzero
|
||||
static if (is (RETURN_T == void)) {
|
||||
|
|
|
@ -112,7 +112,7 @@ class TextWidget : Widget {
|
|||
}
|
||||
}
|
||||
|
||||
/// image widget
|
||||
/// static image widget
|
||||
class ImageWidget : Widget {
|
||||
|
||||
protected string _drawableId;
|
||||
|
@ -339,11 +339,8 @@ class AbstractSlider : WidgetGroup {
|
|||
super(ID);
|
||||
}
|
||||
|
||||
protected bool delegate(AbstractSlider source, ScrollEvent event) _onScrollEventListener;
|
||||
/// scroll event listener
|
||||
@property bool delegate(AbstractSlider source, ScrollEvent event) onScrollEventListener() const { return _onScrollEventListener; }
|
||||
/// sets new scroll event listener
|
||||
@property AbstractSlider onScrollEventListener(bool delegate(AbstractSlider source, ScrollEvent event) listener) { _onScrollEventListener = listener; return this; }
|
||||
/// scroll event listeners
|
||||
Signal!OnScrollHandler onScrollEventListener;
|
||||
|
||||
/// returns slider position
|
||||
@property int position() const { return _position; }
|
||||
|
@ -383,10 +380,10 @@ class AbstractSlider : WidgetGroup {
|
|||
}
|
||||
|
||||
protected bool sendScrollEvent(ScrollAction action, int position) {
|
||||
if (_onScrollEventListener is null)
|
||||
if (!onScrollEventListener.assigned)
|
||||
return false;
|
||||
ScrollEvent event = new ScrollEvent(action, _minValue, _maxValue, _pageSize, position);
|
||||
bool res = _onScrollEventListener(this, event);
|
||||
bool res = onScrollEventListener(this, event);
|
||||
if (event.positionChanged) {
|
||||
_position = event.position;
|
||||
if (_position > _maxValue)
|
||||
|
|
Loading…
Reference in New Issue