mirror of https://github.com/buggins/dlangui.git
fix style with substyles modification - close #150
This commit is contained in:
parent
b306388fd6
commit
eb99980d5e
|
@ -13,6 +13,17 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
// create window
|
// create window
|
||||||
Window window = Platform.instance.createWindow("DlangUI example - 3D Application", null, WindowFlag.Resizable, 600, 500);
|
Window window = Platform.instance.createWindow("DlangUI example - 3D Application", null, WindowFlag.Resizable, 600, 500);
|
||||||
|
|
||||||
|
static if (true) {
|
||||||
|
VerticalLayout layout = new VerticalLayout();
|
||||||
|
Button btn = new Button(null, "Button 1"d);
|
||||||
|
btn.fontSize = 32;
|
||||||
|
Button btn2 = new Button(null, "Button 2"d);
|
||||||
|
btn2.fontSize = 32;
|
||||||
|
layout.addChild(btn);
|
||||||
|
layout.addChild(btn2);
|
||||||
|
window.mainWidget = layout;
|
||||||
|
} else {
|
||||||
|
|
||||||
// create some widget to show in window
|
// create some widget to show in window
|
||||||
//window.mainWidget = (new Button()).text("Hello, world!"d).margins(Rect(20,20,20,20));
|
//window.mainWidget = (new Button()).text("Hello, world!"d).margins(Rect(20,20,20,20));
|
||||||
window.mainWidget = parseML(q{
|
window.mainWidget = parseML(q{
|
||||||
|
@ -55,8 +66,8 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
Button { id: btnOk; text: "Ok" }
|
Button { id: btnOk; text: "Ok"; fontSize: 27px }
|
||||||
Button { id: btnCancel; text: "Cancel" }
|
Button { id: btnCancel; text: "Cancel"; fontSize: 27px }
|
||||||
}
|
}
|
||||||
CanvasWidget {
|
CanvasWidget {
|
||||||
id: canvas
|
id: canvas
|
||||||
|
@ -84,6 +95,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
for (int i = 0; i < 40; i+=3)
|
for (int i = 0; i < 40; i+=3)
|
||||||
buf.drawLine(Point(x+200 + i * 4, y+190), Point(x+150 + i * 7, y+320 + i * 2), 0x008000 + i * 5);
|
buf.drawLine(Point(x+200 + i * 4, y+190), Point(x+150 + i * 7, y+320 + i * 2), 0x008000 + i * 5);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Scene3d scene = new Scene3d();
|
Scene3d scene = new Scene3d();
|
||||||
Camera cam = new Camera();
|
Camera cam = new Camera();
|
||||||
|
|
|
@ -806,6 +806,40 @@ public:
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Style clone() {
|
||||||
|
Style res = new Style(_theme, null);
|
||||||
|
res._stateMask = _stateMask;
|
||||||
|
res._stateValue = _stateValue;
|
||||||
|
res._align = _align;
|
||||||
|
res._fontStyle = _fontStyle;
|
||||||
|
res._fontFamily = _fontFamily;
|
||||||
|
res._fontWeight = _fontWeight;
|
||||||
|
res._fontSize = _fontSize;
|
||||||
|
res._backgroundColor = _backgroundColor;
|
||||||
|
res._textColor = _textColor;
|
||||||
|
res._textFlags = _textFlags;
|
||||||
|
res._alpha = _alpha;
|
||||||
|
res._fontFace = _fontFace;
|
||||||
|
res._backgroundImageId = _backgroundImageId;
|
||||||
|
res._padding = _padding;
|
||||||
|
res._margins = _margins;
|
||||||
|
res._minWidth = _minWidth;
|
||||||
|
res._maxWidth = _maxWidth;
|
||||||
|
res._minHeight = _minHeight;
|
||||||
|
res._maxHeight = _maxHeight;
|
||||||
|
res._layoutWidth = _layoutWidth;
|
||||||
|
res._layoutHeight = _layoutHeight;
|
||||||
|
res._layoutWeight = _layoutWeight;
|
||||||
|
res._maxLines = _maxLines;
|
||||||
|
|
||||||
|
res._focusRectColors = _focusRectColors.dup;
|
||||||
|
|
||||||
|
res._customDrawables = _customDrawables.dup;
|
||||||
|
res._customColors = _customColors.dup;
|
||||||
|
res._customLength = _customLength.dup;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/// find exact existing state style or create new if no matched styles found
|
/// find exact existing state style or create new if no matched styles found
|
||||||
Style getOrCreateState(uint stateMask = 0, uint stateValue = 0) {
|
Style getOrCreateState(uint stateMask = 0, uint stateValue = 0) {
|
||||||
if (stateValue == State.Normal)
|
if (stateValue == State.Normal)
|
||||||
|
@ -878,6 +912,14 @@ class Theme : Style {
|
||||||
style._margins.left = SIZE_UNSPECIFIED; // inherit
|
style._margins.left = SIZE_UNSPECIFIED; // inherit
|
||||||
style._textColor = COLOR_UNSPECIFIED; // inherit
|
style._textColor = COLOR_UNSPECIFIED; // inherit
|
||||||
style._textFlags = TEXT_FLAGS_UNSPECIFIED; // inherit
|
style._textFlags = TEXT_FLAGS_UNSPECIFIED; // inherit
|
||||||
|
Style parent = get(id);
|
||||||
|
if (parent) {
|
||||||
|
foreach(item; parent._substates) {
|
||||||
|
Style substate = item.clone();
|
||||||
|
substate._parentStyle = style;
|
||||||
|
style._substates ~= substate;
|
||||||
|
}
|
||||||
|
}
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue