diff --git a/bin/assets/plugins/aiassistant.json b/bin/assets/plugins/aiassistant.json index 104e8ae7d..4fa1e8652 100644 --- a/bin/assets/plugins/aiassistant.json +++ b/bin/assets/plugins/aiassistant.json @@ -412,8 +412,22 @@ { "name": "openai/gpt-5.2-pro", "display_name": "OpenAI: GPT-5 Pro" + }, + { + "name": "moonshotai/kimi-k2.5", + "display_name": "kimi-k2.5" + } + ] + }, + "moonshot": { + "api_url": "https://api.moonshot.ai/v1/chat/completions", + "display_name": "Moonshot", + "models": [ + { + "name": "kimi-k2.5" } ] } + } } diff --git a/include/eepp/graphics/statelistdrawable.hpp b/include/eepp/graphics/statelistdrawable.hpp index 6d3faf587..9b2c50371 100644 --- a/include/eepp/graphics/statelistdrawable.hpp +++ b/include/eepp/graphics/statelistdrawable.hpp @@ -10,8 +10,6 @@ class EE_API StateListDrawable : public StatefulDrawable { public: static StateListDrawable* New( const std::string& name = "" ); - explicit StateListDrawable( const std::string& name = "" ); - virtual ~StateListDrawable(); virtual Sizef getSize(); @@ -62,6 +60,8 @@ class EE_API StateListDrawable : public StatefulDrawable { std::map mDrawablesOwnership; std::map mDrawableColors; + explicit StateListDrawable( const std::string& name = "" ); + StateListDrawable( Type type, const std::string& name = "" ); virtual void onColorFilterChange(); diff --git a/include/eepp/graphics/text.hpp b/include/eepp/graphics/text.hpp index f4dc4d2aa..dcbf8883e 100644 --- a/include/eepp/graphics/text.hpp +++ b/include/eepp/graphics/text.hpp @@ -25,6 +25,11 @@ struct WhitespaceDisplayConfig { std::optional tabOffset; }; +struct TextSelectionRange { + Int64 start{ 0 }; + Int64 end{ 0 }; +}; + class EE_API Text { public: static bool TextShaperEnabled; @@ -371,7 +376,7 @@ class EE_API Text { /** @return A list of rectangles that cover the selection of the string, each rectangle * has the line spacing height and covers the width of the selection. */ - std::vector getSelectionRects( size_t selectionStartIndex, size_t selectionEndIndex ); + std::vector getSelectionRects( TextSelectionRange range ); protected: struct VertexCoords { @@ -397,8 +402,9 @@ class EE_API Text { Uint32 mTabWidth{ 4 }; Uint32 mInvalidationId{ 0 }; Uint32 mTextHints{ 0 }; - LineWrapMode mLineWrapMode{ LineWrapMode::NoWrap }; Float mMaxWrapWidth{ 0 }; + LineWrapMode mLineWrapMode{ LineWrapMode::NoWrap }; + TextDirection mDirection{ TextDirection::Unspecified }; mutable std::vector mVisualLines; mutable std::vector mLinesWidth; @@ -407,7 +413,6 @@ class EE_API Text { std::vector mColors; std::vector mOutlineVertices; std::vector mOutlineColors; - TextDirection mDirection{ TextDirection::Unspecified }; void ensureGeometryUpdate(); diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index 38cec5032..77c5ddf0e 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -73,8 +73,6 @@ class EE_API Node : public Transformable { typedef std::function EventCallback; - Node(); - virtual ~Node(); virtual void worldToNodeTranslation( Vector2f& position ) const; @@ -512,6 +510,8 @@ class EE_API Node : public Transformable { OriginPoint mRotationOriginPoint; OriginPoint mScaleOriginPoint; + Node(); + virtual Uint32 onMessage( const NodeMessage* msg ); virtual Uint32 onTextInput( const TextInputEvent& event ); diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index 3701a0f91..daf496c65 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -194,9 +194,6 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { static const MouseBindings::ShortcutMap getDefaultMousebindings(); - UICodeEditor( const bool& autoRegisterBaseCommands = true, - const bool& autoRegisterBaseKeybindings = true ); - virtual ~UICodeEditor(); virtual Uint32 getType() const; @@ -964,6 +961,9 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { std::vector mTokens; TextDirection mTextDirection{ TextDirection::LeftToRight }; + UICodeEditor( const bool& autoRegisterBaseCommands = true, + const bool& autoRegisterBaseKeybindings = true ); + UICodeEditor( const std::string& elementTag, const bool& autoRegisterBaseCommands = true, const bool& autoRegisterBaseKeybindings = true ); diff --git a/include/eepp/ui/uicombobox.hpp b/include/eepp/ui/uicombobox.hpp index 9ab2ca481..75bb53778 100644 --- a/include/eepp/ui/uicombobox.hpp +++ b/include/eepp/ui/uicombobox.hpp @@ -9,8 +9,6 @@ class EE_API UIComboBox : public UIWidget { public: static UIComboBox* New(); - UIComboBox(); - virtual ~UIComboBox(); virtual Uint32 getType() const; @@ -42,6 +40,8 @@ class EE_API UIComboBox : public UIWidget { UIDropDownList* mDropDownList; UINode* mButton; + UIComboBox(); + Uint32 onMessage( const NodeMessage* Msg ); void updateWidgets(); diff --git a/include/eepp/ui/uidropdownlist.hpp b/include/eepp/ui/uidropdownlist.hpp index d8ada4edd..3f769e6c1 100644 --- a/include/eepp/ui/uidropdownlist.hpp +++ b/include/eepp/ui/uidropdownlist.hpp @@ -31,8 +31,6 @@ class EE_API UIDropDownList : public UITextInput { static UIDropDownList* New(); - UIDropDownList( const std::string& tag = "dropdownlist" ); - virtual ~UIDropDownList(); virtual Uint32 getType() const; @@ -78,6 +76,8 @@ class EE_API UIDropDownList : public UITextInput { UINode* mFriendNode; Uint32 mListBoxCloseCb{ 0 }; + UIDropDownList( const std::string& tag = "dropdownlist" ); + void onListBoxFocusLoss( const Event* Event ); virtual void onItemSelected( const Event* Event ); diff --git a/include/eepp/ui/uigridlayout.hpp b/include/eepp/ui/uigridlayout.hpp index cef8b5f8b..0a58c432a 100644 --- a/include/eepp/ui/uigridlayout.hpp +++ b/include/eepp/ui/uigridlayout.hpp @@ -11,8 +11,6 @@ class EE_API UIGridLayout : public UILayout { static UIGridLayout* New(); - UIGridLayout(); - virtual Uint32 getType() const; virtual bool isType( const Uint32& type ) const; @@ -63,6 +61,8 @@ class EE_API UIGridLayout : public UILayout { Float mRowWeight; int mRowHeight; + UIGridLayout(); + virtual Uint32 onMessage( const NodeMessage* Msg ); virtual void onParentSizeChange( const Vector2f& size ); diff --git a/include/eepp/ui/uiimage.hpp b/include/eepp/ui/uiimage.hpp index d7954b6d1..b7dd8fec2 100644 --- a/include/eepp/ui/uiimage.hpp +++ b/include/eepp/ui/uiimage.hpp @@ -11,10 +11,6 @@ class EE_API UIImage : public UIWidget { static UIImage* NewWithTag( const std::string& tag ); - UIImage(); - - explicit UIImage( const std::string& tag ); - virtual ~UIImage(); virtual Uint32 getType() const; @@ -57,6 +53,10 @@ class EE_API UIImage : public UIWidget { Uint32 mResourceChangeCb; bool mDrawableOwner; + UIImage(); + + explicit UIImage( const std::string& tag ); + virtual void onSizeChange(); virtual void onAlignChange(); diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index b6903ce0c..ec3f22d6c 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -13,8 +13,6 @@ class EE_API UIListBox : public UITouchDraggableWidget { public: static UIListBox* New(); - UIListBox(); - static UIListBox* NewWithTag( const std::string& tag ); explicit UIListBox( const std::string& tag ); @@ -144,6 +142,8 @@ class EE_API UIListBox : public UITouchDraggableWidget { std::vector mItems; std::vector mTexts; + UIListBox(); + void updateScroll( bool fromScrollChange = false ); void updateScrollBarState(); diff --git a/include/eepp/ui/uilistboxitem.hpp b/include/eepp/ui/uilistboxitem.hpp index 5e8bbd4c4..de70889e4 100644 --- a/include/eepp/ui/uilistboxitem.hpp +++ b/include/eepp/ui/uilistboxitem.hpp @@ -14,10 +14,6 @@ class EE_API UIListBoxItem : public UITextView { static UIListBoxItem* NewWithTag( const std::string& tag ); - UIListBoxItem(); - - UIListBoxItem( const std::string& tag ); - virtual ~UIListBoxItem(); virtual Uint32 getType() const; @@ -35,6 +31,10 @@ class EE_API UIListBoxItem : public UITextView { protected: friend class UIItemContainer; + UIListBoxItem(); + + UIListBoxItem( const std::string& tag ); + virtual void onStateChange(); virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags ); diff --git a/include/eepp/ui/uiloader.hpp b/include/eepp/ui/uiloader.hpp index 10f21047d..bb17efacc 100644 --- a/include/eepp/ui/uiloader.hpp +++ b/include/eepp/ui/uiloader.hpp @@ -11,9 +11,7 @@ class EE_API UILoader : public UIWidget { public: static UILoader* New(); - UILoader(); - - ~UILoader(); + virtual ~UILoader(); virtual Uint32 getType() const; @@ -76,6 +74,8 @@ class EE_API UILoader : public UIWidget { IntPtr mOp; bool mIndeterminate; + UILoader(); + virtual void onAutoSize(); virtual void onSizeChange(); diff --git a/include/eepp/ui/uimenu.hpp b/include/eepp/ui/uimenu.hpp index bc889b523..c6b04ee45 100644 --- a/include/eepp/ui/uimenu.hpp +++ b/include/eepp/ui/uimenu.hpp @@ -18,8 +18,6 @@ class EE_API UIMenu : public UIWidget { static void findBestMenuPos( Vector2f& position, UIWidget* menu, UIMenu* parent = NULL, UIMenuSubMenu* subMenu = NULL, Node* trigger = NULL ); - UIMenu(); - virtual ~UIMenu(); virtual Uint32 getType() const; @@ -95,6 +93,8 @@ class EE_API UIMenu : public UIWidget { friend class UIMenuRadioButton; friend class UIMenuSubMenu; + UIMenu(); + std::deque mItems; Uint32 mMaxWidth; Uint32 mNextPosY; diff --git a/include/eepp/ui/uimenucheckbox.hpp b/include/eepp/ui/uimenucheckbox.hpp index 9a17d0813..4edf3de94 100644 --- a/include/eepp/ui/uimenucheckbox.hpp +++ b/include/eepp/ui/uimenucheckbox.hpp @@ -9,8 +9,6 @@ class EE_API UIMenuCheckBox : public UIMenuItem { public: static UIMenuCheckBox* New(); - UIMenuCheckBox(); - virtual ~UIMenuCheckBox(); virtual Uint32 getType() const; @@ -37,6 +35,8 @@ class EE_API UIMenuCheckBox : public UIMenuItem { UISkin* mSkinActive; UISkin* mSkinInactive; + UIMenuCheckBox(); + Uint32 onMessage( const NodeMessage* msg ); virtual void onStateChange(); diff --git a/include/eepp/ui/uimenuitem.hpp b/include/eepp/ui/uimenuitem.hpp index fc7c8ae11..f2766b36d 100644 --- a/include/eepp/ui/uimenuitem.hpp +++ b/include/eepp/ui/uimenuitem.hpp @@ -11,8 +11,6 @@ class EE_API UIMenuItem : public UIPushButton { static UIMenuItem* New(); - UIMenuItem(); - virtual ~UIMenuItem(); virtual Uint32 getType() const; @@ -35,6 +33,8 @@ class EE_API UIMenuItem : public UIPushButton { UITextView* mShortcutView; OnShouldCloseCb mOnShouldCloseCb; + UIMenuItem(); + explicit UIMenuItem( const std::string& tag ); virtual void onSizeChange(); diff --git a/include/eepp/ui/uimenuradiobutton.hpp b/include/eepp/ui/uimenuradiobutton.hpp index bc5f9ea1d..a5f07055b 100644 --- a/include/eepp/ui/uimenuradiobutton.hpp +++ b/include/eepp/ui/uimenuradiobutton.hpp @@ -9,8 +9,6 @@ class EE_API UIMenuRadioButton : public UIMenuItem { public: static UIMenuRadioButton* New(); - UIMenuRadioButton(); - virtual ~UIMenuRadioButton(); virtual Uint32 getType() const; @@ -37,6 +35,8 @@ class EE_API UIMenuRadioButton : public UIMenuItem { UISkin* mSkinActive; UISkin* mSkinInactive; + UIMenuRadioButton(); + virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags ); virtual void onStateChange(); diff --git a/include/eepp/ui/uimenuseparator.hpp b/include/eepp/ui/uimenuseparator.hpp index d60a21a1c..6aa7aa5bb 100644 --- a/include/eepp/ui/uimenuseparator.hpp +++ b/include/eepp/ui/uimenuseparator.hpp @@ -9,8 +9,6 @@ class EE_API UIMenuSeparator : public UIWidget { public: static UIMenuSeparator* New(); - UIMenuSeparator(); - virtual ~UIMenuSeparator(); virtual Uint32 getType() const; @@ -20,6 +18,8 @@ class EE_API UIMenuSeparator : public UIWidget { virtual void setTheme( UITheme* Theme ); protected: + UIMenuSeparator(); + }; }} // namespace EE::UI diff --git a/include/eepp/ui/uimenusubmenu.hpp b/include/eepp/ui/uimenusubmenu.hpp index 0f2102e26..87251f4ca 100644 --- a/include/eepp/ui/uimenusubmenu.hpp +++ b/include/eepp/ui/uimenusubmenu.hpp @@ -11,8 +11,6 @@ class EE_API UIMenuSubMenu : public UIMenuItem { public: static UIMenuSubMenu* New(); - UIMenuSubMenu(); - virtual ~UIMenuSubMenu(); virtual Uint32 getType() const; @@ -41,6 +39,8 @@ class EE_API UIMenuSubMenu : public UIMenuItem { Time mMaxTime; Action* mCurWait; + UIMenuSubMenu(); + virtual Uint32 onMouseOver( const Vector2i& pos, const Uint32& flags ); virtual Uint32 onMouseLeave( const Vector2i& pos, const Uint32& flags ); diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index 061ebfa51..dfab3d9e1 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -35,8 +35,6 @@ class EE_API UINode : public Node { typedef std::function EventCallback; - UINode(); - virtual ~UINode(); void worldToNodeTranslation( Vector2f& position ) const; @@ -346,6 +344,8 @@ class EE_API UINode : public Node { std::string mMaxWidthEq; std::string mMaxHeightEq; + UINode(); + virtual Uint32 onMouseDown( const Vector2i& position, const Uint32& flags ); virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags ); diff --git a/include/eepp/ui/uipopupmenu.hpp b/include/eepp/ui/uipopupmenu.hpp index ae35d550d..1aa8447c2 100644 --- a/include/eepp/ui/uipopupmenu.hpp +++ b/include/eepp/ui/uipopupmenu.hpp @@ -9,8 +9,6 @@ class EE_API UIPopUpMenu : public UIMenu { public: static UIPopUpMenu* New(); - UIPopUpMenu(); - virtual ~UIPopUpMenu(); virtual Uint32 getType() const; @@ -43,6 +41,8 @@ class EE_API UIPopUpMenu : public UIMenu { Action* mHidingAction{ nullptr }; bool mCloseOnHide{ false }; bool mCloseSubMenusOnClose{ false }; + + UIPopUpMenu(); }; class EE_API ContextMenuEvent : public MouseEvent { diff --git a/include/eepp/ui/uiprogressbar.hpp b/include/eepp/ui/uiprogressbar.hpp index d6a026df4..635fdebf2 100644 --- a/include/eepp/ui/uiprogressbar.hpp +++ b/include/eepp/ui/uiprogressbar.hpp @@ -13,12 +13,13 @@ class EE_API UIProgressBarFiller : public UIWidget { public: static UIProgressBarFiller* New( UIProgressBar* parent ); - UIProgressBarFiller( UIProgressBar* parent ); - void draw() override; UIProgressBar* mProgressBar; UISkin* mFillerSkin; + + protected: + UIProgressBarFiller( UIProgressBar* parent ); }; class EE_API UIProgressBar : public UIWidget { @@ -32,8 +33,6 @@ class EE_API UIProgressBar : public UIWidget { static UIProgressBar* New(); - UIProgressBar(); - virtual ~UIProgressBar(); virtual Uint32 getType() const; @@ -86,6 +85,8 @@ class EE_API UIProgressBar : public UIWidget { Vector2f mOffset; UIProgressBarFiller* mFiller; + UIProgressBar(); + virtual Uint32 onValueChange(); virtual void onSizeChange(); diff --git a/include/eepp/ui/uiradiobutton.hpp b/include/eepp/ui/uiradiobutton.hpp index 48da8185a..46199eb4d 100644 --- a/include/eepp/ui/uiradiobutton.hpp +++ b/include/eepp/ui/uiradiobutton.hpp @@ -10,8 +10,6 @@ class EE_API UIRadioButton : public UITextView { public: static UIRadioButton* New(); - UIRadioButton(); - virtual ~UIRadioButton(); virtual Uint32 getType() const; @@ -46,6 +44,8 @@ class EE_API UIRadioButton : public UITextView { Uint32 mLastTick; Int32 mTextSeparation; + UIRadioButton(); + virtual void onSizeChange(); void switchState(); diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 03c48fac1..9df46d619 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -28,8 +28,6 @@ class EE_API UISceneNode : public SceneNode { public: static UISceneNode* New( EE::Window::Window* window = NULL ); - explicit UISceneNode( EE::Window::Window* window = NULL ); - virtual ~UISceneNode(); virtual Node* setSize( const Sizef& size ); @@ -198,6 +196,8 @@ class EE_API UISceneNode : public SceneNode { Uint32 mCurOnSizeChangeListener{ 0 }; std::shared_ptr mThreadPool; + explicit UISceneNode( EE::Window::Window* window = NULL ); + virtual void resizeNode( EE::Window::Window* win ); virtual void onDrawDebugDataChange(); diff --git a/include/eepp/ui/uiscrollview.hpp b/include/eepp/ui/uiscrollview.hpp index 75575b2ac..d004ede60 100644 --- a/include/eepp/ui/uiscrollview.hpp +++ b/include/eepp/ui/uiscrollview.hpp @@ -11,8 +11,6 @@ class EE_API UIScrollView : public UITouchDraggableWidget { public: static UIScrollView* New(); - UIScrollView(); - virtual Uint32 getType() const; virtual bool isType( const Uint32& type ) const; @@ -66,6 +64,8 @@ class EE_API UIScrollView : public UITouchDraggableWidget { bool mAnchorScroll{ false }; Sizef mLastScrollViewSize; + UIScrollView(); + virtual Uint32 onMessage( const NodeMessage* Msg ); virtual void onSizeChange(); diff --git a/include/eepp/ui/uiselectbutton.hpp b/include/eepp/ui/uiselectbutton.hpp index bc9f0f73b..8ea01b2b2 100644 --- a/include/eepp/ui/uiselectbutton.hpp +++ b/include/eepp/ui/uiselectbutton.hpp @@ -11,10 +11,6 @@ class EE_API UISelectButton : public UIPushButton { static UISelectButton* NewWithTag( const std::string& tag ); - UISelectButton(); - - explicit UISelectButton( const std::string& tag ); - virtual ~UISelectButton(); virtual Uint32 getType() const; @@ -44,6 +40,10 @@ class EE_API UISelectButton : public UIPushButton { protected: Uint32 mSelectOnClickCbId{ 0 }; + UISelectButton(); + + explicit UISelectButton( const std::string& tag ); + virtual void onStateChange(); }; diff --git a/include/eepp/ui/uiskin.hpp b/include/eepp/ui/uiskin.hpp index 0873cf562..79846d2e9 100644 --- a/include/eepp/ui/uiskin.hpp +++ b/include/eepp/ui/uiskin.hpp @@ -10,8 +10,6 @@ class EE_API UISkin : public StateListDrawable { public: static UISkin* New( const std::string& name = "" ); - explicit UISkin( const std::string& name = "" ); - virtual ~UISkin(); virtual Sizef getSize( const Uint32& state ); @@ -29,6 +27,9 @@ class EE_API UISkin : public StateListDrawable { virtual Rectf getBorderSize( const Uint32& state ); virtual Rectf getBorderSize(); + + protected: + explicit UISkin( const std::string& name = "" ); }; }} // namespace EE::UI diff --git a/include/eepp/ui/uiskinstate.hpp b/include/eepp/ui/uiskinstate.hpp index d74c8bf1a..057dc1114 100644 --- a/include/eepp/ui/uiskinstate.hpp +++ b/include/eepp/ui/uiskinstate.hpp @@ -2,6 +2,7 @@ #define EE_UI_UISKINSTATE_HPP #include +#include namespace EE { namespace UI { @@ -11,8 +12,6 @@ class EE_API UISkinState : public UIState { public: static UISkinState* New( UISkin* skin ); - explicit UISkinState( UISkin* Skin ); - virtual ~UISkinState(); UISkin* getSkin() const; @@ -33,6 +32,8 @@ class EE_API UISkinState : public UIState { std::map mColors; Color mCurrentColor; + explicit UISkinState( UISkin* Skin ); + void updateState(); void onStateChange(); diff --git a/include/eepp/ui/uislider.hpp b/include/eepp/ui/uislider.hpp index cb67f4745..5000b7886 100644 --- a/include/eepp/ui/uislider.hpp +++ b/include/eepp/ui/uislider.hpp @@ -19,9 +19,6 @@ class EE_API UISlider : public UIWidget { static UISlider* NewHorizontalWithTag( const std::string& tag ); - UISlider( const std::string& tag, - const UIOrientation& orientation = UIOrientation::Horizontal ); - virtual ~UISlider(); virtual Uint32 getType() const; @@ -100,6 +97,9 @@ class EE_API UISlider : public UIWidget { Uint32 mLastTickMove; + UISlider( const std::string& tag, + const UIOrientation& orientation = UIOrientation::Horizontal ); + virtual void onAutoSize(); virtual void onSizeChange(); diff --git a/include/eepp/ui/uispinbox.hpp b/include/eepp/ui/uispinbox.hpp index 82b64586c..1aa8ed959 100644 --- a/include/eepp/ui/uispinbox.hpp +++ b/include/eepp/ui/uispinbox.hpp @@ -10,8 +10,6 @@ class EE_API UISpinBox : public UIWidget { public: static UISpinBox* New(); - UISpinBox(); - virtual ~UISpinBox(); virtual Uint32 getType() const; @@ -71,6 +69,8 @@ class EE_API UISpinBox : public UIWidget { double mClickStep; bool mModifyingVal; + UISpinBox(); + void adjustChildren(); virtual void onSizeChange(); diff --git a/include/eepp/ui/uisprite.hpp b/include/eepp/ui/uisprite.hpp index 5b7213723..f76da0520 100644 --- a/include/eepp/ui/uisprite.hpp +++ b/include/eepp/ui/uisprite.hpp @@ -14,8 +14,6 @@ class EE_API UISprite : public UIWidget { public: static UISprite* New(); - UISprite(); - virtual ~UISprite(); virtual Uint32 getType() const; @@ -62,6 +60,8 @@ class EE_API UISprite : public UIWidget { TextureRegion* mTextureRegionLast; bool mDealloc; + UISprite(); + void updateSize(); void autoAlign(); diff --git a/include/eepp/ui/uistacklayout.hpp b/include/eepp/ui/uistacklayout.hpp index 07e079a21..660ff3d09 100644 --- a/include/eepp/ui/uistacklayout.hpp +++ b/include/eepp/ui/uistacklayout.hpp @@ -40,7 +40,6 @@ class EE_API UIStackLayout : public UILayout { UIStackLayout(); - explicit UIStackLayout( const std::string& tag ); virtual Uint32 onMessage( const NodeMessage* Msg ); diff --git a/include/eepp/ui/uistyle.hpp b/include/eepp/ui/uistyle.hpp index 5d42244f2..69892371b 100644 --- a/include/eepp/ui/uistyle.hpp +++ b/include/eepp/ui/uistyle.hpp @@ -27,8 +27,6 @@ class EE_API UIStyle : public UIState { public: static UIStyle* New( UIWidget* widget ); - explicit UIStyle( UIWidget* widget ); - virtual ~UIStyle(); bool stateExists( const Uint32& state ) const; @@ -97,6 +95,8 @@ class EE_API UIStyle : public UIState { bool mDisableAnimations; bool mFirstState; + explicit UIStyle( UIWidget* widget ); + void applyVarValues( CSS::StyleSheetProperty* style ); void applyLightDarkValues( CSS::StyleSheetProperty* style ); diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index d2170ea1d..aca9833f2 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -11,8 +11,6 @@ class EE_API UITab : public UISelectButton { public: static UITab* New(); - UITab(); - Node* getOwnedWidget() const; void setOwnedWidget( Node* ownedWidget ); @@ -58,6 +56,8 @@ class EE_API UITab : public UISelectButton { UIWidget* mCurDropWidget{ nullptr }; bool mWasToolipEnabled{ true }; + UITab(); + Uint32 onDrag( const Vector2f& position, const Uint32& flags, const Sizef& dragDiff ); Uint32 onDragStart( const Vector2i& position, const Uint32& flags ); diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index 2c23f3d8a..48ccd3012 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -62,8 +62,6 @@ class EE_API UITabWidget : public UIWidget { static UITabWidget* New(); - UITabWidget(); - virtual ~UITabWidget(); virtual Uint32 getType() const; @@ -263,6 +261,8 @@ class EE_API UITabWidget : public UIWidget { TabJumpMode mTabJumpMode{ TabJumpMode::Linear }; std::function mAcceptsDropOfWidgetFn; + UITabWidget(); + void onThemeLoaded(); UITab* createTab( const String& text, UINode* nodeOwned, Drawable* icon ); diff --git a/include/eepp/ui/uitextedit.hpp b/include/eepp/ui/uitextedit.hpp index b8d261d5e..9c8872203 100644 --- a/include/eepp/ui/uitextedit.hpp +++ b/include/eepp/ui/uitextedit.hpp @@ -10,8 +10,6 @@ class EE_API UITextEdit : public UICodeEditor { public: static UITextEdit* New(); - UITextEdit(); - virtual ~UITextEdit(); virtual Uint32 getType() const; @@ -27,6 +25,8 @@ class EE_API UITextEdit : public UICodeEditor { void setWordWrap( bool enabled ); protected: + UITextEdit(); + virtual bool applyProperty( const StyleSheetProperty& attribute ); virtual void drawCursor( const Vector2f& startScroll, const Float& lineHeight, diff --git a/include/eepp/ui/uitextinput.hpp b/include/eepp/ui/uitextinput.hpp index 7a966ca39..d873824dc 100644 --- a/include/eepp/ui/uitextinput.hpp +++ b/include/eepp/ui/uitextinput.hpp @@ -19,10 +19,6 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client { static UITextInput* NewWithTag( const std::string& tag ); - UITextInput(); - - explicit UITextInput( const std::string& tag ); - virtual ~UITextInput(); virtual Uint32 getType() const; @@ -150,6 +146,10 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client { String::HashType mLastCmdHash{ 0 }; HintDisplay mHintDisplay{ HintDisplay::Always }; + UITextInput(); + + explicit UITextInput( const std::string& tag ); + void resetWaitCursor(); virtual void alignFix(); diff --git a/include/eepp/ui/uitextinputpassword.hpp b/include/eepp/ui/uitextinputpassword.hpp index 694a7ba4f..e4fef8936 100644 --- a/include/eepp/ui/uitextinputpassword.hpp +++ b/include/eepp/ui/uitextinputpassword.hpp @@ -9,9 +9,7 @@ class EE_API UITextInputPassword : public UITextInput { public: static UITextInputPassword* New(); - UITextInputPassword(); - - ~UITextInputPassword(); + virtual ~UITextInputPassword(); virtual void draw(); @@ -19,14 +17,16 @@ class EE_API UITextInputPassword : public UITextInput { virtual UITextView* setText( const String& text ); - Text* getPassCache() const; + const Text& getPassCache() const; const String& getBulletCharacter() const; void setBulletCharacter( const String& bulletCharacter ); protected: - Text* mPassCache; + UITextInputPassword(); + + Text mPassCache; Vector2f mHintAlignOffset; String mBulletCharacter; @@ -42,7 +42,7 @@ class EE_API UITextInputPassword : public UITextInput { virtual void onFontStyleChanged(); - virtual Text* getVisibleTextCache() const; + virtual Text& getVisibleTextCache(); }; }} // namespace EE::UI diff --git a/include/eepp/ui/uitextview.hpp b/include/eepp/ui/uitextview.hpp index 2b424390c..a02f70a60 100644 --- a/include/eepp/ui/uitextview.hpp +++ b/include/eepp/ui/uitextview.hpp @@ -13,8 +13,6 @@ class EE_API UITextView : public UIWidget { static UITextView* NewWithTag( const std::string& tag ); - UITextView(); - explicit UITextView( const std::string& tag ); virtual ~UITextView(); @@ -81,7 +79,7 @@ class EE_API UITextView : public UIWidget { bool isTextSelectionEnabled() const; - void setTextSelection( const bool& active ); + void setTextSelectionEnabled( bool active ); const UIFontStyleConfig& getFontStyleConfig() const; @@ -124,12 +122,12 @@ class EE_API UITextView : public UIWidget { bool isWordWrap() const; - std::pair getSelection() const; + std::pair getTextSelectionRange() const; - void setSelection( std::pair sel ); + void setTextSelectionRange( TextSelectionRange range ); protected: - Text* mTextCache; + Text mTextCache; String mString; UIFontStyleConfig mFontStyleConfig; Vector2f mRealAlignOffset; @@ -145,7 +143,9 @@ class EE_API UITextView : public UIWidget { Float mTextOverflowWidth{ 0 }; TextTransform::Value mTextTransform{ TextTransform::None }; - virtual void drawSelection( Text* textCache ); + UITextView(); + + virtual void drawSelection( Text& textCache ); virtual void onSizeChange(); @@ -185,7 +185,7 @@ class EE_API UITextView : public UIWidget { virtual void onSelectionChange(); - virtual Text* getVisibleTextCache() const; + virtual Text& getVisibleTextCache(); void transformText(); @@ -200,8 +200,6 @@ class EE_API UIAnchor : public UITextView { public: static UIAnchor* New(); - UIAnchor(); - virtual bool applyProperty( const StyleSheetProperty& attribute ); virtual std::string getPropertyString( const PropertyDefinition* propertyDef, @@ -214,6 +212,8 @@ class EE_API UIAnchor : public UITextView { const std::string& getHref() const; protected: + UIAnchor(); + std::string mHref; virtual Uint32 onKeyDown( const KeyEvent& event ); diff --git a/include/eepp/ui/uitooltip.hpp b/include/eepp/ui/uitooltip.hpp index 450520f72..8754b7069 100644 --- a/include/eepp/ui/uitooltip.hpp +++ b/include/eepp/ui/uitooltip.hpp @@ -18,8 +18,6 @@ class EE_API UITooltip : public UIWidget { static Vector2f getTooltipPosition( UIWidget* toolip, const Vector2f& requestedPosition ); - UITooltip(); - virtual ~UITooltip(); virtual Uint32 getType() const; @@ -140,6 +138,8 @@ class EE_API UITooltip : public UIWidget { bool mDontAutoHideOnMouseMove{ false }; bool mUsingCustomStyling{ false }; + UITooltip(); + virtual void onAlignChange(); virtual void onAlphaChange(); diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index 067debaea..d58403273 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -27,8 +27,6 @@ class EE_API UIWidget : public UINode { static UIWidget* NewWithTag( const std::string& tag ); - UIWidget(); - virtual ~UIWidget(); virtual Uint32 getType() const; @@ -313,6 +311,8 @@ class EE_API UIWidget : public UINode { std::vector mClasses; String mTooltipText; + UIWidget(); + explicit UIWidget( const std::string& tag ); void updatePseudoClasses(); diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 2497aa459..4fed3d5ef 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -71,10 +71,6 @@ class EE_API UIWindow : public UIWidget { static UIWindow* NewRelLay(); - explicit UIWindow( WindowBaseContainerType type, const StyleConfig& windowStyleConfig ); - - explicit UIWindow( WindowBaseContainerType type = SIMPLE_LAYOUT ); - virtual ~UIWindow(); virtual Uint32 getType() const; @@ -250,6 +246,10 @@ class EE_API UIWindow : public UIWidget { std::map mKeyBindingCommands; std::function mCheckEphemeralCloseFn; + explicit UIWindow( WindowBaseContainerType type, const StyleConfig& windowStyleConfig ); + + explicit UIWindow( WindowBaseContainerType type = SIMPLE_LAYOUT ); + virtual void onSizeChange(); virtual void onAlphaChange(); diff --git a/src/eepp/graphics/text.cpp b/src/eepp/graphics/text.cpp index cac8d28a0..43e75caff 100644 --- a/src/eepp/graphics/text.cpp +++ b/src/eepp/graphics/text.cpp @@ -2778,20 +2778,20 @@ size_t Text::findVisualLineFromCharIndex( size_t charIndex ) { return 0; } -std::vector Text::getSelectionRects( size_t selectionStartIndex, size_t selectionEndIndex ) { +std::vector Text::getSelectionRects( TextSelectionRange range ) { std::vector rects; - if ( selectionStartIndex == selectionEndIndex || !mFontStyleConfig.Font ) + if ( range.start == range.end || !mFontStyleConfig.Font ) return rects; - if ( selectionStartIndex > selectionEndIndex ) - std::swap( selectionStartIndex, selectionEndIndex ); + if ( range.start > range.end ) + std::swap( range.start, range.end ); ensureVisualLinesUpdate(); cacheWidth(); - size_t startLine = findVisualLineFromCharIndex( selectionStartIndex ); - size_t endLine = findVisualLineFromCharIndex( selectionEndIndex ); + size_t startLine = findVisualLineFromCharIndex( range.start ); + size_t endLine = findVisualLineFromCharIndex( range.end ); Float hspace = mFontStyleConfig.Font ->getGlyph( ' ', mFontStyleConfig.CharacterSize, mFontStyleConfig.Style & Text::Bold, @@ -2820,7 +2820,7 @@ std::vector Text::getSelectionRects( size_t selectionStartIndex, size_t s // Calculate Left if ( i == startLine ) { - left = findCharacterPos( selectionStartIndex ).x; + left = findCharacterPos( range.start ).x; } else { left = centerDiffX; } @@ -2829,10 +2829,10 @@ std::vector Text::getSelectionRects( size_t selectionStartIndex, size_t s if ( i == endLine ) { // If it's a newline character, we select a small chunk to indicate the newline // selection - if ( selectionEndIndex < mString.size() && mString[selectionEndIndex] == '\n' ) { - right = findCharacterPos( selectionEndIndex ).x + hspace; + if ( range.end < (Int64)mString.size() && mString[range.end] == '\n' ) { + right = findCharacterPos( range.end ).x + hspace; } else { - right = findCharacterPos( selectionEndIndex ).x; + right = findCharacterPos( range.end ).x; } } else { right = centerDiffX + ( i < mLinesWidth.size() ? mLinesWidth[i] : 0 ); diff --git a/src/eepp/ui/tools/uitextureviewer.hpp b/src/eepp/ui/tools/uitextureviewer.hpp index fed9e0d48..abffb70d9 100644 --- a/src/eepp/ui/tools/uitextureviewer.hpp +++ b/src/eepp/ui/tools/uitextureviewer.hpp @@ -15,7 +15,7 @@ class EE_API UITextureViewer : public UIRelativeLayout { public: static UITextureViewer* New(); - ~UITextureViewer(); + virtual ~UITextureViewer(); protected: UIGridLayout* mGridLayout{ nullptr }; @@ -33,6 +33,7 @@ class EE_API UITextureViewer : public UIRelativeLayout { }; } // namespace Tools + }} // namespace EE::UI #endif // EE_UITEXTUREVIEWER_HPP diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index a329acac3..ec7f18d65 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -84,7 +84,7 @@ void UICheckBox::onThemeLoaded() { void UICheckBox::onAutoSize() { if ( mFlags & UI_AUTO_SIZE ) { if ( getSize().getWidth() == 0 ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + + setInternalPixelsWidth( (int)mTextCache.getTextWidth() + mActiveButton->getPixelsSize().getWidth() + mTextSeparation + mPaddingPx.Left + mPaddingPx.Right ); } @@ -96,13 +96,13 @@ void UICheckBox::onAutoSize() { } if ( mWidthPolicy == SizePolicy::WrapContent ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mPaddingPx.Left + + setInternalPixelsWidth( (int)mTextCache.getTextWidth() + mPaddingPx.Left + mPaddingPx.Right + mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { - setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mPaddingPx.Top + + setInternalPixelsHeight( (int)mTextCache.getTextHeight() + mPaddingPx.Top + mPaddingPx.Bottom ); } @@ -192,7 +192,7 @@ void UICheckBox::alignFix() { switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = (Float)( (Int32)( ( mSize.x - mPaddingPx.Left - mPaddingPx.Right - - mTextCache->getTextWidth() - + mTextCache.getTextWidth() - mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ) / 2.f ) ) + @@ -201,7 +201,7 @@ void UICheckBox::alignFix() { break; case UI_HALIGN_RIGHT: mRealAlignOffset.x = ( (Float)mSize.x - mPaddingPx.Left - mPaddingPx.Right - - (Float)mTextCache->getTextWidth() ); + (Float)mTextCache.getTextWidth() ); break; case UI_HALIGN_LEFT: mRealAlignOffset.x = diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index 1117ccd30..42772ca12 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -14,7 +14,7 @@ UIComboBox::UIComboBox() : UIWidget( "combobox" ), mDropDownList( NULL ), mButto mDropDownList->setVisible( true ); mDropDownList->setEnabled( true ); mDropDownList->setAllowEditing( true ); - mDropDownList->setTextSelection( true ); + mDropDownList->setTextSelectionEnabled( true ); mDropDownList->on( Event::OnPaddingChange, [this]( const Event* ) { onPaddingChange(); } ); mDropDownList->on( Event::OnSizeChange, [this]( const Event* ) { onSizeChange(); } ); mDropDownList->on( Event::OnValueChange, diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 314b94bd5..bbd3a2313 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -10,8 +10,7 @@ namespace EE { namespace UI { -UIDropDownList::MenuWidthMode -UIDropDownList::menuWidthModeFromString( std::string_view str ) { +UIDropDownList::MenuWidthMode UIDropDownList::menuWidthModeFromString( std::string_view str ) { if ( "contents" == str || "fit-to-contents" == str ) return MenuWidthMode::Contents; if ( "contents-centered" == str || "fit-to-contents-centered" == str ) @@ -125,7 +124,7 @@ void UIDropDownList::setFriendNode( UINode* friendNode ) { void UIDropDownList::onAutoSize() { Float max = eemax( PixelDensity::dpToPxI( getSkinSize().getHeight() ), - mTextCache->getLineSpacing() ); + mTextCache.getLineSpacing() ); if ( mHeightPolicy == SizePolicy::WrapContent ) { setInternalPixelsHeight( eeceil( max + mPaddingPx.Top + mPaddingPx.Bottom ) ); @@ -180,17 +179,14 @@ UIDropDownList* UIDropDownList::showList() { Float width = NULL != mFriendNode ? mFriendNode->getSize().getWidth() : getSize().getWidth(); - bool center = - mStyleConfig.menuWidthRule == MenuWidthMode::ContentsCentered || - mStyleConfig.menuWidthRule == - MenuWidthMode::ExpandIfNeededCentered; + bool center = mStyleConfig.menuWidthRule == MenuWidthMode::ContentsCentered || + mStyleConfig.menuWidthRule == MenuWidthMode::ExpandIfNeededCentered; Float contentsWidth = 0; if ( mStyleConfig.menuWidthRule == MenuWidthMode::Contents || mStyleConfig.menuWidthRule == MenuWidthMode::ContentsCentered || mStyleConfig.menuWidthRule == MenuWidthMode::ExpandIfNeeded || - mStyleConfig.menuWidthRule == - MenuWidthMode::ExpandIfNeededCentered ) { + mStyleConfig.menuWidthRule == MenuWidthMode::ExpandIfNeededCentered ) { contentsWidth = eeceil( PixelDensity::pxToDp( mListBox->getMaxTextWidth() + PixelDensity::dpToPx( mListBox->getContainerPadding().getWidth() ) + @@ -204,8 +200,7 @@ UIDropDownList* UIDropDownList::showList() { } if ( ( mStyleConfig.menuWidthRule == MenuWidthMode::ExpandIfNeeded || - mStyleConfig.menuWidthRule == - MenuWidthMode::ExpandIfNeededCentered ) && + mStyleConfig.menuWidthRule == MenuWidthMode::ExpandIfNeededCentered ) && contentsWidth > width ) { width = contentsWidth; } @@ -467,9 +462,10 @@ std::string UIDropDownList::getPropertyString( const PropertyDefinition* propert std::vector UIDropDownList::getPropertiesImplemented() const { auto props = UITextInput::getPropertiesImplemented(); - auto local = { PropertyId::PopUpToRoot, PropertyId::MaxVisibleItems, PropertyId::SelectedIndex, - PropertyId::SelectedText, PropertyId::ScrollBarStyle, PropertyId::RowHeight, - PropertyId::VScrollMode, PropertyId::HScrollMode, PropertyId::MenuWidthMode }; + auto local = { + PropertyId::PopUpToRoot, PropertyId::MaxVisibleItems, PropertyId::SelectedIndex, + PropertyId::SelectedText, PropertyId::ScrollBarStyle, PropertyId::RowHeight, + PropertyId::VScrollMode, PropertyId::HScrollMode, PropertyId::MenuWidthMode }; props.insert( props.end(), local.begin(), local.end() ); return props; } diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index 3effc3bd1..0aaf5bc9e 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -82,7 +82,7 @@ void UIRadioButton::onAutoSize() { if ( mFlags & UI_AUTO_SIZE ) { if ( getSize().getWidth() == 0 ) { setInternalPixelsWidth( - (int)mTextCache->getTextWidth() + mActiveButton->getPixelsSize().getWidth() + + (int)mTextCache.getTextWidth() + mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) + mPaddingPx.Left + mPaddingPx.Right ); } @@ -93,13 +93,13 @@ void UIRadioButton::onAutoSize() { } if ( mWidthPolicy == SizePolicy::WrapContent ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mPaddingPx.Left + + setInternalPixelsWidth( (int)mTextCache.getTextWidth() + mPaddingPx.Left + mPaddingPx.Right + mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { - setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mPaddingPx.Top + + setInternalPixelsHeight( (int)mTextCache.getTextHeight() + mPaddingPx.Top + mPaddingPx.Bottom ); } @@ -239,7 +239,7 @@ void UIRadioButton::alignFix() { switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = (Float)( (Int32)( ( mSize.x - mPaddingPx.Left - mPaddingPx.Right - - mTextCache->getTextWidth() - + mTextCache.getTextWidth() - mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ) / 2.f ) ) + @@ -248,7 +248,7 @@ void UIRadioButton::alignFix() { break; case UI_HALIGN_RIGHT: mRealAlignOffset.x = ( (Float)mSize.x - mPaddingPx.Left - mPaddingPx.Right - - (Float)mTextCache->getTextWidth() ); + (Float)mTextCache.getTextWidth() ); break; case UI_HALIGN_LEFT: mRealAlignOffset.x = diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index db18279ef..8243f9529 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -111,8 +111,8 @@ void UITextInput::drawWaitingCursor() { Primitives primitives; primitives.setColor( Color( mFontStyleConfig.FontColor ).blendAlpha( mAlpha ) ); primitives.drawRectangle( Rectf( - cursor, Sizef( PixelDensity::dpToPx( 1 ), mTextCache->getFont()->getFontHeight( - mTextCache->getCharacterSize() ) ) ) ); + cursor, Sizef( PixelDensity::dpToPx( 1 ), mTextCache.getFont()->getFontHeight( + mTextCache.getCharacterSize() ) ) ) ); } } @@ -132,10 +132,10 @@ void UITextInput::draw() { if ( mVisible && 0.f != mAlpha ) { UINode::draw(); - if ( mTextCache->getTextWidth() ) { + if ( mTextCache.getTextWidth() ) { drawSelection( mTextCache ); - mTextCache->setAlign( getFlags() ); - mTextCache->draw( + mTextCache.setAlign( getFlags() ); + mTextCache.draw( std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + (int)mPaddingPx.Left, std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); @@ -201,7 +201,7 @@ void UITextInput::alignFix() { UITextView::alignFix(); if ( mAllowEditing && Font::getHorizontalAlign( getFlags() ) == UI_HALIGN_LEFT ) { - Float tW = getVisibleTextCache()->findCharacterPos( selCurInit() ).x; + Float tW = getVisibleTextCache().findCharacterPos( selCurInit() ).x; mCurPos.x = tW; mCurPos.y = 0; @@ -240,7 +240,7 @@ void UITextInput::onThemeLoaded() { void UITextInput::onAutoSize() { if ( mHeightPolicy == SizePolicy::WrapContent ) { - int minHeight = eemax( mTextCache->getLineSpacing(), + int minHeight = eemax( mTextCache.getLineSpacing(), PixelDensity::dpToPxI( getSkinSize().getHeight() ) ); setInternalPixelsHeight( minHeight + mPaddingPx.Top + mPaddingPx.Bottom ); } else if ( ( mFlags & UI_AUTO_SIZE ) && 0 == getSize().getHeight() ) { @@ -818,7 +818,7 @@ void UITextInput::updateIMELocation() { return; Vector2f cursor( eefloor( mScreenPos.x + mRealAlignOffset.x + mCurPos.x + mPaddingPx.Left ), mScreenPos.y + mRealAlignOffset.y + mCurPos.y + mPaddingPx.Top ); - Float h = mTextCache->getFont()->getFontHeight( mTextCache->getCharacterSize() ); + Float h = mTextCache.getFont()->getFontHeight( mTextCache.getCharacterSize() ); getUISceneNode()->getWindow()->getIME().setLocation( Rectf( cursor, { 0, h } ).asInt() ); } diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index 71704e2ce..525b7d0a0 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -12,20 +12,16 @@ UITextInputPassword* UITextInputPassword::New() { UITextInputPassword::UITextInputPassword() : UITextInput( "textinputpassword" ), mBulletCharacter( "●" ) { - mPassCache = Text::New(); - updateFontStyleConfig(); } -UITextInputPassword::~UITextInputPassword() { - eeSAFE_DELETE( mPassCache ); -} +UITextInputPassword::~UITextInputPassword() {} void UITextInputPassword::draw() { if ( mVisible && 0.f != mAlpha ) { UINode::draw(); - if ( mPassCache->getTextWidth() ) { + if ( mPassCache.getTextWidth() ) { drawSelection( mPassCache ); if ( isClipped() ) { @@ -34,8 +30,8 @@ void UITextInputPassword::draw() { mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } - mPassCache->setAlign( getFlags() ); - mPassCache->draw( + mPassCache.setAlign( getFlags() ); + mPassCache.draw( std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + (int)mPaddingPx.Left, std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); @@ -64,17 +60,17 @@ void UITextInputPassword::draw() { drawWaitingCursor(); } -Text* UITextInputPassword::getVisibleTextCache() const { +Text& UITextInputPassword::getVisibleTextCache() { return mPassCache; } void UITextInputPassword::updateText() { - updatePass( mTextCache->getString() ); + updatePass( mTextCache.getString() ); } void UITextInputPassword::updatePass( const String& pass ) { - if ( mBulletCharacter.size() == 1 && mPassCache->getFont()->getType() == FontType::TTF && - !static_cast( mPassCache->getFont() ) + if ( mBulletCharacter.size() == 1 && mPassCache.getFont()->getType() == FontType::TTF && + !static_cast( mPassCache.getFont() ) ->hasGlyph( mBulletCharacter.front() ) ) { mBulletCharacter = "•"; } @@ -84,7 +80,7 @@ void UITextInputPassword::updatePass( const String& pass ) { for ( size_t i = 0; i < pass.size(); i++ ) newTxt += mBulletCharacter; - mPassCache->setString( newTxt ); + mPassCache.setString( newTxt ); } UITextView* UITextInputPassword::setText( const String& text ) { @@ -95,7 +91,7 @@ UITextView* UITextInputPassword::setText( const String& text ) { return this; } -Text* UITextInputPassword::getPassCache() const { +const Text& UITextInputPassword::getPassCache() const { return mPassCache; } @@ -108,12 +104,12 @@ void UITextInputPassword::setBulletCharacter( const String& bulletCharacter ) { } void UITextInputPassword::updateFontStyleConfig() { - mPassCache->setFontSize( mFontStyleConfig.CharacterSize ); - mPassCache->setFont( mFontStyleConfig.getFont() ); - mPassCache->setFillColor( mFontStyleConfig.getFontColor() ); - mPassCache->setShadowColor( mFontStyleConfig.getFontShadowColor() ); - mPassCache->setOutlineColor( mFontStyleConfig.getOutlineColor() ); - mPassCache->setOutlineThickness( mFontStyleConfig.getOutlineThickness() ); + mPassCache.setFontSize( mFontStyleConfig.CharacterSize ); + mPassCache.setFont( mFontStyleConfig.getFont() ); + mPassCache.setFillColor( mFontStyleConfig.getFontColor() ); + mPassCache.setShadowColor( mFontStyleConfig.getFontShadowColor() ); + mPassCache.setOutlineColor( mFontStyleConfig.getOutlineColor() ); + mPassCache.setOutlineThickness( mFontStyleConfig.getOutlineThickness() ); } void UITextInputPassword::onStateChange() { diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index 1b535b028..7967afaf7 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -35,7 +35,6 @@ UITextView::UITextView( const std::string& tag ) : mLastSelCurInit( 0 ), mLastSelCurEnd( 0 ), mSelecting( false ) { - mTextCache = Text::New(); UITheme* theme = getUISceneNode()->getUIThemeManager()->getDefaultTheme(); @@ -62,9 +61,7 @@ UITextView::UITextView( const std::string& tag ) : UITextView::UITextView() : UITextView( "textview" ) {} -UITextView::~UITextView() { - eeSAFE_DELETE( mTextCache ); -} +UITextView::~UITextView() {} Uint32 UITextView::getType() const { return UI_TYPE_TEXTVIEW; @@ -78,7 +75,7 @@ void UITextView::draw() { if ( mVisible && 0.f != mAlpha ) { UINode::draw(); - if ( mTextCache->getTextWidth() <= 0.f ) + if ( mTextCache.getTextWidth() <= 0.f ) return; drawSelection( mTextCache ); @@ -89,11 +86,11 @@ void UITextView::draw() { mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } - mTextCache->setAlign( Font::getHorizontalAlign( getFlags() ) ); - mTextCache->draw( - std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + (int)mPaddingPx.Left, - std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top, - Vector2f::One, 0.f, getBlendMode() ); + mTextCache.setAlign( Font::getHorizontalAlign( getFlags() ) ); + mTextCache.draw( std::trunc( mScreenPos.x ) + (int)mRealAlignOffset.x + + (int)mPaddingPx.Left, + std::trunc( mScreenPos.y ) + (int)mRealAlignOffset.y + (int)mPaddingPx.Top, + Vector2f::One, 0.f, getBlendMode() ); if ( isClipped() ) clipSmartDisable(); @@ -101,12 +98,12 @@ void UITextView::draw() { } Graphics::Font* UITextView::getFont() const { - return mTextCache->getFont(); + return mTextCache.getFont(); } UITextView* UITextView::setFont( Graphics::Font* font ) { - if ( NULL != font && mTextCache->getFont() != font ) { - mTextCache->setFont( font ); + if ( NULL != font && mTextCache.getFont() != font ) { + mTextCache.setFont( font ); mFontStyleConfig.Font = font; recalculate(); onFontChanged(); @@ -118,13 +115,13 @@ UITextView* UITextView::setFont( Graphics::Font* font ) { } Uint32 UITextView::getFontSize() const { - return mTextCache->getCharacterSize(); + return mTextCache.getCharacterSize(); } UITextView* UITextView::setFontSize( const Uint32& characterSize ) { - if ( mTextCache->getCharacterSize() != characterSize ) { + if ( mTextCache.getCharacterSize() != characterSize ) { mFontStyleConfig.CharacterSize = characterSize; - mTextCache->setFontSize( characterSize ); + mTextCache.setFontSize( characterSize ); recalculate(); onFontStyleChanged(); notifyLayoutAttrChange(); @@ -144,7 +141,7 @@ const Float& UITextView::getOutlineThickness() const { UITextView* UITextView::setOutlineThickness( const Float& outlineThickness ) { if ( mFontStyleConfig.OutlineThickness != outlineThickness ) { - mTextCache->setOutlineThickness( outlineThickness ); + mTextCache.setOutlineThickness( outlineThickness ); mFontStyleConfig.OutlineThickness = outlineThickness; recalculate(); onFontStyleChanged(); @@ -164,7 +161,7 @@ UITextView* UITextView::setOutlineColor( const Color& outlineColor ) { mFontStyleConfig.OutlineColor = outlineColor; Color newColor( outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a * mAlpha / 255.f ); - mTextCache->setOutlineColor( newColor ); + mTextCache.setOutlineColor( newColor ); onFontStyleChanged(); invalidateDraw(); } @@ -174,7 +171,7 @@ UITextView* UITextView::setOutlineColor( const Color& outlineColor ) { UITextView* UITextView::setFontStyle( const Uint32& fontStyle ) { if ( mFontStyleConfig.Style != fontStyle ) { - mTextCache->setStyle( fontStyle ); + mTextCache.setStyle( fontStyle ); mFontStyleConfig.Style = fontStyle; recalculate(); onFontStyleChanged(); @@ -189,14 +186,14 @@ const String& UITextView::getText() const { if ( mFlags & UI_WORD_WRAP ) return mString; - return mTextCache->getString(); + return mTextCache.getString(); } UITextView* UITextView::setText( const String& text ) { if ( mString != text ) { mString = text; mTextDrawHints = mString.getTextHints(); - mTextCache->setString( mString ); + mTextCache.setString( mString ); recalculate(); onTextChanged(); @@ -210,7 +207,7 @@ UITextView* UITextView::setText( String&& text ) { if ( mString != text ) { mString = std::move( text ); mTextDrawHints = mString.getTextHints(); - mTextCache->setString( mString ); + mTextCache.setString( mString ); recalculate(); onTextChanged(); @@ -228,7 +225,7 @@ UITextView* UITextView::setFontColor( const Color& color ) { if ( mFontStyleConfig.FontColor != color ) { mFontStyleConfig.FontColor = color; Color newColor( color.r, color.g, color.b, color.a * mAlpha / 255.f ); - mTextCache->setFillColor( newColor ); + mTextCache.setFillColor( newColor ); invalidateDraw(); } @@ -237,17 +234,17 @@ UITextView* UITextView::setFontColor( const Color& color ) { UITextView* UITextView::setFontFillColor( const Color& color, Uint32 from, Uint32 to ) { Color newColor( color.r, color.g, color.b, color.a * mAlpha / 255.f ); - mTextCache->setFillColor( newColor, from, to ); + mTextCache.setFillColor( newColor, from, to ); invalidateDraw(); return this; } const Text* UITextView::getTextCache() const { - return mTextCache; + return &mTextCache; } Text* UITextView::getTextCache() { - return mTextCache; + return &mTextCache; } const Vector2f& UITextView::getRealAlignOffset() const { @@ -259,8 +256,8 @@ const TextTransform::Value& UITextView::getTextTransform() const { } void UITextView::transformText() { - mTextCache->setString( mString ); - mTextCache->transformText( mTextTransform ); + mTextCache.setString( mString ); + mTextCache.transformText( mTextTransform ); } void UITextView::setTextTransform( const TextTransform::Value& textTransform ) { @@ -283,8 +280,8 @@ UITextView* UITextView::setFontShadowColor( const Color& color ) { else mFontStyleConfig.Style &= ~Text::Shadow; Color newColor( color.r, color.g, color.b, color.a * mAlpha / 255.f ); - mTextCache->setShadowColor( newColor ); - mTextCache->setStyle( mFontStyleConfig.Style ); + mTextCache.setShadowColor( newColor ); + mTextCache.setStyle( mFontStyleConfig.Style ); onFontStyleChanged(); recalculate(); invalidateDraw(); @@ -300,7 +297,7 @@ const Vector2f& UITextView::getFontShadowOffset() const { UITextView* UITextView::setFontShadowOffset( const Vector2f& offset ) { if ( mFontStyleConfig.ShadowOffset != offset ) { mFontStyleConfig.ShadowOffset = offset; - mTextCache->setShadowOffset( offset ); + mTextCache.setShadowOffset( offset ); onFontStyleChanged(); invalidateDraw(); } @@ -323,8 +320,7 @@ UITextView* UITextView::setSelectionBackColor( const Color& color ) { } void UITextView::autoWrap() { - mTextCache->setLineWrapMode( mFlags & UI_WORD_WRAP ? LineWrapMode::Word - : LineWrapMode::NoWrap ); + mTextCache.setLineWrapMode( mFlags & UI_WORD_WRAP ? LineWrapMode::Word : LineWrapMode::NoWrap ); if ( mFlags & UI_WORD_WRAP ) { wrapText( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right ); @@ -333,11 +329,11 @@ void UITextView::autoWrap() { void UITextView::wrapText( const Uint32& maxWidth ) { if ( mFlags & UI_WORD_WRAP ) { - mTextCache->setString( mString ); + mTextCache.setString( mString ); } - mTextCache->setLineWrapMode( LineWrapMode::Word ); - mTextCache->setMaxWrapWidth( maxWidth ); + mTextCache.setLineWrapMode( LineWrapMode::Word ); + mTextCache.setMaxWrapWidth( maxWidth ); invalidateDraw(); } @@ -345,7 +341,7 @@ void UITextView::onAutoSize() { bool sizeChanged = false; if ( ( mFlags & UI_AUTO_SIZE && 0 == getSize().getWidth() ) ) { - setInternalPixelsSize( Sizef( getTextWidth(), mTextCache->getTextHeight() ) ); + setInternalPixelsSize( Sizef( getTextWidth(), mTextCache.getTextHeight() ) ); sizeChanged = true; } @@ -365,7 +361,7 @@ void UITextView::onAutoSize() { } if ( mHeightPolicy == SizePolicy::WrapContent ) { - Float totH = (int)mTextCache->getTextHeight() + mPaddingPx.Top + mPaddingPx.Bottom; + Float totH = (int)mTextCache.getTextHeight() + mPaddingPx.Top + mPaddingPx.Bottom; if ( !getMaxHeightEq().empty() ) { Float oldH = totH; totH = eemin( totH, getMaxSizePx().getHeight() ); @@ -403,16 +399,16 @@ void UITextView::alignFix() { switch ( Font::getVerticalAlign( getFlags() ) ) { case UI_VALIGN_CENTER: { Float height = mSize.y - mPaddingPx.Top - mPaddingPx.Bottom; - Float fontSize = mTextCache->getCharacterSize(); - Float lineSpacing = mTextCache->getFont()->getLineSpacing( fontSize ); + Float fontSize = mTextCache.getCharacterSize(); + Float lineSpacing = mTextCache.getFont()->getLineSpacing( fontSize ); Float center = eefloor( ( lineSpacing - fontSize ) * 0.5f ); - Float textHeight = mTextCache->getTextHeight(); + Float textHeight = mTextCache.getTextHeight(); mRealAlignOffset.y = eefloor( ( height - textHeight + center ) * 0.5f ); break; } case UI_VALIGN_BOTTOM: mRealAlignOffset.y = ( (Float)mSize.y - mPaddingPx.Top - mPaddingPx.Bottom - - (Float)mTextCache->getTextHeight() ); + (Float)mTextCache.getTextHeight() ); break; case UI_VALIGN_TOP: mRealAlignOffset.y = 0; @@ -453,15 +449,15 @@ void UITextView::onFontStyleChanged() { void UITextView::onAlphaChange() { Color color( getFontColor() ); Color newColor( color.r, color.g, color.b, color.a * mAlpha / 255.f ); - mTextCache->setFillColor( newColor ); + mTextCache.setFillColor( newColor ); color = getFontShadowColor(); newColor = Color( color.r, color.g, color.b, color.a * mAlpha / 255.f ); - mTextCache->setShadowColor( newColor ); + mTextCache.setShadowColor( newColor ); color = getOutlineColor(); newColor = Color( color.r, color.g, color.b, color.a * mAlpha / 255.f ); - mTextCache->setOutlineColor( newColor ); + mTextCache.setOutlineColor( newColor ); invalidateDraw(); } @@ -480,15 +476,15 @@ void UITextView::setTheme( UITheme* Theme ) { Float UITextView::getTextWidth() { return hasTextOverflow() ? Text::getTextWidth( mString, mFontStyleConfig, 4, mTextDrawHints ) - : mTextCache->getTextWidth(); + : mTextCache.getTextWidth(); } Float UITextView::getTextHeight() { - return mTextCache->getTextHeight(); + return mTextCache.getTextHeight(); } Uint32 UITextView::getNumLines() { - return mTextCache->getNumLines(); + return mTextCache.getNumLines(); } Vector2f UITextView::getAlignOffset() const { @@ -504,12 +500,12 @@ Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32& Flags nodePos.x = eemax( 0.f, nodePos.x ); nodePos.y = eemax( 0.f, nodePos.y ); - Int32 curPos = mTextCache->findCharacterFromPos( nodePos.asInt() ); + Int32 curPos = mTextCache.findCharacterFromPos( nodePos.asInt() ); if ( -1 != curPos ) { Int32 tSelCurInit, tSelCurEnd; - getVisibleTextCache()->findWordFromCharacterIndex( curPos, tSelCurInit, tSelCurEnd ); + getVisibleTextCache().findWordFromCharacterIndex( curPos, tSelCurInit, tSelCurEnd ); selCurInit( tSelCurEnd ); selCurEnd( tSelCurInit ); @@ -540,7 +536,7 @@ Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32& Flags ) { nodePos.x = eemax( 0.f, nodePos.x ); nodePos.y = eemax( 0.f, nodePos.y ); - Int32 curPos = getVisibleTextCache()->findCharacterFromPos( nodePos.asInt() ); + Int32 curPos = getVisibleTextCache().findCharacterFromPos( nodePos.asInt() ); if ( -1 != curPos ) { if ( !mSelecting ) { @@ -559,12 +555,12 @@ Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32& Flags ) { return UIWidget::onMouseDown( Pos, Flags ); } -void UITextView::drawSelection( Text* textCache ) { +void UITextView::drawSelection( Text& textCache ) { if ( selCurInit() != selCurEnd() ) { Int32 init = eemin( selCurInit(), selCurEnd() ); Int32 end = eemax( selCurInit(), selCurEnd() ); - if ( init < 0 && end > (Int32)textCache->getString().size() ) { + if ( init < 0 && end > (Int32)textCache.getString().size() ) { return; } @@ -572,7 +568,7 @@ void UITextView::drawSelection( Text* textCache ) { mSelRectsCache.clear(); mLastSelCurInit = selCurInit(); mLastSelCurEnd = selCurEnd(); - mSelRectsCache = mTextCache->getSelectionRects( selCurInit(), selCurEnd() ); + mSelRectsCache = mTextCache.getSelectionRects( { selCurInit(), selCurEnd() } ); } if ( !mSelRectsCache.empty() ) { @@ -583,11 +579,11 @@ void UITextView::drawSelection( Text* textCache ) { initPos = mSelRectsCache[i].getPosition(); endPos = mSelRectsCache[i].getPosition() + mSelRectsCache[i].getSize(); - P.drawRectangle( Rectf( - mScreenPos.x + initPos.x + mRealAlignOffset.x + mPaddingPx.Left, - mScreenPos.y + initPos.y + mRealAlignOffset.y + mPaddingPx.Top, - mScreenPos.x + endPos.x + mRealAlignOffset.x + mPaddingPx.Left, - mScreenPos.y + endPos.y + mRealAlignOffset.y + mPaddingPx.Top ) ); + P.drawRectangle( + Rectf( mScreenPos.x + initPos.x + mRealAlignOffset.x + mPaddingPx.Left, + mScreenPos.y + initPos.y + mRealAlignOffset.y + mPaddingPx.Top, + mScreenPos.x + endPos.x + mRealAlignOffset.x + mPaddingPx.Left, + mScreenPos.y + endPos.y + mRealAlignOffset.y + mPaddingPx.Top ) ); } } } @@ -597,7 +593,7 @@ bool UITextView::isTextSelectionEnabled() const { return 0 != ( mFlags & UI_TEXT_SELECTION_ENABLED ); } -void UITextView::setTextSelection( const bool& active ) { +void UITextView::setTextSelectionEnabled( bool active ) { if ( active ) { mFlags |= UI_TEXT_SELECTION_ENABLED; } else { @@ -621,13 +617,13 @@ void UITextView::setFontStyleConfig( const UIFontStyleConfig& fontStyleConfig ) onFontStyleChanged(); } -std::pair UITextView::getSelection() const { +std::pair UITextView::getTextSelectionRange() const { return { mSelCurInit, mSelCurEnd }; } -void UITextView::setSelection( std::pair sel ) { - selCurInit( std::clamp( sel.first, 0, (Int32)mString.size() ) ); - selCurEnd( std::clamp( sel.second, 0, (Int32)mString.size() ) ); +void UITextView::setTextSelectionRange( TextSelectionRange range ) { + selCurInit( std::clamp( range.start, (Int64)0, (Int64)mString.size() ) ); + selCurEnd( std::clamp( range.end, (Int64)0, (Int64)mString.size() ) ); } void UITextView::selCurInit( const Int32& init ) { @@ -658,23 +654,23 @@ void UITextView::onAlignChange() { } void UITextView::onSelectionChange() { - mTextCache->invalidateColors(); + mTextCache.invalidateColors(); if ( selCurInit() != selCurEnd() ) { Color color( mFontStyleConfig.getFontSelectedColor() ); color.a = mFontStyleConfig.getFontSelectedColor().a * mAlpha / 255.f; - mTextCache->setFillColor( color, eemin( selCurInit(), selCurEnd() ), - eemax( selCurInit(), selCurEnd() ) - 1 ); + mTextCache.setFillColor( color, eemin( selCurInit(), selCurEnd() ), + eemax( selCurInit(), selCurEnd() ) - 1 ); } else { Color color( mFontStyleConfig.getFontColor() ); color.a = mFontStyleConfig.getFontColor().a * mAlpha / 255.f; - mTextCache->setFillColor( color ); + mTextCache.setFillColor( color ); } invalidateDraw(); } -Text* UITextView::getVisibleTextCache() const { +Text& UITextView::getVisibleTextCache() { return mTextCache; } @@ -768,7 +764,7 @@ bool UITextView::applyProperty( const StyleSheetProperty& attribute ) { break; case PropertyId::TextSelection: if ( !mUsingCustomStyling ) - setTextSelection( attribute.asBool() ); + setTextSelectionEnabled( attribute.asBool() ); break; case PropertyId::TextAlign: { std::string align = String::toLower( attribute.value() ); @@ -885,12 +881,12 @@ void UITextView::updateTextOverflow() { maxWidth -= mTextOverflowWidth; charPos = Text::findLastCharPosWithinLength( mString, maxWidth, mFontStyleConfig, 4, {}, mTextDrawHints ); - mTextCache->setString( mString.view().substr( 0, charPos ) + mTextOverflow ); + mTextCache.setString( mString.view().substr( 0, charPos ) + mTextOverflow ); } else { if ( mFlags & UI_WORD_WRAP ) { autoWrap(); - } else if ( mString != mTextCache->getString() ) { - mTextCache->setString( mString ); + } else if ( mString != mTextCache.getString() ) { + mTextCache.setString( mString ); } } } else { @@ -898,8 +894,8 @@ void UITextView::updateTextOverflow() { if ( mFlags & UI_WORD_WRAP ) { autoWrap(); - } else if ( mString != mTextCache->getString() ) { - mTextCache->setString( mString ); + } else if ( mString != mTextCache.getString() ) { + mTextCache.setString( mString ); } } } diff --git a/src/tests/ui_perf_test/ui_perf_test.cpp b/src/tests/ui_perf_test/ui_perf_test.cpp index aacf2b01e..668df6dc5 100644 --- a/src/tests/ui_perf_test/ui_perf_test.cpp +++ b/src/tests/ui_perf_test/ui_perf_test.cpp @@ -187,7 +187,7 @@ EE_MAIN_FUNC int main( int, char*[] ) { std::string buffer; FileSystem::fileGet( "unit_tests/assets/textfiles/lorem-ipsum.uext", buffer ); editor->setText( buffer ); - editor->setTextSelection( true ); + editor->setTextSelectionEnabled( true ); editor->setFont( app.getUI()->getUIThemeManager()->getDefaultFont() ); editor->on( Event::KeyUp, [&]( const Event* event ) { diff --git a/src/tests/unit_tests/fontrendering.cpp b/src/tests/unit_tests/fontrendering.cpp index b8daf6cf3..121da4e67 100644 --- a/src/tests/unit_tests/fontrendering.cpp +++ b/src/tests/unit_tests/fontrendering.cpp @@ -1104,8 +1104,8 @@ UTEST( FontRendering, UITextViewWrappedSelection ) { textView->setPixelsSize( app.getUI()->getPixelsSize() ); textView->setText( buffer ); textView->setWordWrap( true ); - textView->setTextSelection( true ); - textView->setSelection( { 51, 286 } ); + textView->setTextSelectionEnabled( true ); + textView->setTextSelectionRange( { 51, 286 } ); SceneManager::instance()->update(); SceneManager::instance()->draw(); compareImages( utest_state, utest_result, app.getWindow(), @@ -1206,7 +1206,7 @@ UTEST( FontRendering, TextSelection ) { // Test 1: Single line selection (Line 1) { - std::vector rects = text.getSelectionRects( 0, 4 ); // "Line" + std::vector rects = text.getSelectionRects( { 0, 4 } ); // "Line" EXPECT_EQ( 1ul, rects.size() ); if ( !rects.empty() ) { EXPECT_EQ( 0, rects[0].Top ); @@ -1220,7 +1220,7 @@ UTEST( FontRendering, TextSelection ) { { // "Line 1\nLine 2" -> Indices: "Line 1" (0-5), "\n" (6), "Line 2" (7-12) // Select from index 2 ("n" in "Line 1") to index 9 ("i" in "Line 2") - std::vector rects = text.getSelectionRects( 2, 9 ); + std::vector rects = text.getSelectionRects( { 2, 9 } ); EXPECT_EQ( 2ul, rects.size() ); if ( rects.size() >= 2 ) { // First line rect: From index 2 to end of line 1 @@ -1235,7 +1235,8 @@ UTEST( FontRendering, TextSelection ) { // Test 3: Full selection { - std::vector rects = text.getSelectionRects( 0, txt.size() ); + std::vector rects = + text.getSelectionRects( { 0, static_cast( txt.size() ) } ); EXPECT_EQ( 3ul, rects.size() ); } @@ -1250,7 +1251,8 @@ UTEST( FontRendering, TextSelection ) { EXPECT_GT( text.getVisualLineCount(), (Uint32)1 ); - std::vector rects = text.getSelectionRects( 0, text.getString().size() ); + std::vector rects = + text.getSelectionRects( { 0, static_cast( text.getString().size() ) } ); EXPECT_EQ( (size_t)text.getVisualLineCount(), rects.size() ); } diff --git a/src/tools/ecode/applayout.xml.hpp b/src/tools/ecode/applayout.xml.hpp index 676dd775c..42fa9f631 100644 --- a/src/tools/ecode/applayout.xml.hpp +++ b/src/tools/ecode/applayout.xml.hpp @@ -441,13 +441,15 @@ Anchor.error:hover { border-width: 1dp; border-color: var(--primary); } -#build_output_issues TableView::cell.theme-warning > TableView::cell::icon { +#build_output_issues TableView::row TableView::cell.theme-warning { tint: var(--theme-warning); + color: var(--theme-warning); } -#build_output_issues TableView::cell.theme-error > TableView::cell::icon { +#build_output_issues TableView::row TableView::cell.theme-error { tint: var(--theme-error); + color: var(--theme-error); } -#build_output_issues TableView::row:selected TableView::cell.theme-error > TableView::cell { +#build_output_issues TableView::row:selected TableView::cell.theme-error { color: var(--list-row-active); tint: var(--list-row-active); } diff --git a/src/tools/ecode/notificationcenter.cpp b/src/tools/ecode/notificationcenter.cpp index 6734a9e5c..e7618b5ae 100644 --- a/src/tools/ecode/notificationcenter.cpp +++ b/src/tools/ecode/notificationcenter.cpp @@ -51,7 +51,7 @@ void NotificationCenter::addNotification( const String& text, const Time& delay, tv->setFlags( UI_WORD_WRAP ); tv->setText( text ); tv->addClass( "notification" ); - tv->setTextSelection( allowCopy ); + tv->setTextSelectionEnabled( allowCopy ); mLayout->toFront(); Action* sequence = Actions::Sequence::New( { Actions::FadeIn::New( Seconds( 0.125 ) ), Actions::Delay::New( delay ), @@ -114,7 +114,7 @@ void NotificationCenter::addInteractiveNotification( String text, String actionT ->asType(); UITextView* tv = lay->findByType( UI_TYPE_TEXTVIEW )->asType(); tv->setText( text ); - tv->setTextSelection( allowCopy ); + tv->setTextSelectionEnabled( allowCopy ); tv->on( Event::MouseClick, [allowCopy, lay]( const Event* event ) { const MouseEvent* mouseEvent = static_cast( event ); if ( mouseEvent->getFlags() & diff --git a/src/tools/ecode/plugins/aiassistant/aiassistantplugin.cpp b/src/tools/ecode/plugins/aiassistant/aiassistantplugin.cpp index b3252adaa..b6fbbb565 100644 --- a/src/tools/ecode/plugins/aiassistant/aiassistantplugin.cpp +++ b/src/tools/ecode/plugins/aiassistant/aiassistantplugin.cpp @@ -327,6 +327,11 @@ void AIAssistantPlugin::loadAIAssistantConfig( const std::string& path, bool upd mApiKeys["openrouter"] = config.value( "openrouter_api_key", "" ); else if ( updateConfigFile ) config["openrouter_api_key"] = mApiKeys["openrouter"]; + + if ( config.contains( "moonshot_api_key" ) ) + mApiKeys["moonshot"] = config.value( "moonshot_api_key", "" ); + else if ( updateConfigFile ) + config["moonshot_api_key"] = mApiKeys["moonshot"]; } if ( mKeyBindings.empty() ) { @@ -520,6 +525,8 @@ std::optional AIAssistantPlugin::getApiKeyFromProvider( const std:: ret = getenv( "PERPLEXITY_API_KEY" ); } else if ( provider == "openrouter" ) { ret = getenv( "OPENROUTER_API_KEY" ); + } else if ( provider == "moonshot" ) { + ret = getenv( "MOONSHOT_API_KEY" ); } if ( ret ) diff --git a/src/tools/ecode/plugins/aiassistant/chatui.cpp b/src/tools/ecode/plugins/aiassistant/chatui.cpp index 971e3872d..6fceaa779 100644 --- a/src/tools/ecode/plugins/aiassistant/chatui.cpp +++ b/src/tools/ecode/plugins/aiassistant/chatui.cpp @@ -1408,7 +1408,7 @@ void LLMChatUI::showMsg( String msg ) { msgBox->getTextBox()->setPixelsSize( { PixelDensity::dpToPx( 600 ), msgBox->getTextBox()->getPixelsSize().getHeight() } ); msgBox->getTextBox()->setWordWrap( true ); - msgBox->getTextBox()->setTextSelection( true ); + msgBox->getTextBox()->setTextSelectionEnabled( true ); msgBox->getTextBox()->onClick( []( const MouseEvent* event ) { auto tv = event->getNode()->asType();