From 38bb518bd3f172e4504cac75c3c1a458bbc12d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 4 Jun 2022 00:33:17 -0300 Subject: [PATCH] UIWidget: Added virtual function "acceptsDropOfWidget" and "acceptsDropOfWidgetInTree". Added UI_TOOLTIP_ENABLED that allows to enable/disable tooltips in an element. Added functions: "isTooltipEnabled" and "setTooltipEnabled". UITabWidget: Added support to draggable object hovering highlight color. UICodeEditor: fixed vertical scroll. Added UIRoot class, that represents the root (":root") element of the scene node. --- bin/assets/ui/breeze.css | 26 ++++++++++++--- docs/articles/cssspecification.md | 11 ++++++ include/eepp/scene/node.hpp | 8 +++-- include/eepp/ui/css/propertydefinition.hpp | 1 + include/eepp/ui/uihelper.hpp | 3 +- include/eepp/ui/uinode.hpp | 2 ++ include/eepp/ui/uiroot.hpp | 25 ++++++++++++++ include/eepp/ui/uitab.hpp | 12 ++++--- include/eepp/ui/uitabwidget.hpp | 11 ++++-- include/eepp/ui/uiwidget.hpp | 8 +++++ projects/linux/ee.files | 2 ++ src/eepp/scene/node.cpp | 8 ++--- src/eepp/ui/css/stylesheetspecification.cpp | 2 ++ src/eepp/ui/uinode.cpp | 27 +++++++++++++++ src/eepp/ui/uiroot.cpp | 37 +++++++++++++++++++++ src/eepp/ui/uiscenenode.cpp | 3 +- src/eepp/ui/uitab.cpp | 33 ++++++++++++++++-- src/eepp/ui/uitabwidget.cpp | 20 ++++++++++- src/eepp/ui/uiwidget.cpp | 37 +++++++++++++++++++-- 19 files changed, 250 insertions(+), 26 deletions(-) create mode 100644 include/eepp/ui/uiroot.hpp create mode 100644 src/eepp/ui/uiroot.cpp diff --git a/bin/assets/ui/breeze.css b/bin/assets/ui/breeze.css index 5eab97eab..e76e911f7 100644 --- a/bin/assets/ui/breeze.css +++ b/bin/assets/ui/breeze.css @@ -38,6 +38,7 @@ --menu-font-disabled: #6e7275; --win-icon: #dbdbdd; --floating-icon: #eff0f188; + droppable-hovering-color: #FFFFFF20; } pushbutton::icon, @@ -953,6 +954,15 @@ ScrollBarMini::hbutton:hover { background-color: var(--back); } +tab::icon { + tint: var(--icon); +} + +tab:selected > tab::icon, +tab:not(:selected):hover > tab::icon { + tint: var(--menu-font-active); +} + @media (prefers-color-scheme: light) { :root { @@ -994,6 +1004,7 @@ ScrollBarMini::hbutton:hover { --menu-font-disabled: #a8a9aa; --win-icon: #232627; --floating-icon: #cbcdcd; + droppable-hovering-color: #00000020; } Menu::Item:selected, @@ -1014,11 +1025,7 @@ Menu::item:hover > Menu::RadioButton::icon, PushButton:pressed > PushButton::icon, SelectButton:pressed > SelectButton::icon, SelectButton:selected > SelectButton::icon, -SelectButton:selectedpressed > SelectButton::icon { - color: var(--menu-font-active); - tint: var(--menu-font-active); -} - +SelectButton:selectedpressed > SelectButton::icon, tableview::row:selected tableview::cell::text, treeview::row:selected treeview::cell::text, listview::row:selected listview::cell::text, @@ -1059,6 +1066,15 @@ Tooltip { color: var(--back)!important; } +tab::icon, +tab:selected > tab::icon, { + tint: var(--icon); +} + +tab:not(:selected):hover > tab::icon { + tint: var(--menu-font-active); +} + } @media screen and (min-pixel-density: 1.1) and (max-pixel-density: 1.99) { diff --git a/docs/articles/cssspecification.md b/docs/articles/cssspecification.md index 61121ef60..c2bb2f382 100644 --- a/docs/articles/cssspecification.md +++ b/docs/articles/cssspecification.md @@ -520,6 +520,17 @@ Sets the amount of drag that is needed to start dragging an element. --- +### droppable-hovering-color + +Sets the foreground color to highlight the current dragged element that its is hovering +an element that accepts a drop of the dragged element. + +* Applicatable to: EE::UI::UITabWidget (TabWidget), EE::UI::UIRoot (:root) +* Data Type: [color](#color-data-type) +* Default value: `#FFFFFF20` + +--- + ### enabled Sets if the element is enabled diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index 7f76d2d1b..51b6e82d4 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -46,7 +46,7 @@ enum NodeFlags { NODE_FLAG_DRAGGING = ( 1 << 11 ), NODE_FLAG_SKIN_OWNER = ( 1 << 12 ), NODE_FLAG_TOUCH_DRAGGING = ( 1 << 13 ), - NODE_FLAG_DISABLED_BY_NODE = ( 1 << 14 ), + NODE_FLAG_DROPPABLE_HOVERING = ( 1 << 14 ), NODE_FLAG_OWNED_BY_NODE = ( 1 << 15 ), NODE_FLAG_REVERSE_DRAW = ( 1 << 16 ), NODE_FLAG_FRAME_BUFFER = ( 1 << 17 ), @@ -209,7 +209,7 @@ class EE_API Node : public Transformable { const Rectf& getWorldBounds(); - bool isParentOf( Node* node ) const; + bool isParentOf( const Node* node ) const; void sendEvent( const Event* Event ); @@ -238,6 +238,10 @@ class EE_API Node : public Transformable { template T* asType() { return reinterpret_cast( this ); } + template const T* asConstType() const { + return reinterpret_cast( this ); + } + Node* findByType( const Uint32& type ) const; template T* findByType( const Uint32& type ) const { diff --git a/include/eepp/ui/css/propertydefinition.hpp b/include/eepp/ui/css/propertydefinition.hpp index 58d68f76c..b7f422819 100644 --- a/include/eepp/ui/css/propertydefinition.hpp +++ b/include/eepp/ui/css/propertydefinition.hpp @@ -196,6 +196,7 @@ enum class PropertyId : Uint32 { TabAllowSwitchTabsInEmptySpaces = String::hash( "tabbar-allow-switch-tabs-in-empty-spaces" ), SplitterPartition = String::hash( "splitter-partition" ), SplitterAlwaysShow = String::hash( "splitter-always-show" ), + DroppableHoveringColor = String::hash( "droppable-hovering-color" ) }; enum class PropertyType : Uint32 { diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index 537a0058e..1be954c97 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -39,7 +39,8 @@ enum UIFlag { UI_OWNS_CHILDS_POSITION = ( 1 << 22 ), UI_DRAG_VERTICAL = ( 1 << 23 ), UI_DRAG_HORIZONTAL = ( 1 << 24 ), - UI_TAB_FOCUSABLE = ( 1 << 25 ) + UI_TAB_FOCUSABLE = ( 1 << 25 ), + UI_TOOLTIP_ENABLED = ( 1 << 26 ) }; enum UINodeType { diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index 287f4fdda..591fb06a5 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -324,6 +324,8 @@ class EE_API UINode : public Node { virtual void onSceneChange(); + virtual void drawDroppableHovering(); + void checkClose(); virtual void onWidgetFocusLoss(); diff --git a/include/eepp/ui/uiroot.hpp b/include/eepp/ui/uiroot.hpp new file mode 100644 index 000000000..0ba0d604b --- /dev/null +++ b/include/eepp/ui/uiroot.hpp @@ -0,0 +1,25 @@ +#ifndef EE_UI_UIROOT_HPP +#define EE_UI_UIROOT_HPP + +#include + +namespace EE { namespace UI { + +class EE_API UIRoot : public UIWidget { + public: + static UIRoot* New(); + + protected: + UIRoot() : UIWidget( ":root" ) {} + + Color mDroppableHoveringColor{ Color::Transparent }; + + std::string getPropertyString( const PropertyDefinition* propertyDef, + const Uint32& propertyIndex ); + + bool applyProperty( const StyleSheetProperty& attribute ); +}; + +}} // namespace EE::UI + +#endif diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index b9cbaa0e4..29477f0dc 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -34,19 +34,21 @@ class EE_API UITab : public UISelectButton { virtual std::string getPropertyString( const PropertyDefinition* propertyDef, const Uint32& propertyIndex = 0 ); - UITabWidget* getTabWidget(); + UITabWidget* getTabWidget() const; virtual UIWidget* getExtraInnerWidget() const; protected: friend class UITabWidget; - Node* mOwnedWidget; + Node* mOwnedWidget{ nullptr }; String mText; std::string mOwnedName; - mutable UIWidget* mCloseButton{nullptr}; - Float mDragTotalDiff; - UITabWidget* mTabWidget; + mutable UIWidget* mCloseButton{ nullptr }; + Float mDragTotalDiff{ 0.f }; + UITabWidget* mTabWidget{ nullptr }; + UIWidget* mCurDropWidget{ nullptr }; + bool mWasToolipEnabled{ true }; Uint32 onDrag( const Vector2f& position, const Uint32& flags, const Sizef& dragDiff ); diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index dd9bbf79e..7229f48d5 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -1,5 +1,5 @@ -#ifndef EE_UICUITABWIDGET_HPP -#define EE_UICUITABWIDGET_HPP +#ifndef EE_UI_UITABWIDGET_HPP +#define EE_UI_UITABWIDGET_HPP #include #include @@ -156,6 +156,12 @@ class EE_API UITabWidget : public UIWidget { void setAllowSwitchTabsInEmptySpaces( bool allowSwitchTabsInEmptySpaces ); + virtual bool acceptsDropOfWidget( const UIWidget* widget ); + + const Color& getDroppableHoveringColor() const; + + void setDroppableHoveringColor( const Color& droppableHoveringColor ); + protected: friend class UITab; @@ -172,6 +178,7 @@ class EE_API UITabWidget : public UIWidget { bool mAllowDragAndDropTabs; bool mAllowSwitchTabsInEmptySpaces; Float mTabVerticalDragResistance; + Color mDroppableHoveringColor{ Color::Transparent }; void onThemeLoaded(); diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index ab377ede8..7a9850433 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -55,6 +55,10 @@ class EE_API UIWidget : public UINode { virtual const Sizef& getSize() const; + virtual bool acceptsDropOfWidget( const UIWidget* widget ); + + UIWidget* acceptsDropOfWidgetInTree( const UIWidget* widget ); + UITooltip* getTooltip(); void tooltipRemove(); @@ -245,6 +249,10 @@ class EE_API UIWidget : public UINode { bool hasPseudoClass( const std::string& pseudoCls ) const; + bool isTooltipEnabled() const; + + void setTooltipEnabled( bool enabled ); + protected: friend class UIManager; friend class UISceneNode; diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 9e81aba2d..57e458d88 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -392,6 +392,7 @@ ../../include/eepp/ui/uipushbutton.hpp ../../include/eepp/ui/uiradiobutton.hpp ../../include/eepp/ui/uirelativelayout.hpp +../../include/eepp/ui/uiroot.hpp ../../include/eepp/ui/uiscenenode.hpp ../../include/eepp/ui/uiscrollablewidget.hpp ../../include/eepp/ui/uiscrollbar.hpp @@ -870,6 +871,7 @@ ../../src/eepp/ui/uipushbutton.cpp ../../src/eepp/ui/uiradiobutton.cpp ../../src/eepp/ui/uirelativelayout.cpp +../../src/eepp/ui/uiroot.cpp ../../src/eepp/ui/uiscenenode.cpp ../../src/eepp/ui/uiscrollablewidget.cpp ../../src/eepp/ui/uiscrollbar.cpp diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index dee6d5118..70246e1f0 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -261,7 +261,7 @@ Node* Node::setParent( Node* parent ) { return this; } -bool Node::isParentOf( Node* node ) const { +bool Node::isParentOf( const Node* node ) const { eeASSERT( NULL != node ); Node* tParent = node->getParent(); while ( NULL != tParent ) { @@ -472,7 +472,7 @@ void Node::onSizeChange() { Rectf Node::getScreenBounds() { return Rectf( Vector2f( mScreenPosi.x, mScreenPosi.y ), - Sizef( ( Float )(int)mSize.getWidth(), ( Float )(int)mSize.getHeight() ) ); + Sizef( (Float)(int)mSize.getWidth(), (Float)(int)mSize.getHeight() ) ); } Rectf Node::getLocalBounds() const { @@ -483,8 +483,8 @@ const Uint32& Node::getNodeFlags() const { return mNodeFlags; } -void Node::setNodeFlags( const Uint32& Flags ) { - mNodeFlags = Flags; +void Node::setNodeFlags( const Uint32& flags ) { + mNodeFlags = flags; } void Node::drawChilds() { diff --git a/src/eepp/ui/css/stylesheetspecification.cpp b/src/eepp/ui/css/stylesheetspecification.cpp index 816a50efa..0cb460282 100644 --- a/src/eepp/ui/css/stylesheetspecification.cpp +++ b/src/eepp/ui/css/stylesheetspecification.cpp @@ -370,6 +370,8 @@ void StyleSheetSpecification::registerDefaultProperties() { .setRelativeTarget( PropertyRelativeTarget::LocalBlockWidth ); registerProperty( "splitter-always-show", "true" ).setType( PropertyType::Bool ); + registerProperty( "droppable-hovering-color", "#FFFFFF20" ).setType( PropertyType::Color ); + // Shorthands registerShorthand( "margin", { "margin-top", "margin-right", "margin-bottom", "margin-left" }, "box" ); diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index a0667739d..46ec0a278 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -332,6 +332,30 @@ void UINode::drawOverNode() { } } +void UINode::drawDroppableHovering() { + const PropertyDefinition* def = + StyleSheetSpecification::instance()->getProperty( "droppable-hovering-color" ); + Color color = Color::fromString( def->getDefaultValue() ); + if ( isWidget() ) { + UIWidget* widget = asType(); + std::string colorString = widget->getPropertyString( def ); + if ( !colorString.empty() ) { + color = Color::fromString( colorString ); + } else { + colorString = mUISceneNode->getRoot()->getPropertyString( def ); + if ( !colorString.empty() ) + color = Color::fromString( colorString ); + } + } + + Primitives P; + P.setFillMode( DRAW_FILL ); + P.setBlendMode( getBlendMode() ); + P.setColor( color ); + P.setLineWidth( PixelDensity::dpToPxI( 1 ) ); + P.drawRectangle( getScreenBounds() ); +} + void UINode::updateDebugData() { if ( NULL != mSceneNode && mSceneNode->getDrawDebugData() && isWidget() && NULL != getEventDispatcher() && getEventDispatcher()->getMouseOverNode() == this ) { @@ -765,6 +789,9 @@ void UINode::nodeDraw() { drawBorder(); + if ( mNodeFlags & NODE_FLAG_DROPPABLE_HOVERING ) + drawDroppableHovering(); + drawHighlightFocus(); drawOverNode(); diff --git a/src/eepp/ui/uiroot.cpp b/src/eepp/ui/uiroot.cpp new file mode 100644 index 000000000..8b5eced0c --- /dev/null +++ b/src/eepp/ui/uiroot.cpp @@ -0,0 +1,37 @@ +#include + +namespace EE { namespace UI { + +UIRoot* UIRoot::New() { + return eeNew( UIRoot, () ); +} + +std::string UIRoot::getPropertyString( const PropertyDefinition* propertyDef, + const Uint32& propertyIndex ) { + if ( NULL == propertyDef ) + return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::DroppableHoveringColor: + return mDroppableHoveringColor.toHexString(); + default: + return UIWidget::getPropertyString( propertyDef, propertyIndex ); + } +} + +bool UIRoot::applyProperty( const StyleSheetProperty& attribute ) { + if ( !checkPropertyDefinition( attribute ) ) + return false; + + switch ( attribute.getPropertyDefinition()->getPropertyId() ) { + case PropertyId::DroppableHoveringColor: + mDroppableHoveringColor = attribute.asColor(); + break; + default: + return UIWidget::applyProperty( attribute ); + } + + return true; +} + +}} // namespace EE::UI diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index f7f518774..0a2c6cee7 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,7 @@ UISceneNode::UISceneNode( EE::Window::Window* window ) : setEventDispatcher( UIEventDispatcher::New( this ) ); - mRoot = UIWidget::NewWithTag( ":root" ); + mRoot = UIRoot::New(); mRoot->setParent( this )->setPosition( 0, 0 )->setId( "uiscenenode_root_node" ); mRoot->enableReportSizeChangeToChilds(); diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index e9449c057..398cbf4b2 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace EE { namespace UI { @@ -37,7 +38,7 @@ bool UITab::isType( const Uint32& type ) const { return UITab::getType() == type ? true : UISelectButton::isType( type ); } -UITabWidget* UITab::getTabWidget() { +UITabWidget* UITab::getTabWidget() const { if ( NULL != getParent() && NULL != getParent()->getParent() && getParent()->getParent()->isType( UI_TYPE_TABWIDGET ) ) { return getParent()->getParent()->asType(); @@ -67,7 +68,7 @@ Uint32 UITab::onDrag( const Vector2f& pos, const Uint32&, const Sizef& dragDiff tabW->swapTabs( tab, this ); } if ( tabW->getAllowDragAndDropTabs() && !( mFlags & UI_DRAG_VERTICAL ) ) { - mDragTotalDiff += ( Float )( mDragPoint.y - pos.y ); + mDragTotalDiff += (Float)( mDragPoint.y - pos.y ); if ( eeabs( mDragTotalDiff ) >= tabW->getTabVerticalDragResistance() ) { setFlags( UI_DRAG_VERTICAL ); setPixelsPosition( mPosition.x, mPosition.y - mDragTotalDiff ); @@ -79,6 +80,25 @@ Uint32 UITab::onDrag( const Vector2f& pos, const Uint32&, const Sizef& dragDiff setPixelsPosition( pos - posDiff ); } } + + setEnabled( false ); + Node* overFind = getUISceneNode()->overFind( pos ); + setEnabled( true ); + + if ( overFind && overFind->isType( UI_TYPE_WIDGET ) ) { + UIWidget* widget = overFind->asType()->acceptsDropOfWidgetInTree( this ); + + if ( mCurDropWidget ) { + mCurDropWidget->writeNodeFlag( NODE_FLAG_DROPPABLE_HOVERING, 0 ); + mCurDropWidget = nullptr; + } + + if ( widget ) { + mCurDropWidget = widget; + mCurDropWidget->writeNodeFlag( NODE_FLAG_DROPPABLE_HOVERING, 1 ); + } + } + return 1; } @@ -86,6 +106,9 @@ Uint32 UITab::onDragStart( const Vector2i& position, const Uint32& flags ) { UITabWidget* tabW = getTabWidget(); mTabWidget = NULL; mDragTotalDiff = 0; + mWasToolipEnabled = isTooltipEnabled(); + if ( mWasToolipEnabled ) + setTooltipEnabled( false ); unsetFlags( UI_DRAG_VERTICAL ); if ( tabW ) { for ( size_t i = 0; i < tabW->getTabCount(); i++ ) { @@ -99,11 +122,17 @@ Uint32 UITab::onDragStart( const Vector2i& position, const Uint32& flags ) { } Uint32 UITab::onDragStop( const Vector2i& position, const Uint32& flags ) { + if ( mWasToolipEnabled ) + setTooltipEnabled( true ); UITabWidget* tabW = getTabWidget(); if ( mTabWidget ) { setParent( tabW->getTabBar() ); mTabWidget = NULL; } + if ( mCurDropWidget ) { + mCurDropWidget->writeNodeFlag( NODE_FLAG_DROPPABLE_HOVERING, 0 ); + mCurDropWidget = nullptr; + } if ( tabW ) { for ( size_t i = 0; i < tabW->getTabCount(); i++ ) { UITab* tab = tabW->getTab( i ); diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index d2784b737..75437d46b 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -168,6 +168,8 @@ std::string UITabWidget::getPropertyString( const PropertyDefinition* propertyDe return getAllowDragAndDropTabs() ? "true" : "false"; case PropertyId::TabAllowSwitchTabsInEmptySpaces: return getAllowSwitchTabsInEmptySpaces() ? "true" : "false"; + case PropertyId::DroppableHoveringColor: + return getDroppableHoveringColor().toHexString(); default: return UIWidget::getPropertyString( propertyDef, propertyIndex ); } @@ -245,6 +247,8 @@ bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) { break; case PropertyId::TabAllowSwitchTabsInEmptySpaces: setAllowSwitchTabsInEmptySpaces( attribute.asBool() ); + case PropertyId::DroppableHoveringColor: + setDroppableHoveringColor( attribute.asColor() ); default: return UIWidget::applyProperty( attribute ); } @@ -729,6 +733,19 @@ void UITabWidget::setAllowSwitchTabsInEmptySpaces( bool allowSwitchTabsInEmptySp mAllowSwitchTabsInEmptySpaces = allowSwitchTabsInEmptySpaces; } +bool UITabWidget::acceptsDropOfWidget( const UIWidget* widget ) { + return mAllowDragAndDropTabs && widget && UI_TYPE_TAB == widget->getType() && + !isParentOf( widget ) && widget->asConstType()->getTabWidget() != this; +} + +const Color& UITabWidget::getDroppableHoveringColor() const { + return mDroppableHoveringColor; +} + +void UITabWidget::setDroppableHoveringColor( const Color& droppableHoveringColor ) { + mDroppableHoveringColor = droppableHoveringColor; +} + void UITabWidget::refreshOwnedWidget( UITab* tab ) { if ( NULL != tab && NULL != tab->getOwnedWidget() ) { tab->getOwnedWidget()->setParent( mNodeContainer ); @@ -849,7 +866,8 @@ Uint32 UITabWidget::onMessage( const NodeMessage* msg ) { return 1; } } - } else if ( msg->getMsg() == NodeMessage::MouseUp && mAllowSwitchTabsInEmptySpaces ) { + } else if ( msg->getMsg() == NodeMessage::MouseUp && mAllowSwitchTabsInEmptySpaces && + msg->getSender() == mTabBar ) { Uint32 flags = msg->getFlags(); if ( flags & EE_BUTTONS_WUWD ) { if ( flags & EE_BUTTON_WUMASK ) { diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 21efe92bf..13cf99790 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -43,7 +43,7 @@ UIWidget::UIWidget( const std::string& tag ) : mLayoutPositionPolicyWidget( NULL ), mAttributesTransactionCount( 0 ) { mNodeFlags |= NODE_FLAG_WIDGET; - mFlags |= UI_TAB_FOCUSABLE; + mFlags |= UI_TAB_FOCUSABLE | UI_TOOLTIP_ENABLED; createStyle(); @@ -310,7 +310,7 @@ Uint32 UIWidget::onMouseOver( const Vector2i& position, const Uint32& flags ) { updateDebugData(); } - if ( mVisible && NULL != mTooltip && !mTooltip->getText().empty() ) { + if ( mVisible && NULL != mTooltip && isTooltipEnabled() && !mTooltip->getText().empty() ) { UIThemeManager* themeManager = getUISceneNode()->getUIThemeManager(); if ( NULL == themeManager ) @@ -323,7 +323,8 @@ Uint32 UIWidget::onMouseOver( const Vector2i& position, const Uint32& flags ) { } else { runAction( Actions::Runnable::New( [&] { - if ( getEventDispatcher()->getMouseOverNode() == this ) { + if ( isTooltipEnabled() && + getEventDispatcher()->getMouseOverNode() == this ) { mTooltip->setPixelsPosition( getTooltipPosition() ); mTooltip->show(); } @@ -516,6 +517,26 @@ const Sizef& UIWidget::getSize() const { return UINode::getSize(); } +bool UIWidget::acceptsDropOfWidget( const UIWidget* ) { + return false; +} + +UIWidget* UIWidget::acceptsDropOfWidgetInTree( const UIWidget* widget ) { + if ( acceptsDropOfWidget( widget ) ) { + return this; + } else { + Node* parent = getParent(); + while ( parent ) { + if ( parent->isType( UI_TYPE_WIDGET ) && + parent->asType()->acceptsDropOfWidget( widget ) ) { + return parent->asType(); + } + parent = parent->getParent(); + } + } + return nullptr; +} + UITooltip* UIWidget::getTooltip() { return mTooltip; } @@ -939,6 +960,16 @@ bool UIWidget::hasPseudoClass( const std::string& pseudoCls ) const { mPseudoClasses.end(); } +bool UIWidget::isTooltipEnabled() const { + return ( mFlags & UI_TOOLTIP_ENABLED ) != 0; +} + +void UIWidget::setTooltipEnabled( bool enabled ) { + writeFlag( UI_TOOLTIP_ENABLED, enabled ? 1 : 0 ); + if ( mTooltip && mTooltip->isVisible() ) + mTooltip->setVisible( false ); +} + void UIWidget::setElementTag( const std::string& tag ) { if ( mTag != tag ) { mTag = tag;