diff --git a/include/eepp/ui/css/stylesheetselector.hpp b/include/eepp/ui/css/stylesheetselector.hpp index 17443351a..8638a6817 100644 --- a/include/eepp/ui/css/stylesheetselector.hpp +++ b/include/eepp/ui/css/stylesheetselector.hpp @@ -27,7 +27,7 @@ class EE_API StyleSheetSelector { bool hasPseudoClasses() const; - std::vector getRelatedElements( UIWidget* element, bool applyPseudo = true ) const; + SmallVector getRelatedElements( UIWidget* element, bool applyPseudo = true ) const; bool isStructurallyVolatile() const; diff --git a/include/eepp/ui/databinding/uiproperty.hpp b/include/eepp/ui/databinding/uiproperty.hpp index f03dd8e27..c5af9fd39 100644 --- a/include/eepp/ui/databinding/uiproperty.hpp +++ b/include/eepp/ui/databinding/uiproperty.hpp @@ -123,7 +123,7 @@ template class UIProperty { } /** @return All currently connected widgets, or an empty vector after expiration. */ - std::vector widgets() const { + SmallVector widgets() const { auto state = mState.lock(); if ( !state || !state->property || !state->property->databind().isInitialized() ) return {}; diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index ee3eef0a8..1cf64a17b 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -1516,8 +1516,14 @@ class EE_API UINode : public Node { /** @brief Get a widget's computed absolute font size in pixels. */ Float getAbsoluteFontSize( const UIWidget* widget ) const; + /** Returns true if the node is currently being created, this state is not used by all node + * types. + */ bool isCreatingNode() const; + /** Forces a left mouse click event over the node */ + void click(); + protected: Vector2f mDpPos; Sizef mDpSize; diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 0e360ee46..d023eaf20 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -858,7 +858,8 @@ class EE_API UISceneNode : public SceneNode { * @param marker Marker for style association. * @return Vector of root widgets created. */ - std::vector loadNode( pugi::xml_node node, Node* parent, const Uint32& marker = 0 ); + SmallVector loadNode( pugi::xml_node node, Node* parent, + const Uint32& marker = 0 ); /** Sets the document / scene URI used to resolve paths of inner elements */ void setURI( const URI& uri ); diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index 1fabedec0..671586ad4 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -23,6 +23,7 @@ namespace EE { namespace UI { class UITooltip; class UIStyle; +class UIWidget; struct MarginAuto { static constexpr auto Left = ( 1 << 0 ); @@ -31,6 +32,8 @@ struct MarginAuto { static constexpr auto Bottom = ( 1 << 3 ); }; +using WidgetQueryResult = SmallVector; + /** * @brief Base class for all UI widgets in the eepp framework. * @@ -1118,7 +1121,7 @@ class EE_API UIWidget : public UINode { * @param className The CSS class to search for. * @return Vector of matching UIWidget pointers. */ - std::vector findAllByClass( const std::string& className ); + WidgetQueryResult findAllByClass( const std::string& className ); /** * @brief Finds all widgets by CSS tag. @@ -1128,7 +1131,7 @@ class EE_API UIWidget : public UINode { * @param tag The CSS tag to search for. * @return Vector of matching UIWidget pointers. */ - std::vector findAllByTag( const std::string& tag ); + WidgetQueryResult findAllByTag( const std::string& tag ); /** * @brief Finds a widget by CSS class. @@ -1190,7 +1193,7 @@ class EE_API UIWidget : public UINode { * @param selector The CSS selector to use. * @return Vector of all matching UIWidget pointers. */ - std::vector querySelectorAll( const CSS::StyleSheetSelector& selector ); + WidgetQueryResult querySelectorAll( const CSS::StyleSheetSelector& selector ); /** * @brief Queries all widgets using a CSS selector string. @@ -1200,7 +1203,7 @@ class EE_API UIWidget : public UINode { * @param selector The CSS selector string to use. * @return Vector of all matching UIWidget pointers. */ - std::vector querySelectorAll( const std::string& selector ); + WidgetQueryResult querySelectorAll( const std::string& selector ); /** * @brief Gets a property value as a string. diff --git a/src/eepp/ui/css/stylesheetselector.cpp b/src/eepp/ui/css/stylesheetselector.cpp index a673cd37a..1ee064166 100644 --- a/src/eepp/ui/css/stylesheetselector.cpp +++ b/src/eepp/ui/css/stylesheetselector.cpp @@ -237,10 +237,10 @@ bool StyleSheetSelector::selectComplex( UIWidget* element, const bool& applyPseu return true; } -std::vector StyleSheetSelector::getRelatedElements( UIWidget* element, - bool applyPseudo ) const { - static std::vector EMPTY_ELEMENTS; - std::vector elements; +SmallVector StyleSheetSelector::getRelatedElements( UIWidget* element, + bool applyPseudo ) const { + static SmallVector EMPTY_ELEMENTS; + SmallVector elements; if ( mSelectorRules.empty() ) return elements; diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 35b379ea4..894d5d0dd 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -1905,4 +1905,10 @@ bool UINode::isCreatingNode() const { return mFlags & UI_CREATING_NODE; } +void UINode::click() { + Vector2f pos; + nodeToWorld( pos ); + getEventDispatcher()->sendMouseClick( this, pos.ceil().asInt(), EE_BUTTON_LMASK ); +} + }} // namespace EE::UI diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index 5f13fb277..ffe6eeb45 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -546,12 +546,12 @@ bool UISceneNode::windowExists( UIWindow* win ) { return mWindowsList.end() != std::find( mWindowsList.begin(), mWindowsList.end(), win ); } -std::vector UISceneNode::loadNode( pugi::xml_node node, Node* parent, +SmallVector UISceneNode::loadNode( pugi::xml_node node, Node* parent, const Uint32& marker ) { Uint32 oldMarker = mCurrentMarker; mCurrentMarker = marker; - std::vector rootWidgets; + SmallVector rootWidgets; if ( NULL == parent ) parent = this; @@ -646,7 +646,7 @@ UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent, const std::string id( node.attribute( "id" ).as_string() ); mIsLoading = true; Clock innerClock; - std::vector widgets = loadNode( node, parent, marker ); + SmallVector widgets = loadNode( node, parent, marker ); if ( mVerbose ) { std::sort( diff --git a/src/eepp/ui/uistyle.cpp b/src/eepp/ui/uistyle.cpp index 5d253e63c..1b3a31bee 100644 --- a/src/eepp/ui/uistyle.cpp +++ b/src/eepp/ui/uistyle.cpp @@ -581,8 +581,7 @@ void UIStyle::subscribeNonCacheableStyles() { return; for ( auto& style : mGlobalDefinition->getStyles() ) { if ( !style->getSelector().isCacheable() ) { - std::vector elements = - style->getSelector().getRelatedElements( mWidget, false ); + auto elements = style->getSelector().getRelatedElements( mWidget, false ); if ( !elements.empty() ) { for ( auto& element : elements ) { diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 06d362a4d..54db7b793 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -1557,8 +1557,8 @@ const Uint32& UIWidget::getStylePreviousState() const { return NULL != mStyle ? mStyle->getPreviousState() : mState; } -std::vector UIWidget::findAllByClass( const std::string& className ) { - std::vector widgets; +WidgetQueryResult UIWidget::findAllByClass( const std::string& className ) { + WidgetQueryResult widgets; if ( !isClosing() && hasClass( className ) && !inClosingTree() ) { widgets.push_back( this ); @@ -1568,8 +1568,7 @@ std::vector UIWidget::findAllByClass( const std::string& className ) while ( NULL != child ) { if ( child->isWidget() ) { - std::vector foundWidgets = - child->asType()->findAllByClass( className ); + WidgetQueryResult foundWidgets = child->asType()->findAllByClass( className ); if ( !foundWidgets.empty() ) widgets.insert( widgets.end(), foundWidgets.begin(), foundWidgets.end() ); @@ -1581,8 +1580,8 @@ std::vector UIWidget::findAllByClass( const std::string& className ) return widgets; } -std::vector UIWidget::findAllByTag( const std::string& tag ) { - std::vector widgets; +WidgetQueryResult UIWidget::findAllByTag( const std::string& tag ) { + WidgetQueryResult widgets; if ( !isClosing() && getElementTag() == tag && !inClosingTree() ) { widgets.push_back( this ); @@ -1592,7 +1591,7 @@ std::vector UIWidget::findAllByTag( const std::string& tag ) { while ( NULL != child ) { if ( child->isWidget() ) { - std::vector foundWidgets = child->asType()->findAllByTag( tag ); + WidgetQueryResult foundWidgets = child->asType()->findAllByTag( tag ); if ( !foundWidgets.empty() ) widgets.insert( widgets.end(), foundWidgets.begin(), foundWidgets.end() ); @@ -1667,8 +1666,8 @@ UIWidget* UIWidget::querySelector( const CSS::StyleSheetSelector& selector ) { return NULL; } -std::vector UIWidget::querySelectorAll( const CSS::StyleSheetSelector& selector ) { - std::vector widgets; +WidgetQueryResult UIWidget::querySelectorAll( const CSS::StyleSheetSelector& selector ) { + WidgetQueryResult widgets; if ( !isClosing() && !inClosingTree() && selector.select( this ) ) { widgets.push_back( this ); @@ -1678,7 +1677,7 @@ std::vector UIWidget::querySelectorAll( const CSS::StyleSheetSelector while ( NULL != child ) { if ( child->isWidget() ) { - std::vector foundWidgets = + WidgetQueryResult foundWidgets = child->asType()->querySelectorAll( selector ); if ( !foundWidgets.empty() ) @@ -1714,7 +1713,7 @@ UIWidget* UIWidget::querySelector( const std::string& selector ) { return querySelector( CSS::StyleSheetSelector( selector ) ); } -std::vector UIWidget::querySelectorAll( const std::string& selector ) { +WidgetQueryResult UIWidget::querySelectorAll( const std::string& selector ) { return querySelectorAll( CSS::StyleSheetSelector( selector ) ); } diff --git a/src/tests/unit_tests/uihtml_tests.cpp b/src/tests/unit_tests/uihtml_tests.cpp index 3f58f51e5..76abdbce6 100644 --- a/src/tests/unit_tests/uihtml_tests.cpp +++ b/src/tests/unit_tests/uihtml_tests.cpp @@ -5837,7 +5837,7 @@ UTEST( UIHTML, RonStonerDeferredImagesUpdateDocumentHeight ) { ASSERT_TRUE( documentScene != nullptr ); UIWidget* body = nullptr; - std::vector images; + WidgetQueryResult images; for ( int i = 0; i < 300; ++i ) { pump(); body = documentScene->getRoot()->findByType( UI_TYPE_HTML_BODY )->asType(); diff --git a/src/tools/ecode/plugins/git/gitplugin.hpp b/src/tools/ecode/plugins/git/gitplugin.hpp index dda3cf11e..078880554 100644 --- a/src/tools/ecode/plugins/git/gitplugin.hpp +++ b/src/tools/ecode/plugins/git/gitplugin.hpp @@ -157,7 +157,7 @@ class GitPlugin : public PluginBase { UIDropDownList* mPanelSwicher{ nullptr }; UIDropDownList* mRepoDropDown{ nullptr }; UIStackWidget* mStackWidget{ nullptr }; - std::vector mStackMap; + SmallVector mStackMap; UIWidget* mGitContentView{ nullptr }; UIWidget* mGitNoContentView{ nullptr }; UIWidget* mConflictStateBar{ nullptr };