diff options
author | crupest <crupest@outlook.com> | 2022-02-08 16:53:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-08 16:53:51 +0800 |
commit | 74bb9cd27242b9320f99ff4d2b50c3051576cc14 (patch) | |
tree | 744bac5799c593d1d6f81e7b09581bea626f2cde /include/cru/platform/graphics/TextLayout.h | |
parent | b90c398de829d1ba5329651d75bae82f5e4085fe (diff) | |
download | cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.gz cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.tar.bz2 cru-74bb9cd27242b9320f99ff4d2b50c3051576cc14.zip |
...
Diffstat (limited to 'include/cru/platform/graphics/TextLayout.h')
-rw-r--r-- | include/cru/platform/graphics/TextLayout.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/cru/platform/graphics/TextLayout.h b/include/cru/platform/graphics/TextLayout.h new file mode 100644 index 00000000..e060186b --- /dev/null +++ b/include/cru/platform/graphics/TextLayout.h @@ -0,0 +1,33 @@ +#pragma once +#include "Resource.h" + +#include <string> +#include <vector> + +namespace cru::platform::graphics { +// Requirement: +// All text must be left-top aligned. +struct CRU_PLATFORM_GRAPHICS_API ITextLayout : virtual IGraphicsResource { + virtual String GetText() = 0; + virtual void SetText(String new_text) = 0; + + virtual std::shared_ptr<IFont> GetFont() = 0; + virtual void SetFont(std::shared_ptr<IFont> font) = 0; + + virtual void SetMaxWidth(float max_width) = 0; + virtual void SetMaxHeight(float max_height) = 0; + + virtual bool IsEditMode() = 0; + virtual void SetEditMode(bool enable) = 0; + + virtual Index GetLineIndexFromCharIndex(Index char_index) = 0; + virtual Index GetLineCount() = 0; + virtual float GetLineHeight(Index line_index) = 0; + + virtual Rect GetTextBounds(bool includingTrailingSpace = false) = 0; + virtual std::vector<Rect> TextRangeRect(const TextRange& text_range) = 0; + // Width is always 0, height is line height. + virtual Rect TextSinglePoint(Index position, bool trailing) = 0; + virtual TextHitTestResult HitTest(const Point& point) = 0; +}; +} // namespace cru::platform::graphics |