mirror of https://github.com/buggins/dlangui.git
fixes
This commit is contained in:
parent
b9bd78d3fd
commit
afae967515
|
@ -23,9 +23,87 @@ module dlangui.widgets.statusline;
|
|||
import dlangui.widgets.layouts;
|
||||
import dlangui.widgets.controls;
|
||||
|
||||
class StatusLinePanelBase : HorizontalLayout {
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
}
|
||||
}
|
||||
|
||||
class StatusLineTextPanel : StatusLinePanelBase {
|
||||
protected TextWidget _text;
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
_text = new TextWidget(null, ""d);
|
||||
addChild(_text);
|
||||
}
|
||||
/// returns widget content text (override to support this)
|
||||
override @property dstring text() { return _text.text; }
|
||||
/// sets widget content text (override to support this)
|
||||
override @property Widget text(dstring s) { _text.text = s; return this; }
|
||||
/// sets widget content text (override to support this)
|
||||
override @property Widget text(UIString s) { _text.text = s; return this; }
|
||||
}
|
||||
|
||||
class StatusLineIconPanel : StatusLinePanelBase {
|
||||
protected ImageWidget _icon;
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
_icon = new ImageWidget(null);
|
||||
addChild(_icon);
|
||||
}
|
||||
@property string iconId() {
|
||||
return _icon.drawableId;
|
||||
}
|
||||
@property void iconId(string icon) {
|
||||
_icon.drawableId = icon;
|
||||
}
|
||||
}
|
||||
|
||||
class StatusLineTextAndIconPanel : StatusLineTextPanel {
|
||||
protected ImageWidget _icon;
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
_icon = new ImageWidget(null);
|
||||
_icon.minWidth = 20;
|
||||
_icon.minHeight = 20;
|
||||
_icon.alignment = Align.Center;
|
||||
addChild(_icon);
|
||||
}
|
||||
@property string iconId() {
|
||||
return _icon.drawableId;
|
||||
}
|
||||
@property void iconId(string icon) {
|
||||
_icon.drawableId = icon;
|
||||
}
|
||||
}
|
||||
|
||||
class StatusLineBackgroundOperationPanel : StatusLineTextAndIconPanel {
|
||||
this(string ID) {
|
||||
super(ID);
|
||||
visibility = Visibility.Gone;
|
||||
}
|
||||
protected uint animationProgress;
|
||||
/// show / update / animate background operation status; when both parameters are nulls, hide background op status panel
|
||||
void setBackgroundOperationStatus(string icon, dstring statusText) {
|
||||
if (icon || statusText) {
|
||||
visibility = Visibility.Visible;
|
||||
text = statusText;
|
||||
iconId = icon;
|
||||
animationProgress = (animationProgress + 30) % 512;
|
||||
uint a = animationProgress;
|
||||
if (a >= 256)
|
||||
a = 512 - a;
|
||||
_icon.backgroundColor((a << 24) | (0x00FF00));
|
||||
} else {
|
||||
visibility = Visibility.Gone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Status line control
|
||||
class StatusLine : HorizontalLayout {
|
||||
TextWidget _defStatus;
|
||||
protected TextWidget _defStatus;
|
||||
protected StatusLineBackgroundOperationPanel _backgroundOperationPanel;
|
||||
this() {
|
||||
super("STATUS_LINE");
|
||||
styleId = STYLE_STATUS_LINE;
|
||||
|
@ -36,6 +114,8 @@ class StatusLine : HorizontalLayout {
|
|||
_defStatus.layoutWidth(FILL_PARENT);
|
||||
_defStatus.text = "DLANGUI"d;
|
||||
addChild(_defStatus);
|
||||
_backgroundOperationPanel = new StatusLineBackgroundOperationPanel("BACKGROUND_OP_STATUS");
|
||||
addChild(_backgroundOperationPanel);
|
||||
}
|
||||
/// set text to show in status line in specific panel
|
||||
void setStatusText(string itemId, dstring value) {
|
||||
|
@ -46,6 +126,7 @@ class StatusLine : HorizontalLayout {
|
|||
setStatusText(null, value);
|
||||
}
|
||||
/// show / update / animate background operation status; when both parameters are nulls, hide background op status panel
|
||||
void setBackgroundOperationStatus(string icon, dstring statusText) {
|
||||
void setBackgroundOperationStatus(string icon, dstring statusText = null) {
|
||||
_backgroundOperationPanel.setBackgroundOperationStatus(icon, statusText);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -555,9 +555,12 @@ class Widget {
|
|||
/// sets widget visibility (Visible, Invisible, Gone)
|
||||
@property Widget visibility(Visibility visible) {
|
||||
if (_visibility != visible) {
|
||||
if ((_visibility == Visibility.Gone) || (visible == Visibility.Gone))
|
||||
requestLayout();
|
||||
else
|
||||
if ((_visibility == Visibility.Gone) || (visible == Visibility.Gone)) {
|
||||
if (parent)
|
||||
parent.requestLayout();
|
||||
else
|
||||
requestLayout();
|
||||
} else
|
||||
invalidate();
|
||||
_visibility = visible;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue