mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Some UI widgets constructor refactor and minor function renaming.
Added Moonshot LLM models support.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Drawable*, bool> mDrawablesOwnership;
|
||||
std::map<Uint32, Color> mDrawableColors;
|
||||
|
||||
explicit StateListDrawable( const std::string& name = "" );
|
||||
|
||||
StateListDrawable( Type type, const std::string& name = "" );
|
||||
|
||||
virtual void onColorFilterChange();
|
||||
|
||||
@@ -25,6 +25,11 @@ struct WhitespaceDisplayConfig {
|
||||
std::optional<Float> 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<Rectf> getSelectionRects( size_t selectionStartIndex, size_t selectionEndIndex );
|
||||
std::vector<Rectf> 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<Int64> mVisualLines;
|
||||
mutable std::vector<Float> mLinesWidth;
|
||||
@@ -407,7 +413,6 @@ class EE_API Text {
|
||||
std::vector<Color> mColors;
|
||||
std::vector<VertexCoords> mOutlineVertices;
|
||||
std::vector<Color> mOutlineColors;
|
||||
TextDirection mDirection{ TextDirection::Unspecified };
|
||||
|
||||
void ensureGeometryUpdate();
|
||||
|
||||
|
||||
@@ -73,8 +73,6 @@ class EE_API Node : public Transformable {
|
||||
|
||||
typedef std::function<void( const Event* )> 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 );
|
||||
|
||||
@@ -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<SyntaxTokenPosition> 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 );
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<UIListBoxItem*> mItems;
|
||||
std::vector<String> mTexts;
|
||||
|
||||
UIListBox();
|
||||
|
||||
void updateScroll( bool fromScrollChange = false );
|
||||
|
||||
void updateScrollBarState();
|
||||
|
||||
@@ -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<UIListBox>;
|
||||
|
||||
UIListBoxItem();
|
||||
|
||||
UIListBoxItem( const std::string& tag );
|
||||
|
||||
virtual void onStateChange();
|
||||
|
||||
virtual Uint32 onMouseUp( const Vector2i& position, const Uint32& flags );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<UIWidget*> mItems;
|
||||
Uint32 mMaxWidth;
|
||||
Uint32 mNextPosY;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -35,8 +35,6 @@ class EE_API UINode : public Node {
|
||||
|
||||
typedef std::function<void( const Event* )> 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 );
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<ThreadPool> mThreadPool;
|
||||
|
||||
explicit UISceneNode( EE::Window::Window* window = NULL );
|
||||
|
||||
virtual void resizeNode( EE::Window::Window* win );
|
||||
|
||||
virtual void onDrawDebugDataChange();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EE_UI_UISKINSTATE_HPP
|
||||
|
||||
#include <eepp/ui/uistate.hpp>
|
||||
#include <map>
|
||||
|
||||
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<Uint32, Color> mColors;
|
||||
Color mCurrentColor;
|
||||
|
||||
explicit UISkinState( UISkin* Skin );
|
||||
|
||||
void updateState();
|
||||
|
||||
void onStateChange();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -40,7 +40,6 @@ class EE_API UIStackLayout : public UILayout {
|
||||
|
||||
UIStackLayout();
|
||||
|
||||
|
||||
explicit UIStackLayout( const std::string& tag );
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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<bool( const UIWidget* widget )> mAcceptsDropOfWidgetFn;
|
||||
|
||||
UITabWidget();
|
||||
|
||||
void onThemeLoaded();
|
||||
|
||||
UITab* createTab( const String& text, UINode* nodeOwned, Drawable* icon );
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<int, int> getSelection() const;
|
||||
std::pair<int, int> getTextSelectionRange() const;
|
||||
|
||||
void setSelection( std::pair<int, int> 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 );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<std::string> mClasses;
|
||||
String mTooltipText;
|
||||
|
||||
UIWidget();
|
||||
|
||||
explicit UIWidget( const std::string& tag );
|
||||
|
||||
void updatePseudoClasses();
|
||||
|
||||
@@ -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<std::string, KeyBindingCommand> mKeyBindingCommands;
|
||||
std::function<bool( Node* focusNode )> mCheckEphemeralCloseFn;
|
||||
|
||||
explicit UIWindow( WindowBaseContainerType type, const StyleConfig& windowStyleConfig );
|
||||
|
||||
explicit UIWindow( WindowBaseContainerType type = SIMPLE_LAYOUT );
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
virtual void onAlphaChange();
|
||||
|
||||
@@ -2778,20 +2778,20 @@ size_t Text::findVisualLineFromCharIndex( size_t charIndex ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<Rectf> Text::getSelectionRects( size_t selectionStartIndex, size_t selectionEndIndex ) {
|
||||
std::vector<Rectf> Text::getSelectionRects( TextSelectionRange range ) {
|
||||
std::vector<Rectf> 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<Rectf> 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<Rectf> 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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<Float>( 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<PropertyId> 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;
|
||||
}
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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<int>( mTextCache->getLineSpacing(),
|
||||
int minHeight = eemax<int>( 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() );
|
||||
}
|
||||
|
||||
|
||||
@@ -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<FontTrueType*>( mPassCache->getFont() )
|
||||
if ( mBulletCharacter.size() == 1 && mPassCache.getFont()->getType() == FontType::TTF &&
|
||||
!static_cast<FontTrueType*>( 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() {
|
||||
|
||||
@@ -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<int, int> UITextView::getSelection() const {
|
||||
std::pair<int, int> UITextView::getTextSelectionRange() const {
|
||||
return { mSelCurInit, mSelCurEnd };
|
||||
}
|
||||
|
||||
void UITextView::setSelection( std::pair<int, int> 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<Int32>( selCurInit(), selCurEnd() ),
|
||||
eemax<Int32>( selCurInit(), selCurEnd() ) - 1 );
|
||||
mTextCache.setFillColor( color, eemin<Int32>( selCurInit(), selCurEnd() ),
|
||||
eemax<Int32>( 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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<Rectf> rects = text.getSelectionRects( 0, 4 ); // "Line"
|
||||
std::vector<Rectf> 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<Rectf> rects = text.getSelectionRects( 2, 9 );
|
||||
std::vector<Rectf> 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<Rectf> rects = text.getSelectionRects( 0, txt.size() );
|
||||
std::vector<Rectf> rects =
|
||||
text.getSelectionRects( { 0, static_cast<Int64>( txt.size() ) } );
|
||||
EXPECT_EQ( 3ul, rects.size() );
|
||||
}
|
||||
|
||||
@@ -1250,7 +1251,8 @@ UTEST( FontRendering, TextSelection ) {
|
||||
|
||||
EXPECT_GT( text.getVisualLineCount(), (Uint32)1 );
|
||||
|
||||
std::vector<Rectf> rects = text.getSelectionRects( 0, text.getString().size() );
|
||||
std::vector<Rectf> rects =
|
||||
text.getSelectionRects( { 0, static_cast<Int64>( text.getString().size() ) } );
|
||||
EXPECT_EQ( (size_t)text.getVisualLineCount(), rects.size() );
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<UILinearLayout>();
|
||||
UITextView* tv = lay->findByType( UI_TYPE_TEXTVIEW )->asType<UITextView>();
|
||||
tv->setText( text );
|
||||
tv->setTextSelection( allowCopy );
|
||||
tv->setTextSelectionEnabled( allowCopy );
|
||||
tv->on( Event::MouseClick, [allowCopy, lay]( const Event* event ) {
|
||||
const MouseEvent* mouseEvent = static_cast<const MouseEvent*>( event );
|
||||
if ( mouseEvent->getFlags() &
|
||||
|
||||
@@ -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<std::string> 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 )
|
||||
|
||||
@@ -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<UITextView>();
|
||||
|
||||
Reference in New Issue
Block a user