mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Allow to configure window shadow style with: window-shadow-color, window-shadow-offset, window-shadow-size.
This commit is contained in:
@@ -672,6 +672,8 @@ Window {
|
||||
window-buttons-offset: -6dp 0dp;
|
||||
window-buttons-separation: 8dp;
|
||||
window-flags: default|shadow;
|
||||
window-shadow-offset: 0dp 0dp;
|
||||
window-shadow-size: 16dp;
|
||||
}
|
||||
|
||||
Window::decoration {
|
||||
|
||||
@@ -908,7 +908,7 @@ Sets the hint font shadow offset.
|
||||
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
|
||||
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UIPushButton (PushButton), EE::UI::UIToolti
|
||||
(Tooltip)
|
||||
* Data Type: [vector2-number](#vector2-number-data-type)
|
||||
* Data Type: [vector2-length](#vector2-length-data-type)
|
||||
* Default offset: `1dp 1dp`
|
||||
|
||||
---
|
||||
@@ -1984,7 +1984,7 @@ Sets the text shadow offset.
|
||||
(TextInput), EE::UI::UIListBoxItem (ListBox::item), EE::UI::UIDropDownList (DropDownList),
|
||||
EE::UI::UITextInputPassword (TextInputPassword), EE::UI::UIPushButton (PushButton), EE::UI::UIToolti
|
||||
(Tooltip)
|
||||
* Data Type: [vector2-number](#vector2-number-data-type)
|
||||
* Data Type: [vector2-length](#vector2-length-data-type)
|
||||
* Default offset: `1dp 1dp`
|
||||
|
||||
---
|
||||
@@ -2289,6 +2289,36 @@ And the opacity property applied to the window will be multiplied by this value.
|
||||
|
||||
---
|
||||
|
||||
### window-shadow-color
|
||||
|
||||
Sets the window shadow color.
|
||||
|
||||
* Applicable to: EE::UI::UIWindow (window)
|
||||
* Data Type: [color](#color-data-type)
|
||||
* Default value: `rgba(0,0,0,0.1)`
|
||||
|
||||
---
|
||||
|
||||
### window-shadow-offset
|
||||
|
||||
Sets the window shadow offset.
|
||||
|
||||
* Applicable to: EE::UI::UIWindow (window)
|
||||
* Data Type: [vector2-length](#vector2-length-data-type)
|
||||
* Default value: `16dp 16dp`
|
||||
|
||||
---
|
||||
|
||||
### window-shadow-size
|
||||
|
||||
Sets the window shadow size.
|
||||
|
||||
* Applicable to: EE::UI::UIWindow (window)
|
||||
* Data Type: [length](#length-data-type)
|
||||
* Default value: `16dp`
|
||||
|
||||
---
|
||||
|
||||
### window-title
|
||||
|
||||
Sets the window title.
|
||||
@@ -2297,6 +2327,8 @@ Sets the window title.
|
||||
* Data Type: [string](#string-data-type)
|
||||
* Default value: _No value_
|
||||
|
||||
---
|
||||
|
||||
### window-titlebar-auto-size
|
||||
|
||||
Sets if the window titlebar size should be automatically calculated based on the skin size.
|
||||
|
||||
@@ -152,10 +152,13 @@ enum class PropertyId : Uint32 {
|
||||
WindowTitlebarSize = String::hash( "window-titlebar-size" ),
|
||||
WindowBorderSize = String::hash( "window-border-size" ),
|
||||
WindowMinSize = String::hash( "window-min-size" ),
|
||||
WindowBorderAutoSize = String::hash( "window-border-auto-size" ),
|
||||
WindowButtonsSeparation = String::hash( "window-buttons-separation" ),
|
||||
WindowCornerDistance = String::hash( "window-corner-distance" ),
|
||||
WindowTitlebarAutoSize = String::hash( "window-decoration-auto-size" ),
|
||||
WindowBorderAutoSize = String::hash( "window-border-auto-size" ),
|
||||
WindowShadowColor = String::hash( "window-shadow-color" ),
|
||||
WindowShadowOffset = String::hash( "window-shadow-offset" ),
|
||||
WindowShadowSize = String::hash( "window-shadow-size" ),
|
||||
Hint = String::hash( "hint" ),
|
||||
HintColor = String::hash( "hint-color" ),
|
||||
HintShadowColor = String::hash( "hint-shadow-color" ),
|
||||
|
||||
@@ -235,7 +235,11 @@ class EE_API UIWindow : public UIWidget {
|
||||
UI_RESIZE_TYPE mResizeType;
|
||||
Vector2f mResizePos;
|
||||
|
||||
bool mFrameBufferBound;
|
||||
Color mShadowColor{ 0, 0, 0, 25 };
|
||||
CSS::StyleSheetLength mShadowSize{ "16dp" };
|
||||
Vector2f mShadowOffset{ 0, PixelDensity::dpToPx( 16.f ) };
|
||||
|
||||
bool mFrameBufferBound{ false };
|
||||
bool mWindowReady{ false };
|
||||
bool mShowWhenReady{ false };
|
||||
bool mStealFocusOnShow{ true };
|
||||
|
||||
@@ -309,6 +309,9 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
registerProperty( "window-corner-distance", "" ).setType( PropertyType::NumberLength );
|
||||
registerProperty( "window-decoration-auto-size", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "window-border-auto-size", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "window-shadow-color", "" ).setType( PropertyType::Color );
|
||||
registerProperty( "window-shadow-offset", "" ).setType( PropertyType::Vector2 );
|
||||
registerProperty( "window-shadow-size", "" ).setType( PropertyType::NumberLength );
|
||||
|
||||
registerProperty( "word-wrap", "" ).setType( PropertyType::Bool );
|
||||
|
||||
|
||||
@@ -378,12 +378,11 @@ void UIWindow::drawHighlightInvalidation() {
|
||||
void UIWindow::drawShadow() {
|
||||
UIWidget::matrixSet();
|
||||
Primitives p;
|
||||
Color shadowColor( 0, 0, 0, 25 * ( getAlpha() / 255.f ) );
|
||||
Float shadowSize = PixelDensity::dpToPx( 16.f );
|
||||
Vector2f shadowOffset( 0, shadowSize );
|
||||
Color shadowColor( mShadowColor.blendAlpha( getAlpha() ) );
|
||||
Float shadowSize = convertLength( mShadowSize, mSize.getWidth() );
|
||||
Rectf windowRect( mScreenPos, mSize );
|
||||
p.setColor( shadowColor );
|
||||
p.drawSoftShadow( windowRect, shadowOffset, shadowSize, shadowSize / 2 );
|
||||
p.drawSoftShadow( windowRect, mShadowOffset, shadowSize, shadowSize / 2 );
|
||||
UIWidget::matrixUnset();
|
||||
}
|
||||
|
||||
@@ -1594,6 +1593,13 @@ std::string UIWindow::getPropertyString( const PropertyDefinition* propertyDef,
|
||||
return mStyleConfig.TitlebarAutoSize ? "true" : "false";
|
||||
case PropertyId::WindowBorderAutoSize:
|
||||
return mStyleConfig.BorderAutoSize ? "true" : "false";
|
||||
case PropertyId::WindowShadowColor:
|
||||
return mShadowColor.toHexString();
|
||||
case PropertyId::WindowShadowSize:
|
||||
return mShadowSize.toString();
|
||||
case PropertyId::WindowShadowOffset:
|
||||
return String::fromFloat( PixelDensity::pxToDp( mShadowOffset.x ), "dp" ) + " " +
|
||||
String::fromFloat( PixelDensity::pxToDp( mShadowOffset.y ), "dp" );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef, propertyIndex );
|
||||
}
|
||||
@@ -1613,7 +1619,10 @@ std::vector<PropertyId> UIWindow::getPropertiesImplemented() const {
|
||||
PropertyId::WindowButtonsSeparation,
|
||||
PropertyId::WindowCornerDistance,
|
||||
PropertyId::WindowTitlebarAutoSize,
|
||||
PropertyId::WindowBorderAutoSize };
|
||||
PropertyId::WindowBorderAutoSize,
|
||||
PropertyId::WindowShadowSize,
|
||||
PropertyId::WindowShadowColor,
|
||||
PropertyId::WindowShadowOffset };
|
||||
props.insert( props.end(), local.begin(), local.end() );
|
||||
return props;
|
||||
}
|
||||
@@ -1718,6 +1727,18 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
mStyleConfig.BorderAutoSize = attribute.asBool();
|
||||
fixChildrenSize();
|
||||
break;
|
||||
case PropertyId::WindowShadowColor:
|
||||
mShadowColor = attribute.asColor();
|
||||
invalidateDraw();
|
||||
break;
|
||||
case PropertyId::WindowShadowOffset:
|
||||
mShadowOffset = attribute.asVector2f( this, mShadowOffset );
|
||||
invalidateDraw();
|
||||
break;
|
||||
case PropertyId::WindowShadowSize:
|
||||
mShadowSize = attribute.asStyleSheetLength();
|
||||
invalidateDraw();
|
||||
break;
|
||||
default:
|
||||
return UIWidget::applyProperty( attribute );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user