Merge branch 'master' into console-widget
This commit is contained in:
@@ -11,13 +11,17 @@
|
||||
#include <Nazara/Utility/SimpleTextDrawer.hpp>
|
||||
#include <NDK/BaseWidget.hpp>
|
||||
#include <NDK/Widgets/Enums.hpp>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
class NDK_API TextAreaWidget : public BaseWidget
|
||||
{
|
||||
public:
|
||||
TextAreaWidget(BaseWidget* parent = nullptr);
|
||||
using CharacterFilter = std::function<bool(char32_t)>;
|
||||
|
||||
TextAreaWidget(BaseWidget* parent);
|
||||
TextAreaWidget(const TextAreaWidget&) = delete;
|
||||
TextAreaWidget(TextAreaWidget&&) = default;
|
||||
~TextAreaWidget() = default;
|
||||
@@ -28,10 +32,18 @@ namespace Ndk
|
||||
|
||||
//virtual TextAreaWidget* Clone() const = 0;
|
||||
|
||||
inline void EnableMultiline(bool enable = true);
|
||||
|
||||
inline void EnableMultiline(bool enable = true);
|
||||
inline void EnableTabWriting(bool enable = true);
|
||||
|
||||
inline void Erase(std::size_t glyphPosition);
|
||||
void Erase(std::size_t firstGlyph, std::size_t lastGlyph);
|
||||
void EraseSelection();
|
||||
|
||||
inline const CharacterFilter& GetCharacterFilter() const;
|
||||
inline unsigned int GetCharacterSize() const;
|
||||
inline const Nz::Vector2ui& GetCursorPosition() const;
|
||||
inline Nz::Vector2ui GetCursorPosition(std::size_t glyphIndex) const;
|
||||
inline const Nz::String& GetDisplayText() const;
|
||||
inline EchoMode GetEchoMode() const;
|
||||
inline std::size_t GetGlyphIndex() const;
|
||||
@@ -39,25 +51,30 @@ namespace Ndk
|
||||
inline const Nz::String& GetText() const;
|
||||
inline const Nz::Color& GetTextColor() const;
|
||||
|
||||
std::size_t GetHoveredGlyph(float x, float y) const;
|
||||
Nz::Vector2ui GetHoveredGlyph(float x, float y) const;
|
||||
|
||||
inline bool HasSelection() const;
|
||||
|
||||
inline bool IsMultilineEnabled() const;
|
||||
inline bool IsReadOnly() const;
|
||||
inline bool IsTabWritingEnabled() const;
|
||||
|
||||
inline void MoveCursor(int offset);
|
||||
inline void MoveCursor(const Nz::Vector2i& offset);
|
||||
|
||||
void ResizeToContent() override;
|
||||
|
||||
inline void SetCharacterSize(unsigned int characterSize);
|
||||
inline void SetCharacterFilter(CharacterFilter filter);
|
||||
void SetCharacterSize(unsigned int characterSize);
|
||||
inline void SetCursorPosition(std::size_t glyphIndex);
|
||||
inline void SetCursorPosition(Nz::Vector2ui cursorPosition);
|
||||
inline void SetEchoMode(EchoMode echoMode);
|
||||
inline void SetReadOnly(bool readOnly = true);
|
||||
inline void SetSelection(Nz::Vector2ui fromPosition, Nz::Vector2ui toPosition);
|
||||
inline void SetText(const Nz::String& text);
|
||||
inline void SetTextColor(const Nz::Color& text);
|
||||
|
||||
void Write(const Nz::String& text);
|
||||
inline void Write(const Nz::String& text);
|
||||
inline void Write(const Nz::String& text, const Nz::Vector2ui& glyphPosition);
|
||||
void Write(const Nz::String& text, std::size_t glyphPosition);
|
||||
|
||||
TextAreaWidget& operator=(const TextAreaWidget&) = delete;
|
||||
TextAreaWidget& operator=(TextAreaWidget&&) = default;
|
||||
@@ -65,6 +82,8 @@ namespace Ndk
|
||||
NazaraSignal(OnTextAreaCursorMove, const TextAreaWidget* /*textArea*/, std::size_t* /*newCursorPosition*/);
|
||||
NazaraSignal(OnTextAreaKeyBackspace, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyDown, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyEnd, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyHome, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyLeft, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyReturn, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyRight, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
@@ -80,21 +99,29 @@ namespace Ndk
|
||||
bool OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override;
|
||||
void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) override;
|
||||
void OnMouseButtonPress(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
||||
void OnMouseButtonRelease(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
||||
void OnMouseEnter() override;
|
||||
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
|
||||
void OnTextEntered(char32_t character, bool repeated) override;
|
||||
|
||||
void RefreshCursor();
|
||||
void UpdateDisplayText();
|
||||
|
||||
CharacterFilter m_characterFilter;
|
||||
EchoMode m_echoMode;
|
||||
EntityHandle m_cursorEntity;
|
||||
EntityHandle m_textEntity;
|
||||
Nz::SimpleTextDrawer m_drawer;
|
||||
Nz::SpriteRef m_cursorSprite;
|
||||
Nz::String m_text;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
Nz::Vector2ui m_cursorPosition;
|
||||
Nz::Vector2ui m_cursorPositionBegin;
|
||||
Nz::Vector2ui m_cursorPositionEnd;
|
||||
Nz::Vector2ui m_selectionCursor;
|
||||
std::vector<Nz::SpriteRef> m_cursorSprites;
|
||||
bool m_isMouseButtonDown;
|
||||
bool m_multiLineEnabled;
|
||||
bool m_readOnly;
|
||||
bool m_tabEnabled; // writes (Shift+)Tab character if set to true
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user