diff --git a/README.md b/README.md index ce90255d..02a2f431 100644 --- a/README.md +++ b/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 ------------ diff --git a/src/dlangui/core/signals.d b/src/dlangui/core/signals.d index 9bdbfdf8..d9713d33 100644 --- a/src/dlangui/core/signals.d +++ b/src/dlangui/core/signals.d @@ -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)) { diff --git a/src/dlangui/widgets/controls.d b/src/dlangui/widgets/controls.d index 51bbee49..3a2620f5 100644 --- a/src/dlangui/widgets/controls.d +++ b/src/dlangui/widgets/controls.d @@ -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)