mirror of https://github.com/buggins/dlangui.git
box shadow property in Style
This commit is contained in:
parent
c9186ead05
commit
bb4c7b0a02
|
|
@ -1136,7 +1136,7 @@ class CombinedDrawable : Drawable {
|
||||||
DrawableRef background;
|
DrawableRef background;
|
||||||
DrawableRef border;
|
DrawableRef border;
|
||||||
|
|
||||||
this(uint backgroundColor, string backgroundImageId, string borderDescription) {
|
this(uint backgroundColor, string backgroundImageId, string borderDescription, string boxShadowDescription) {
|
||||||
background =
|
background =
|
||||||
(backgroundImageId !is null) ? drawableCache.get(backgroundImageId) :
|
(backgroundImageId !is null) ? drawableCache.get(backgroundImageId) :
|
||||||
(!backgroundColor.isFullyTransparentColor) ? new SolidFillDrawable(backgroundColor) : null;
|
(!backgroundColor.isFullyTransparentColor) ? new SolidFillDrawable(backgroundColor) : null;
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,7 @@ protected:
|
||||||
uint _alpha;
|
uint _alpha;
|
||||||
string _fontFace;
|
string _fontFace;
|
||||||
string _backgroundImageId;
|
string _backgroundImageId;
|
||||||
|
string _boxShadow;
|
||||||
string _border;
|
string _border;
|
||||||
Rect _padding;
|
Rect _padding;
|
||||||
Rect _margins;
|
Rect _margins;
|
||||||
|
|
@ -413,8 +414,10 @@ public:
|
||||||
return (cast(Style)this)._backgroundDrawable;
|
return (cast(Style)this)._backgroundDrawable;
|
||||||
string image = backgroundImageId;
|
string image = backgroundImageId;
|
||||||
uint color = backgroundColor;
|
uint color = backgroundColor;
|
||||||
if (border !is null) {
|
string borders = border;
|
||||||
(cast(Style)this)._backgroundDrawable = new CombinedDrawable(color, image, border);
|
string shadows = boxShadow;
|
||||||
|
if (borders !is null || shadows !is null) {
|
||||||
|
(cast(Style)this)._backgroundDrawable = new CombinedDrawable(color, image, borders, shadows);
|
||||||
} else if (image !is null) {
|
} else if (image !is null) {
|
||||||
(cast(Style)this)._backgroundDrawable = drawableCache.get(image);
|
(cast(Style)this)._backgroundDrawable = drawableCache.get(image);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -530,6 +533,15 @@ public:
|
||||||
return parentStyle.fontSize;
|
return parentStyle.fontSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// box shadow
|
||||||
|
@property string boxShadow() const {
|
||||||
|
if (_boxShadow !is null)
|
||||||
|
return _boxShadow;
|
||||||
|
else {
|
||||||
|
return parentStyle.boxShadow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// border
|
/// border
|
||||||
@property string border() const {
|
@property string border() const {
|
||||||
if (_border !is null)
|
if (_border !is null)
|
||||||
|
|
@ -791,6 +803,12 @@ public:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property Style boxShadow(string s) {
|
||||||
|
_boxShadow = s;
|
||||||
|
_backgroundDrawable.clear();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@property Style border(string s) {
|
@property Style border(string s) {
|
||||||
_border = s;
|
_border = s;
|
||||||
_backgroundDrawable.clear();
|
_backgroundDrawable.clear();
|
||||||
|
|
@ -1038,6 +1056,10 @@ class Theme : Style {
|
||||||
@property override string backgroundImageId() const {
|
@property override string backgroundImageId() const {
|
||||||
return _backgroundImageId;
|
return _backgroundImageId;
|
||||||
}
|
}
|
||||||
|
/// box shadow
|
||||||
|
@property override string boxShadow() const {
|
||||||
|
return _boxShadow;
|
||||||
|
}
|
||||||
/// border
|
/// border
|
||||||
@property override string border() const {
|
@property override string border() const {
|
||||||
return _border;
|
return _border;
|
||||||
|
|
@ -1527,6 +1549,11 @@ string sanitizeBorderProperty(string s) pure {
|
||||||
return cast(string)res;
|
return cast(string)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// remove superfluous space characters from a box shadow property
|
||||||
|
string sanitizeBoxShadowProperty(string s) pure {
|
||||||
|
return sanitizeBorderProperty(s);
|
||||||
|
}
|
||||||
|
|
||||||
/// load style attributes from XML element
|
/// load style attributes from XML element
|
||||||
bool loadStyleAttributes(Style style, Element elem, bool allowStates) {
|
bool loadStyleAttributes(Style style, Element elem, bool allowStates) {
|
||||||
//Log.d("Theme: loadStyleAttributes ", style.id, " ", elem.tag.attr);
|
//Log.d("Theme: loadStyleAttributes ", style.id, " ", elem.tag.attr);
|
||||||
|
|
@ -1542,6 +1569,8 @@ bool loadStyleAttributes(Style style, Element elem, bool allowStates) {
|
||||||
style.padding = decodeRect(elem.tag.attr["padding"]);
|
style.padding = decodeRect(elem.tag.attr["padding"]);
|
||||||
if ("border" in elem.tag.attr)
|
if ("border" in elem.tag.attr)
|
||||||
style.border = sanitizeBorderProperty(elem.tag.attr["border"]);
|
style.border = sanitizeBorderProperty(elem.tag.attr["border"]);
|
||||||
|
if ("boxShadow" in elem.tag.attr)
|
||||||
|
style.boxShadow = sanitizeBoxShadowProperty(elem.tag.attr["boxShadow"]);
|
||||||
if ("align" in elem.tag.attr)
|
if ("align" in elem.tag.attr)
|
||||||
style.alignment = decodeAlignment(elem.tag.attr["align"]);
|
style.alignment = decodeAlignment(elem.tag.attr["align"]);
|
||||||
if ("minWidth" in elem.tag.attr)
|
if ("minWidth" in elem.tag.attr)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue