ecode: Added range formatting support. Improved behavior when closing tabs with mouse.

This commit is contained in:
Martín Lucas Golini
2023-07-02 18:57:23 -03:00
parent b68161b64e
commit 1f1f2b5c17
11 changed files with 140 additions and 42 deletions

View File

@@ -51,9 +51,9 @@ class EE_API UICodeEditorSplitter {
virtual ~UICodeEditorSplitter();
virtual bool tryTabClose( UIWidget* widget );
virtual bool tryTabClose( UIWidget* widget, UITabWidget::FocusTabBehavior focusTabBehavior );
void closeTab( UIWidget* widget );
void closeTab( UIWidget* widget, UITabWidget::FocusTabBehavior focusTabBehavior );
bool curEditorExistsAndFocused() const;
@@ -218,7 +218,9 @@ class EE_API UICodeEditorSplitter {
template <typename T> void registerSplitterCommands( T& t ) {
t.setCommand( "switch-to-previous-split", [this] { switchPreviousSplit( mCurWidget ); } );
t.setCommand( "switch-to-next-split", [this] { switchNextSplit( mCurWidget ); } );
t.setCommand( "close-tab", [this] { tryTabClose( mCurWidget ); } );
t.setCommand( "close-tab", [this] {
tryTabClose( mCurWidget, UITabWidget::FocusTabBehavior::Default );
} );
t.setCommand( "create-new", [this] {
auto d = createCodeEditorInTabWidget( tabWidgetFromWidget( mCurWidget ) );
if ( d.first != nullptr && d.second != nullptr ) {

View File

@@ -26,7 +26,7 @@ class EE_API TabEvent : public Event {
class EE_API UITabWidget : public UIWidget {
public:
enum class FocusTabBehavior { Closest, FocusOrder };
enum class FocusTabBehavior { Closest, FocusOrder, Default };
class StyleConfig {
public:
@@ -41,7 +41,7 @@ class EE_API UITabWidget : public UIWidget {
//! border tab ) are different from the central tabs.
};
typedef std::function<bool( UITab* )> TabTryCloseCallback;
typedef std::function<bool( UITab*, FocusTabBehavior )> TabTryCloseCallback;
static UITabWidget* New();
@@ -67,10 +67,11 @@ class EE_API UITabWidget : public UIWidget {
Uint32 getTabCount() const;
void removeTab( const Uint32& index, bool destroyOwnedNode = true,
bool immediateClose = false );
void removeTab( const Uint32& index, bool destroyOwnedNode = true, bool immediateClose = false,
FocusTabBehavior focusTabBehavior = FocusTabBehavior::Default );
void removeTab( UITab* tab, bool destroyOwnedNode = true, bool immediateClose = false );
void removeTab( UITab* tab, bool destroyOwnedNode = true, bool immediateClose = false,
FocusTabBehavior focusTabBehavior = FocusTabBehavior::Default );
void removeAllTabs( bool destroyOwnedNode = true, bool immediateClose = false );
@@ -170,6 +171,7 @@ class EE_API UITabWidget : public UIWidget {
void setDroppableHoveringColor( const Color& droppableHoveringColor );
FocusTabBehavior getFocusTabBehavior() const;
void setFocusTabBehavior( FocusTabBehavior focusTabBehavior );
protected:
@@ -198,9 +200,11 @@ class EE_API UITabWidget : public UIWidget {
UITab* createTab( const String& text, UINode* nodeOwned, Drawable* icon );
void removeTab( const Uint32& index, bool destroyOwnedNode, bool destroyTab,
bool immediateClose );
bool immediateClose,
FocusTabBehavior focusTabBehavior = FocusTabBehavior::Default );
void removeTab( UITab* tab, bool destroyOwnedNode, bool destroyTab, bool immediateClose );
void removeTab( UITab* tab, bool destroyOwnedNode, bool destroyTab, bool immediateClose,
FocusTabBehavior focusTabBehavior = FocusTabBehavior::Default );
virtual void onSizeChange();
@@ -224,7 +228,7 @@ class EE_API UITabWidget : public UIWidget {
void refreshOwnedWidget( UITab* tab );
void tryCloseTab( UITab* tab );
void tryCloseTab( UITab* tab, FocusTabBehavior focustTabBehavior = FocusTabBehavior::Default );
void swapTabs( UITab* left, UITab* right );