mirror of https://github.com/buggins/dlangui.git
introduce layout params
This commit is contained in:
parent
fb1215502c
commit
f13757042e
|
@ -16,6 +16,10 @@ immutable ubyte FONT_STYLE_ITALIC = 0x01;
|
||||||
/// use as widget.layout() param to avoid applying of parent size
|
/// use as widget.layout() param to avoid applying of parent size
|
||||||
immutable int SIZE_UNSPECIFIED = int.max;
|
immutable int SIZE_UNSPECIFIED = int.max;
|
||||||
|
|
||||||
|
immutable int FILL_PARENT = int.max - 1;
|
||||||
|
immutable int WRAP_CONTENT = int.max - 2;
|
||||||
|
immutable int WEIGHT_UNSPECIFIED = -1;
|
||||||
|
|
||||||
enum Align : ubyte {
|
enum Align : ubyte {
|
||||||
Unspecified = ALIGN_UNSPECIFIED,
|
Unspecified = ALIGN_UNSPECIFIED,
|
||||||
Left = 1,
|
Left = 1,
|
||||||
|
@ -51,6 +55,9 @@ class Style {
|
||||||
protected int _maxWidth = SIZE_UNSPECIFIED;
|
protected int _maxWidth = SIZE_UNSPECIFIED;
|
||||||
protected int _minHeight = SIZE_UNSPECIFIED;
|
protected int _minHeight = SIZE_UNSPECIFIED;
|
||||||
protected int _maxHeight = SIZE_UNSPECIFIED;
|
protected int _maxHeight = SIZE_UNSPECIFIED;
|
||||||
|
protected int _layoutWidth = SIZE_UNSPECIFIED;
|
||||||
|
protected int _layoutHeight = SIZE_UNSPECIFIED;
|
||||||
|
protected int _layoutWeight = WEIGHT_UNSPECIFIED;
|
||||||
|
|
||||||
protected Style[] _substates;
|
protected Style[] _substates;
|
||||||
protected Style[] _children;
|
protected Style[] _children;
|
||||||
|
@ -253,6 +260,46 @@ class Style {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// layout width parameter
|
||||||
|
@property uint layoutWidth() const {
|
||||||
|
if (_layoutWidth != SIZE_UNSPECIFIED)
|
||||||
|
return _layoutWidth;
|
||||||
|
else
|
||||||
|
return parentStyle.layoutWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// layout height parameter
|
||||||
|
@property uint layoutHeight() const {
|
||||||
|
if (_layoutHeight != SIZE_UNSPECIFIED)
|
||||||
|
return _layoutHeight;
|
||||||
|
else
|
||||||
|
return parentStyle.layoutHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// layout weight parameter
|
||||||
|
@property uint layoutWeight() const {
|
||||||
|
if (_layoutWeight != WEIGHT_UNSPECIFIED)
|
||||||
|
return _layoutWeight;
|
||||||
|
else
|
||||||
|
return parentStyle.layoutWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// set layout height
|
||||||
|
@property Style layoutHeight(int value) {
|
||||||
|
_layoutHeight = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/// set layout width
|
||||||
|
@property Style layoutWidth(int value) {
|
||||||
|
_layoutWidth = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/// set layout weight
|
||||||
|
@property Style layoutWeight(int value) {
|
||||||
|
_layoutWeight = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
//===================================================
|
//===================================================
|
||||||
// alignment
|
// alignment
|
||||||
|
|
||||||
|
@ -387,6 +434,9 @@ class Theme : Style {
|
||||||
_fontFamily = FontFamily.SansSerif;
|
_fontFamily = FontFamily.SansSerif;
|
||||||
_minHeight = 0;
|
_minHeight = 0;
|
||||||
_minWidth = 0;
|
_minWidth = 0;
|
||||||
|
_layoutWidth = WRAP_CONTENT;
|
||||||
|
_layoutHeight = WRAP_CONTENT;
|
||||||
|
_layoutWeight = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// create wrapper style which will have currentTheme.get(id) as parent instead of fixed parent - to modify some base style properties in widget
|
/// create wrapper style which will have currentTheme.get(id) as parent instead of fixed parent - to modify some base style properties in widget
|
||||||
|
|
|
@ -162,6 +162,20 @@ class Widget {
|
||||||
/// set max height constraint (0 for no constraint)
|
/// set max height constraint (0 for no constraint)
|
||||||
@property Widget minHeight(int value) { ownStyle.minHeight = value; return this; }
|
@property Widget minHeight(int value) { ownStyle.minHeight = value; return this; }
|
||||||
|
|
||||||
|
/// returns layout width options (WRAP_CONTENT, FILL_PARENT, or some constant value)
|
||||||
|
@property int layoutWidth() { return style.layoutWidth; }
|
||||||
|
/// returns layout height options (WRAP_CONTENT, FILL_PARENT, or some constant value)
|
||||||
|
@property int layoutHeight() { return style.layoutHeight; }
|
||||||
|
/// returns layout weight (while resizing to fill parent, widget will be resized proportionally to this value)
|
||||||
|
@property int layoutWeight() { return style.layoutWeight; }
|
||||||
|
|
||||||
|
/// sets layout width options (WRAP_CONTENT, FILL_PARENT, or some constant value)
|
||||||
|
@property Widget layoutWidth(int value) { ownStyle.layoutWidth = value; return this; }
|
||||||
|
/// sets layout height options (WRAP_CONTENT, FILL_PARENT, or some constant value)
|
||||||
|
@property Widget layoutHeight(int value) { ownStyle.layoutHeight = value; return this; }
|
||||||
|
/// sets layout weight (while resizing to fill parent, widget will be resized proportionally to this value)
|
||||||
|
@property Widget layoutWeight(int value) { ownStyle.layoutWeight = value; return this; }
|
||||||
|
|
||||||
/// returns widget visibility (Visible, Invisible, Gone)
|
/// returns widget visibility (Visible, Invisible, Gone)
|
||||||
@property Visibility visibility() { return _visibility; }
|
@property Visibility visibility() { return _visibility; }
|
||||||
/// sets widget visibility (Visible, Invisible, Gone)
|
/// sets widget visibility (Visible, Invisible, Gone)
|
||||||
|
|
Loading…
Reference in New Issue