mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Redesigning UITextInput and all the derivatives to use TextDocument.
This commit is contained in:
@@ -238,13 +238,16 @@ class EE_API String {
|
||||
/** Converts from any basic type to std::string */
|
||||
template <class T> static std::string toStr( const T& i ) {
|
||||
std::ostringstream ss;
|
||||
ss << i;
|
||||
ss << std::fixed << i;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static std::string fromFloat( const Float& value, const std::string& append = "",
|
||||
const std::string& prepend = "" );
|
||||
|
||||
static std::string fromDouble( const double& value, const std::string& append = "",
|
||||
const std::string& prepend = "" );
|
||||
|
||||
/** Converts from a string to type */
|
||||
template <class T>
|
||||
static bool fromString( T& t, const std::string& s,
|
||||
|
||||
@@ -91,6 +91,9 @@ class EE_API Text {
|
||||
/** @return The cached text height */
|
||||
Float getTextHeight();
|
||||
|
||||
/** @return The line espacing */
|
||||
Float getLineSpacing();
|
||||
|
||||
/** Draw the cached text on screen */
|
||||
void draw( const Float& X, const Float& Y, const Vector2f& Scale = Vector2f::One,
|
||||
const Float& Rotation = 0, BlendMode Effect = BlendAlpha,
|
||||
|
||||
@@ -133,7 +133,6 @@ enum class PropertyId : Uint32 {
|
||||
AllowEditing = String::hash( "allow-editing" ),
|
||||
Locked = String::hash( "locked" ),
|
||||
MaxLength = String::hash( "max-length" ),
|
||||
FreeEditing = String::hash( "free-editing" ),
|
||||
Numeric = String::hash( "numeric" ),
|
||||
AllowFloat = String::hash( "allow-float" ),
|
||||
TouchDrag = String::hash( "touch-drag" ),
|
||||
|
||||
@@ -25,8 +25,6 @@ class EE_API UIComboBox : public UIWidget {
|
||||
|
||||
UINode* getButton() const { return mButton; }
|
||||
|
||||
InputTextBuffer* getInputTextBuffer();
|
||||
|
||||
const String& getText();
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
@@ -24,25 +24,25 @@ class EE_API UISpinBox : public UIWidget {
|
||||
|
||||
const Rectf& getPadding() const;
|
||||
|
||||
virtual void setClickStep( const Float& step );
|
||||
virtual void setClickStep( const double& step );
|
||||
|
||||
const Float& getClickStep() const;
|
||||
const double& getClickStep() const;
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
void addValue( const Float& value );
|
||||
void addValue( const double& value );
|
||||
|
||||
virtual UISpinBox* setMinValue( const Float& MinVal );
|
||||
virtual UISpinBox* setMinValue( const double& minVal );
|
||||
|
||||
const Float& getMinValue() const;
|
||||
const double& getMinValue() const;
|
||||
|
||||
virtual UISpinBox* setMaxValue( const Float& MaxVal );
|
||||
virtual UISpinBox* setMaxValue( const double& maxVal );
|
||||
|
||||
const Float& getMaxValue() const;
|
||||
const double& getMaxValue() const;
|
||||
|
||||
virtual UISpinBox* setValue( const Float& Val );
|
||||
virtual UISpinBox* setValue( const double& val );
|
||||
|
||||
const Float& getValue() const;
|
||||
const double& getValue() const;
|
||||
|
||||
UINode* getButtonPushUp() const;
|
||||
|
||||
@@ -50,7 +50,7 @@ class EE_API UISpinBox : public UIWidget {
|
||||
|
||||
UITextInput* getTextInput() const;
|
||||
|
||||
UISpinBox* setAllowOnlyNumbers( bool allow );
|
||||
UISpinBox* allowFloatingPoint( bool allow );
|
||||
|
||||
bool dotsInNumbersAllowed();
|
||||
|
||||
@@ -63,15 +63,13 @@ class EE_API UISpinBox : public UIWidget {
|
||||
UITextInput* mInput;
|
||||
UIWidget* mPushUp;
|
||||
UIWidget* mPushDown;
|
||||
Float mMinValue;
|
||||
Float mMaxValue;
|
||||
Float mValue;
|
||||
Float mClickStep;
|
||||
double mMinValue;
|
||||
double mMaxValue;
|
||||
double mValue;
|
||||
double mClickStep;
|
||||
|
||||
void adjustChilds();
|
||||
|
||||
void internalValue( const Float& Val, const bool& Force = false );
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
virtual void onPositionChange();
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#ifndef EE_UICUITEXTINPUT_H
|
||||
#define EE_UICUITEXTINPUT_H
|
||||
|
||||
#include <eepp/ui/doc/textdocument.hpp>
|
||||
#include <eepp/ui/keyboardshortcut.hpp>
|
||||
#include <eepp/ui/uinode.hpp>
|
||||
#include <eepp/ui/uitextview.hpp>
|
||||
#include <eepp/window/inputtextbuffer.hpp>
|
||||
|
||||
using namespace EE::UI::Doc;
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class EE_API UITextInput : public UITextView {
|
||||
class EE_API UITextInput : public UITextView, public TextDocument::Client {
|
||||
public:
|
||||
static UITextInput* New();
|
||||
|
||||
@@ -27,12 +31,8 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
virtual void draw();
|
||||
|
||||
void pushIgnoredChar( const Uint32& ch );
|
||||
|
||||
virtual void setTheme( UITheme* Theme );
|
||||
|
||||
InputTextBuffer* getInputTextBuffer();
|
||||
|
||||
UITextInput* setAllowEditing( const bool& allow );
|
||||
|
||||
const bool& isEditingAllowed() const;
|
||||
@@ -43,13 +43,9 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
virtual void shrinkText( const Uint32& MaxWidth );
|
||||
|
||||
UITextInput* setMaxLength( Uint32 maxLength );
|
||||
UITextInput* setMaxLength( const Uint32& maxLength );
|
||||
|
||||
Uint32 getMaxLength();
|
||||
|
||||
UITextInput* setFreeEditing( bool support );
|
||||
|
||||
bool isFreeEditingEnabled();
|
||||
const Uint32& getMaxLength();
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
@@ -90,8 +86,21 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
UITextView* setHintOutlineColor( const Color& outlineColor );
|
||||
|
||||
/** Block all the inserts, allow only numeric characters. */
|
||||
void setAllowOnlyNumbers( const bool& onlyNumbers, const bool& allowFloat = false );
|
||||
|
||||
/** @return If is only allowing numbers */
|
||||
bool onlyNumbersAllowed();
|
||||
|
||||
/** @return If is only allowing numbers, it allow floating point numbers? */
|
||||
bool floatingPointAllowed();
|
||||
|
||||
TextDocument& getDocument();
|
||||
|
||||
KeyBindings& getKeyBindings();
|
||||
|
||||
protected:
|
||||
InputTextBuffer mTextBuffer;
|
||||
TextDocument mDoc;
|
||||
Float mWaitCursorTime;
|
||||
Vector2f mCurPos;
|
||||
Text* mHintCache;
|
||||
@@ -99,6 +108,11 @@ class EE_API UITextInput : public UITextView {
|
||||
int mCursorPos;
|
||||
bool mAllowEditing;
|
||||
bool mShowingWait;
|
||||
bool mOnlyNumbers;
|
||||
bool mAllowFloat;
|
||||
Uint32 mMaxLength{0};
|
||||
KeyBindings mKeyBindings;
|
||||
|
||||
void resetWaitCursor();
|
||||
|
||||
virtual void alignFix();
|
||||
@@ -107,8 +121,6 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
void privOnPressEnter();
|
||||
|
||||
void autoPadding();
|
||||
|
||||
virtual Uint32 onMouseDown( const Vector2i& position, const Uint32& flags );
|
||||
@@ -145,11 +157,29 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
virtual Int32 selCurEnd();
|
||||
|
||||
void onCursorPositionChange();
|
||||
virtual void onDocumentTextChanged();
|
||||
|
||||
void onBufferChange();
|
||||
virtual void onDocumentCursorChange( const TextPosition& );
|
||||
|
||||
void onInputSelectionChange();
|
||||
virtual void onDocumentSelectionChange( const TextRange& );
|
||||
|
||||
virtual void onDocumentLineCountChange( const size_t& lastCount, const size_t& newCount );
|
||||
|
||||
virtual void onDocumentLineChanged( const Int64& lineIndex );
|
||||
|
||||
void registerKeybindings();
|
||||
|
||||
void registerCommands();
|
||||
|
||||
void copy();
|
||||
|
||||
void cut();
|
||||
|
||||
void paste();
|
||||
|
||||
virtual Uint32 onKeyDown( const KeyEvent& event );
|
||||
|
||||
virtual Uint32 onTextInput( const TextInputEvent& event );
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
Reference in New Issue
Block a user