Hide tab widget scroll when mouse is not over.

Add context menu for splitter tabs.
Git status count lines of added files and other fixes.
Other code clean up regarding Variant class.
This commit is contained in:
Martín Lucas Golini
2024-01-07 15:18:07 -03:00
parent eec3397592
commit 74e3dee369
24 changed files with 301 additions and 121 deletions

View File

@@ -72,6 +72,9 @@ class EE_API Variant {
UIIcon* asIcon() const { return mValue.asIcon; }
void* asDataPtr() const { return mValue.asDataPtr; }
bool is( const Type& type ) const { return type == mType; }
bool isString() const {
return mType == Type::StdString || mType == Type::cstr || mType == Type::String;
}
void reset() {
switch ( mType ) {
case Type::StdString:
@@ -212,6 +215,42 @@ class EE_API Variant {
return false;
}
size_t size() const {
switch ( mType ) {
case Type::Bool:
return 1;
case Type::Int:
return sizeof( int );
case Type::Uint:
return sizeof( unsigned int );
case Type::Int64:
return sizeof( Int64 );
case Type::Uint64:
return sizeof( Uint64 );
case Type::Float:
return sizeof( Float );
case Type::StdString:
return asStdString().size();
case Type::String:
return asString().size();
case Type::Drawable:
return sizeof( mValue.asDrawable );
case Type::Icon:
return asIcon()->getName().size();
case Type::DataPtr:
return sizeof( mValue.asDataPtr );
case Type::Vector2f:
return sizeof( mValue.asVector2f );
case Type::Rectf:
return sizeof( mValue.asRectf );
case Type::cstr:
return strlen( asCStr() );
case Type::Invalid:
break;
}
return 0;
}
private:
union {
void* asDataPtr;

View File

@@ -23,6 +23,8 @@ class EE_API UICodeEditorSplitter {
public:
virtual ~Client(){};
virtual void onTabCreated( UITab* tab, UIWidget* widget ) = 0;
virtual void onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) = 0;
virtual void onCodeEditorFocusChange( UICodeEditor* editor ) = 0;

View File

@@ -64,6 +64,8 @@ class EE_API UITab : public UISelectButton {
Uint32 onDragStop( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags );
virtual Uint32 onMessage( const NodeMessage* message );
virtual void onStateChange();
@@ -74,6 +76,8 @@ class EE_API UITab : public UISelectButton {
virtual void onSizeChange();
virtual bool onCreateContextMenu( const Vector2i& position, const Uint32& flags );
void setOwnedNode();
void updateTab();

View File

@@ -7,6 +7,7 @@
namespace EE { namespace UI {
class UIPopUpMenu;
class UIScrollBar;
class EE_API TabEvent : public Event {
@@ -111,7 +112,7 @@ class EE_API UITabWidget : public UIWidget {
bool getTabCloseButtonVisible() const;
void setTabCloseButtonVisible( bool visible);
void setTabCloseButtonVisible( bool visible );
bool getSpecialBorderTabs() const;
@@ -178,6 +179,10 @@ class EE_API UITabWidget : public UIWidget {
void setFocusTabBehavior( FocusTabBehavior focusTabBehavior );
bool getEnabledCreateContextMenu() const;
void setEnabledCreateContextMenu( bool enabledCreateContextMenu );
protected:
friend class UITab;
@@ -194,10 +199,12 @@ class EE_API UITabWidget : public UIWidget {
bool mAllowDragAndDropTabs{ false };
bool mAllowSwitchTabsInEmptySpaces{ false };
bool mDroppableHoveringColorWasSet{ false };
bool mEnabledCreateContextMenu{ false };
Float mTabVerticalDragResistance;
Color mDroppableHoveringColor{ Color::Transparent };
FocusTabBehavior mFocusTabBehavior{ FocusTabBehavior::Closest };
std::deque<UITab*> mFocusHistory;
UIPopUpMenu* mCurrentMenu{ nullptr };
void onThemeLoaded();