diff --git a/bin/assets/ui/breeze.css b/bin/assets/ui/breeze.css index 9fb5c6db3..a7b856678 100644 --- a/bin/assets/ui/breeze.css +++ b/bin/assets/ui/breeze.css @@ -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 { diff --git a/docs/articles/cssspecification.md b/docs/articles/cssspecification.md index 539a77279..95d57838d 100644 --- a/docs/articles/cssspecification.md +++ b/docs/articles/cssspecification.md @@ -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. diff --git a/include/eepp/ui/css/propertydefinition.hpp b/include/eepp/ui/css/propertydefinition.hpp index 9c6b14504..727669595 100644 --- a/include/eepp/ui/css/propertydefinition.hpp +++ b/include/eepp/ui/css/propertydefinition.hpp @@ -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" ), diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 4fed3d5ef..7b8725eeb 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -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 }; diff --git a/src/eepp/ui/css/stylesheetspecification.cpp b/src/eepp/ui/css/stylesheetspecification.cpp index 8d9250292..af62c6ed8 100644 --- a/src/eepp/ui/css/stylesheetspecification.cpp +++ b/src/eepp/ui/css/stylesheetspecification.cpp @@ -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 ); diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 815dfc294..24a62c241 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -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 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 ); }