19#include <AUI/Common/AString.h>
21#include <AUI/Font/AFontStyle.h>
22#include <AUI/Render/ATextLayoutHelper.h>
23#include <AUI/Render/RenderHints.h>
24#include <AUI/Platform/AInput.h>
25#include <AUI/View/AView.h>
37 bool operator==(
const Selection& rhs)
const noexcept =
default;
40 bool operator!=(
const Selection& rhs)
const noexcept =
default;
43 bool empty()
const noexcept {
61 [[nodiscard]]
virtual size_t length()
const = 0;
62 [[nodiscard]]
AString selectedText()
const
67 return {t.begin() + selection().begin, t.begin() + selection().end };
73 [[nodiscard]] Selection selection()
const;
78 [[nodiscard]]
bool hasSelection()
const;
85 [[nodiscard]]
virtual glm::ivec2 getPosByIndex(
size_t index) = 0;
104 void clearSelection();
106 void setSelection(
int cursorIndex) {
107 mCursorIndex = cursorIndex;
108 mCursorSelection.reset();
109 onSelectionChanged();
112 void setSelection(Selection selection) {
113 mCursorIndex = selection.begin;
114 mCursorSelection = selection.end;
115 onSelectionChanged();
119 unsigned mCursorIndex = 0;
122 virtual bool isLButtonPressed() = 0;
123 virtual AString getDisplayText() = 0;
124 virtual void cursorSelectableRedraw() = 0;
125 virtual void onSelectionChanged() = 0;
131 void handleMouseMove(
const glm::ivec2& pos);
133 template<aui::invocable Callback>
134 void drawSelectionBeforeAndAfter(
IRenderer& render, std::span<
ARect<int>> rects, Callback&& drawText) {
140 auto drawRects = [&] {
141 for (
auto r : rects) {
159 bool mIgnoreSelection =
false;
166 o <<
"{" << e.begin <<
"}";
168 o <<
"[" << e.begin <<
";" << e.end <<
")";
Represents a 4-component floating point color.
Definition: AColor.h:27
Definition: ACursorSelectable.h:27
virtual const AString & text() const =0
virtual size_t length() const =0
virtual unsigned cursorIndexByPos(glm::ivec2 pos)=0
virtual glm::ivec2 getCursorPosition()=0
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition: AOptional.h:32
Represents a Unicode character string.
Definition: AString.h:37
Base class for rendering.
Definition: IRenderer.h:149
void setColor(const AColor &color)
Definition: IRenderer.h:430
virtual void setBlending(Blending blending)=0
Sets blending mode.
virtual void rectangle(const ABrush &brush, glm::vec2 position, glm::vec2 size)=0
Draws simple rectangle.
#define AUI_DEFER
Defers execution of the next block to the end of current block (RAII scope).
Definition: kAUI.h:197
Definition: ACursorSelectable.h:32
Pointing method press event.
Definition: APointerPressedEvent.h:21
Pointing method press event.
Definition: APointerReleasedEvent.h:19
Axis aligned 2D rectangle.
Definition: ARect.h:24
Definition: RenderHints.h:79