mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
cleanup element classes
This commit is contained in:
parent
660bd0a5d3
commit
8c5a549773
11 changed files with 141 additions and 141 deletions
|
|
@ -8,7 +8,7 @@ class ActionsHistory;
|
|||
|
||||
namespace gui {
|
||||
class TextBoxHistorian;
|
||||
class TextBox : public Container {
|
||||
class TextBox final : public Container {
|
||||
const Input& inputEvents;
|
||||
LabelCache rawTextCache;
|
||||
std::shared_ptr<ActionsHistory> history;
|
||||
|
|
@ -100,124 +100,124 @@ namespace gui {
|
|||
glm::vec4 padding=glm::vec4(4.0f)
|
||||
);
|
||||
|
||||
virtual ~TextBox();
|
||||
~TextBox();
|
||||
|
||||
void paste(const std::wstring& text, bool history=true);
|
||||
void erase(size_t start, size_t length);
|
||||
void resetSelection();
|
||||
|
||||
virtual void setTextSupplier(wstringsupplier supplier);
|
||||
void setTextSupplier(wstringsupplier supplier);
|
||||
|
||||
/// @brief Consumer called on stop editing text (textbox defocus)
|
||||
/// @param consumer std::wstring consumer function
|
||||
virtual void setTextConsumer(wstringconsumer consumer);
|
||||
void setTextConsumer(wstringconsumer consumer);
|
||||
|
||||
/// @brief Sub-consumer called while editing text
|
||||
/// @param consumer std::wstring consumer function
|
||||
virtual void setTextSubConsumer(wstringconsumer consumer);
|
||||
void setTextSubConsumer(wstringconsumer consumer);
|
||||
|
||||
/// @brief Text validator called while text editing and returns true if
|
||||
/// text is valid
|
||||
/// @param validator std::wstring consumer returning boolean
|
||||
virtual void setTextValidator(wstringchecker validator);
|
||||
void setTextValidator(wstringchecker validator);
|
||||
|
||||
virtual void setOnControlCombination(key_handler handler);
|
||||
void setOnControlCombination(key_handler handler);
|
||||
|
||||
virtual void setFocusedColor(glm::vec4 color);
|
||||
virtual glm::vec4 getFocusedColor() const;
|
||||
void setFocusedColor(glm::vec4 color);
|
||||
const glm::vec4& getFocusedColor() const;
|
||||
|
||||
virtual void setTextColor(glm::vec4 color);
|
||||
virtual glm::vec4 getTextColor() const;
|
||||
void setTextColor(glm::vec4 color);
|
||||
const glm::vec4& getTextColor() const;
|
||||
|
||||
/// @brief Set color of textbox marked by validator as invalid
|
||||
virtual void setErrorColor(glm::vec4 color);
|
||||
void setErrorColor(glm::vec4 color);
|
||||
|
||||
/// @brief Get color of textbox marked by validator as invalid
|
||||
virtual glm::vec4 getErrorColor() const;
|
||||
glm::vec4 getErrorColor() const;
|
||||
|
||||
/// @brief Get TextBox content text or placeholder if empty
|
||||
virtual const std::wstring& getText() const;
|
||||
const std::wstring& getText() const;
|
||||
|
||||
/// @brief Set TextBox content text
|
||||
virtual void setText(const std::wstring &value);
|
||||
void setText(const std::wstring &value);
|
||||
|
||||
/// @brief Get text placeholder
|
||||
virtual const std::wstring& getPlaceholder() const;
|
||||
const std::wstring& getPlaceholder() const;
|
||||
|
||||
/// @brief Set text placeholder
|
||||
/// @param text will be used instead of empty
|
||||
virtual void setPlaceholder(const std::wstring& text);
|
||||
void setPlaceholder(const std::wstring& text);
|
||||
|
||||
/// @brief Get textbox hint
|
||||
virtual const std::wstring& getHint() const;
|
||||
const std::wstring& getHint() const;
|
||||
|
||||
/// @brief Set textbox hint
|
||||
/// @param text will be shown instead of empty
|
||||
virtual void setHint(const std::wstring& text);
|
||||
void setHint(const std::wstring& text);
|
||||
|
||||
/// @brief Get selected text
|
||||
virtual std::wstring getSelection() const;
|
||||
std::wstring getSelection() const;
|
||||
|
||||
/// @brief Get current caret position in text
|
||||
/// @return integer in range [0, text.length()]
|
||||
virtual size_t getCaret() const;
|
||||
size_t getCaret() const;
|
||||
|
||||
/// @brief Set caret position in the text
|
||||
/// @param position integer in range [0, text.length()]
|
||||
virtual void setCaret(size_t position);
|
||||
void setCaret(size_t position);
|
||||
|
||||
/// @brief Set caret position in the text
|
||||
/// @param position integer in range [-text.length(), text.length()]
|
||||
virtual void setCaret(ptrdiff_t position);
|
||||
void setCaret(ptrdiff_t position);
|
||||
|
||||
/// @brief Select part of the text
|
||||
/// @param start index of the first selected character
|
||||
/// @param end index of the last selected character + 1
|
||||
virtual void select(int start, int end);
|
||||
void select(int start, int end);
|
||||
|
||||
/// @brief Get number of line at specific position in text
|
||||
/// @param position target position
|
||||
/// @return line number
|
||||
virtual uint getLineAt(size_t position) const;
|
||||
uint getLineAt(size_t position) const;
|
||||
|
||||
/// @brief Get specific line text position
|
||||
/// @param line target line
|
||||
/// @return line position in text
|
||||
virtual size_t getLinePos(uint line) const;
|
||||
size_t getLinePos(uint line) const;
|
||||
|
||||
int calcIndexAt(int x, int y) const;
|
||||
int getLineYOffset(int line) const;
|
||||
|
||||
/// @brief Check text with validator set with setTextValidator
|
||||
/// @return true if text is valid
|
||||
virtual bool validate();
|
||||
bool validate();
|
||||
|
||||
virtual void setValid(bool valid);
|
||||
virtual bool isValid() const;
|
||||
void setValid(bool valid);
|
||||
bool isValid() const;
|
||||
|
||||
/// @brief Enable/disable multiline mode
|
||||
virtual void setMultiline(bool multiline);
|
||||
void setMultiline(bool multiline);
|
||||
|
||||
/// @brief Check if multiline mode is enabled
|
||||
virtual bool isMultiline() const;
|
||||
bool isMultiline() const;
|
||||
|
||||
/// @brief Enable/disable text wrapping
|
||||
virtual void setTextWrapping(bool flag);
|
||||
void setTextWrapping(bool flag);
|
||||
|
||||
/// @brief Check if text wrapping is enabled
|
||||
virtual bool isTextWrapping() const;
|
||||
bool isTextWrapping() const;
|
||||
|
||||
/// @brief Enable/disable text editing feature
|
||||
virtual void setEditable(bool editable);
|
||||
void setEditable(bool editable);
|
||||
|
||||
/// @brief Check if text editing feature is enabled
|
||||
virtual bool isEditable() const;
|
||||
bool isEditable() const;
|
||||
|
||||
virtual bool isEdited() const;
|
||||
virtual void setUnedited();
|
||||
bool isEdited() const;
|
||||
void setUnedited();
|
||||
|
||||
virtual void setPadding(glm::vec4 padding);
|
||||
glm::vec4 getPadding() const;
|
||||
void setPadding(glm::vec4 padding);
|
||||
const glm::vec4& getPadding() const;
|
||||
|
||||
size_t getSelectionStart() const;
|
||||
size_t getSelectionEnd() const;
|
||||
|
|
@ -226,34 +226,34 @@ namespace gui {
|
|||
bool isKeepLineSelection() const;
|
||||
|
||||
/// @brief Set runnable called on textbox focus
|
||||
virtual void setOnEditStart(runnable oneditstart);
|
||||
void setOnEditStart(runnable oneditstart);
|
||||
|
||||
virtual void setAutoResize(bool flag);
|
||||
virtual bool isAutoResize() const;
|
||||
void setAutoResize(bool flag);
|
||||
bool isAutoResize() const;
|
||||
|
||||
virtual void setShowLineNumbers(bool flag);
|
||||
virtual bool isShowLineNumbers() const;
|
||||
void setShowLineNumbers(bool flag);
|
||||
bool isShowLineNumbers() const;
|
||||
|
||||
virtual void reposition() override;
|
||||
virtual void onFocus() override;
|
||||
virtual void refresh() override;
|
||||
virtual void doubleClick(int x, int y) override;
|
||||
virtual void click(int, int) override;
|
||||
virtual void mouseMove(int x, int y) override;
|
||||
virtual bool isFocuskeeper() const override {return true;}
|
||||
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
|
||||
virtual void drawBackground(const DrawContext& pctx, const Assets& assets) override;
|
||||
virtual void typed(unsigned int codepoint) override;
|
||||
virtual void keyPressed(Keycode key) override;
|
||||
virtual std::shared_ptr<UINode> getAt(const glm::vec2& pos) override;
|
||||
virtual void setOnUpPressed(const runnable &callback);
|
||||
virtual void setOnDownPressed(const runnable &callback);
|
||||
void reposition() override;
|
||||
void onFocus() override;
|
||||
void refresh() override;
|
||||
void doubleClick(int x, int y) override;
|
||||
void click(int, int) override;
|
||||
void mouseMove(int x, int y) override;
|
||||
bool isFocuskeeper() const override {return true;}
|
||||
void draw(const DrawContext& pctx, const Assets& assets) override;
|
||||
void drawBackground(const DrawContext& pctx, const Assets& assets) override;
|
||||
void typed(unsigned int codepoint) override;
|
||||
void keyPressed(Keycode key) override;
|
||||
std::shared_ptr<UINode> getAt(const glm::vec2& pos) override;
|
||||
void setOnUpPressed(const runnable& callback);
|
||||
void setOnDownPressed(const runnable& callback);
|
||||
|
||||
virtual void setSyntax(std::string_view lang);
|
||||
virtual const std::string& getSyntax() const;
|
||||
void setSyntax(std::string_view lang);
|
||||
const std::string& getSyntax() const;
|
||||
|
||||
virtual void setMarkup(std::string_view lang);
|
||||
virtual const std::string& getMarkup() const;
|
||||
void setMarkup(std::string_view lang);
|
||||
const std::string& getMarkup() const;
|
||||
|
||||
std::shared_ptr<Label> getLabel() const;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue