diff --git a/README.md b/README.md index 429b660f5..4605d4e39 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ It should look really familiar to any Android developer. This is a window with the most basic widgets in a vertical linear layout display. ```xml - + diff --git a/docs/articles/cssspecification.md b/docs/articles/cssspecification.md index f81f8898b..961659c2e 100644 --- a/docs/articles/cssspecification.md +++ b/docs/articles/cssspecification.md @@ -856,7 +856,7 @@ or one of the special constants. * `match_parent`: The element must be as big as its parent. * `wrap_content`: The element should be only big enough to enclose its content (plus padding). * Default value: `wrap_content` -* Aliases: `layout_height` +* Aliases: `layout_height`, `lh` --- @@ -928,7 +928,7 @@ layout weight. * Applicable to: Any element child of a EE::UI::UILinearLayout (LinearLayout) * Data Type: [number](#number-data-type) (normalized from `0` to `1`) * Default value: `0` -* Aliases: `layout_weight` +* Aliases: `layout_weight`, `lw8` --- @@ -946,7 +946,7 @@ or one of the special constants. * `match_parent`: The element must be as big as its parent. * `wrap_content`: The element should be only big enough to enclose its content (plus padding). * Default value: `wrap_content` -* Aliases: `layout_width` +* Aliases: `layout_width`, `lw` --- @@ -2067,6 +2067,13 @@ Read [background-position](https://developer.mozilla.org/en-US/docs/Web/CSS/back --- +### border + +Read [border](https://developer.mozilla.org/en-US/docs/Web/CSS/border) documentation. +`border-style` is not implemented yet. + +--- + ### border-color Read [border-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-color) documentation. diff --git a/include/eepp/scene/event.hpp b/include/eepp/scene/event.hpp index 5847b6582..46c62fd1d 100644 --- a/include/eepp/scene/event.hpp +++ b/include/eepp/scene/event.hpp @@ -60,7 +60,7 @@ class EE_API Event { OnTabAdded, OnTabClosed, OnTabNavigate, - OnClose, // Warning: Only some nodes will report this event. + OnClose, OnDragStart, OnDragStop, OnPaddingChange, diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index 01cef843e..3477485a0 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -390,7 +390,6 @@ Uint32 Node::onCalculateDrag( const Vector2f&, const Uint32& ) { void Node::onClose() { sendCommonEvent( Event::OnClose ); - invalidateDraw(); } Node* Node::getNextNode() const { diff --git a/src/eepp/ui/css/stylesheetspecification.cpp b/src/eepp/ui/css/stylesheetspecification.cpp index ab4b5f769..f0302f4b2 100644 --- a/src/eepp/ui/css/stylesheetspecification.cpp +++ b/src/eepp/ui/css/stylesheetspecification.cpp @@ -148,10 +148,11 @@ void StyleSheetSpecification::registerDefaultProperties() { registerProperty( "tooltip", "" ).setType( PropertyType::String ); registerProperty( "layout-weight", "" ) .addAlias( "layout_weight" ) + .addAlias( "lw8" ) .setType( PropertyType::NumberFloat ); registerProperty( "layout-gravity", "" ).addAlias( "layout_gravity" ); - registerProperty( "layout-width", "" ).addAlias( "layout_width" ); - registerProperty( "layout-height", "" ).addAlias( "layout_height" ); + registerProperty( "layout-width", "" ).addAlias( "layout_width" ).addAlias( "lw" ); + registerProperty( "layout-height", "" ).addAlias( "layout_height" ).addAlias( "lh" ); registerProperty( "layout-to-left-of", "" ).addAlias( "layout_to_left_of" ); registerProperty( "layout-to-right-of", "" ).addAlias( "layout_to_right_of" ); registerProperty( "layout-to-top-of", "" ).addAlias( "layout_to_top_of" ); @@ -417,6 +418,7 @@ void StyleSheetSpecification::registerDefaultProperties() { "vector2" ); registerShorthand( "min-size", { "min-width", "min-height" }, "vector2" ); registerShorthand( "max-size", { "max-width", "max-height" }, "vector2" ); + registerShorthand( "border", { "border-width", "border-style", "border-color" }, "border" ); } void StyleSheetSpecification::registerNodeSelector( const std::string& name, @@ -715,7 +717,7 @@ void StyleSheetSpecification::registerDefaultShorthandParsers() { if ( value.empty() ) return {}; std::vector properties; - const std::vector propNames( shorthand->getProperties() ); + const std::vector& propNames = shorthand->getProperties(); auto ltrbSplit = String::split( value, " ", "", "(\"" ); if ( !ltrbSplit.empty() ) { for ( size_t i = 0; i < propNames.size(); i++ ) { @@ -732,7 +734,7 @@ void StyleSheetSpecification::registerDefaultShorthandParsers() { if ( value.empty() ) return {}; std::vector properties; - const std::vector propNames( shorthand->getProperties() ); + const std::vector& propNames = shorthand->getProperties(); auto splits = String::split( value, '/' ); auto widths = String::split( splits[0], ' ' ); std::vector heights; @@ -758,7 +760,7 @@ void StyleSheetSpecification::registerDefaultShorthandParsers() { if ( value.empty() ) return {}; std::vector properties; - const std::vector propNames( shorthand->getProperties() ); + const std::vector& propNames = shorthand->getProperties(); std::vector values = String::split( value, ',' ); std::map> tmpProperties; @@ -809,12 +811,10 @@ void StyleSheetSpecification::registerDefaultShorthandParsers() { mShorthandParsers["background"] = [&]( const ShorthandDefinition* shorthand, std::string value ) -> std::vector { value = String::trim( value ); - if ( value.empty() ) - return {}; - if ( "none" == value ) + if ( value.empty() || "none" == value ) return {}; std::vector properties; - const std::vector propNames( shorthand->getProperties() ); + const std::vector& propNames = shorthand->getProperties(); std::vector tokens = String::split( value, " ", "", "(" ); std::string positionStr; @@ -843,8 +843,55 @@ void StyleSheetSpecification::registerDefaultShorthandParsers() { int pos = getIndexEndingWith( propNames, "-position" ); if ( pos != -1 ) { const ShorthandDefinition* shorthand = getShorthand( propNames[pos] ); - if ( NULL != shorthand ) - mShorthandParsers["background-position"]( shorthand, positionStr ); + if ( NULL != shorthand ) { + auto bpVec = mShorthandParsers["background-position"]( shorthand, positionStr ); + for ( auto& bp : bpVec ) + properties.emplace_back( bp ); + } + } + } + + return properties; + }; + + mShorthandParsers["border"] = [&]( const ShorthandDefinition* shorthand, + std::string value ) -> std::vector { + value = String::trim( value ); + if ( value.empty() || "none" == value ) + return {}; + + std::vector properties; + const std::vector& propNames = shorthand->getProperties(); + std::vector tokens = String::split( value, " ", "", "(" ); + + for ( auto& tok : tokens ) { + if ( -1 != + String::valueIndex( + tok, "none;hidden;dotted;dashed;solid;double;groove;ridge;inset;outset" ) ) { + int pos = getIndexEndingWith( propNames, "-style" ); + // boder-style is not implemented yet + if ( pos != -1 ) + continue; + } else if ( Color::isColorString( tok ) ) { + int pos = getIndexEndingWith( propNames, "-color" ); + if ( pos != -1 ) { + const ShorthandDefinition* shorthand = getShorthand( propNames[pos] ); + if ( NULL != shorthand ) { + auto bbVec = mShorthandParsers["border-box"]( shorthand, tok ); + for ( auto& bb : bbVec ) + properties.emplace_back( bb ); + } + } + } else { + int pos = getIndexEndingWith( propNames, "-width" ); + if ( pos != -1 ) { + const ShorthandDefinition* shorthand = getShorthand( propNames[pos] ); + if ( NULL != shorthand ) { + auto bbVec = mShorthandParsers["border-box"]( shorthand, tok ); + for ( auto& bb : bbVec ) + properties.emplace_back( bb ); + } + } } } diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 4f02b6737..99ee49dbe 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -45,6 +45,9 @@ UIDropDownList::UIDropDownList( const std::string& tag ) : cb::Make1( this, &UIDropDownList::onItemKeyDown ) ); mListBox->addEventListener( Event::KeyDown, cb::Make1( this, &UIDropDownList::onItemKeyDown ) ); mListBox->addEventListener( Event::OnClear, cb::Make1( this, &UIDropDownList::onWidgetClear ) ); + mListBox->addEventListener( Event::OnClose, [&]( const Event* ) { + mListBox = nullptr; + } ); } UIDropDownList::~UIDropDownList() { diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index 01e235c9e..9a699bd7c 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -71,9 +71,8 @@ UIImage* UIImage::setDrawable( Drawable* drawable, bool ownIt ) { void UIImage::onAutoSize() { if ( NULL != mDrawable ) { - if ( ( mFlags & UI_AUTO_SIZE ) && Sizef::Zero == getSize() ) { - setInternalSize( mDrawable->getSize() ); - } + if ( ( mFlags & UI_AUTO_SIZE ) && Sizef::Zero == getSize() ) + setInternalSize( mDrawable->getSize().asInt().asFloat() ); Sizef size( getSize() ); diff --git a/src/eepp/ui/uipopupmenu.cpp b/src/eepp/ui/uipopupmenu.cpp index d92d41a5b..71b5c70a7 100644 --- a/src/eepp/ui/uipopupmenu.cpp +++ b/src/eepp/ui/uipopupmenu.cpp @@ -18,7 +18,6 @@ UIPopUpMenu::UIPopUpMenu() : UIMenu() { } UIPopUpMenu::~UIPopUpMenu() { - onClose(); } Uint32 UIPopUpMenu::getType() const { diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index ea13edc69..36ea18675 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -57,6 +57,8 @@ UIWidget::UIWidget( const std::string& tag ) : UIWidget::UIWidget() : UIWidget( "widget" ) {} UIWidget::~UIWidget() { + onClose(); + if ( mUISceneNode && mUISceneNode->getUIEventDispatcher() && mUISceneNode->getUIEventDispatcher()->getNodeDragging() == this ) mUISceneNode->getUIEventDispatcher()->setNodeDragging( nullptr ); @@ -1474,9 +1476,9 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) { std::string val = attribute.asString(); String::toLowerInPlace( val ); - if ( "match_parent" == val || "match-parent" == val ) { + if ( "match_parent" == val || "match-parent" == val || "mp" == val ) { setLayoutWidthPolicy( SizePolicy::MatchParent ); - } else if ( "wrap_content" == val || "wrap-content" == val ) { + } else if ( "wrap_content" == val || "wrap-content" == val || "wc" == val ) { setLayoutWidthPolicy( SizePolicy::WrapContent ); } else if ( "fixed" == val ) { setLayoutWidthPolicy( SizePolicy::Fixed ); @@ -1497,9 +1499,9 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) { std::string val = attribute.asString(); String::toLowerInPlace( val ); - if ( "match_parent" == val ) { + if ( "match_parent" == val || "match-parent" == val || "mp" == val ) { setLayoutHeightPolicy( SizePolicy::MatchParent ); - } else if ( "wrap_content" == val ) { + } else if ( "wrap_content" == val || "wrap-content" == val || "wc" == val ) { setLayoutHeightPolicy( SizePolicy::WrapContent ); } else if ( "fixed" == val ) { setLayoutHeightPolicy( SizePolicy::Fixed ); diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 50a4beea3..16ff3ca8a 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -109,8 +109,6 @@ UIWindow::~UIWindow() { sendCommonEvent( Event::OnWindowClose ); - onClose(); - eeSAFE_DELETE( mFrameBuffer ); }