aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/osx/graphics/quartz/TextLayout.hpp4
-rw-r--r--include/cru/platform/graphics/NullPainter.hpp53
-rw-r--r--include/cru/platform/graphics/TextLayout.hpp4
-rw-r--r--include/cru/platform/gui/Window.hpp4
-rw-r--r--include/cru/ui/render/TextRenderObject.hpp3
5 files changed, 66 insertions, 2 deletions
diff --git a/include/cru/osx/graphics/quartz/TextLayout.hpp b/include/cru/osx/graphics/quartz/TextLayout.hpp
index 80c257cc..2c6347db 100644
--- a/include/cru/osx/graphics/quartz/TextLayout.hpp
+++ b/include/cru/osx/graphics/quartz/TextLayout.hpp
@@ -31,6 +31,10 @@ class OsxCTTextLayout : public OsxQuartzResource, public virtual ITextLayout {
bool IsEditMode() override;
void SetEditMode(bool enable) override;
+ Index GetLineIndexFromCharIndex(Index char_index) override;
+ Index GetLineCount() override;
+ float GetLineHeight(Index line_index) override;
+
Rect GetTextBounds(bool includingTrailingSpace = false) override;
std::vector<Rect> TextRangeRect(const TextRange& text_range) override;
Rect TextSinglePoint(Index position, bool trailing) override;
diff --git a/include/cru/platform/graphics/NullPainter.hpp b/include/cru/platform/graphics/NullPainter.hpp
new file mode 100644
index 00000000..cf790ccf
--- /dev/null
+++ b/include/cru/platform/graphics/NullPainter.hpp
@@ -0,0 +1,53 @@
+#pragma once
+#include "Painter.hpp"
+
+namespace cru::platform::graphics {
+class NullPainter : public Object, public virtual IPainter {
+ public:
+ NullPainter() = default;
+
+ CRU_DELETE_COPY(NullPainter)
+ CRU_DELETE_MOVE(NullPainter)
+
+ ~NullPainter() override = default;
+
+ public:
+ String GetPlatformId() const override { return u"NULL"; }
+
+ String GetDebugString() override { return u"NullPainter"; }
+
+ Matrix GetTransform() override { return Matrix(); }
+ void SetTransform(const Matrix& matrix) override {}
+
+ void ConcatTransform(const Matrix& matrix) override {}
+
+ void Clear(const Color& color) override {}
+
+ void DrawLine(const Point& start, const Point& end, IBrush* brush,
+ float width) override{};
+ void StrokeRectangle(const Rect& rectangle, IBrush* brush,
+ float width) override {}
+ void FillRectangle(const Rect& rectangle, IBrush* brush) override {}
+ void StrokeEllipse(const Rect& outline_rect, IBrush* brush,
+ float width) override {}
+ void FillEllipse(const Rect& outline_rect, IBrush* brush,
+ float width) override {}
+
+ void StrokeGeometry(IGeometry* geometry, IBrush* brush,
+ float width) override {}
+ void FillGeometry(IGeometry* geometry, IBrush* brush) override {}
+
+ void DrawText(const Point& offset, ITextLayout* text_layout,
+ IBrush* brush) override {}
+
+ void PushLayer(const Rect& bounds) override{};
+
+ void PopLayer() override {}
+
+ void PushState() override {}
+
+ void PopState() override {}
+
+ void EndDraw() override {}
+};
+} // namespace cru::platform::graphics
diff --git a/include/cru/platform/graphics/TextLayout.hpp b/include/cru/platform/graphics/TextLayout.hpp
index d10c9f22..a040ec3b 100644
--- a/include/cru/platform/graphics/TextLayout.hpp
+++ b/include/cru/platform/graphics/TextLayout.hpp
@@ -20,6 +20,10 @@ struct ITextLayout : virtual IGraphicsResource {
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.
diff --git a/include/cru/platform/gui/Window.hpp b/include/cru/platform/gui/Window.hpp
index f6e1d650..bab5e8fe 100644
--- a/include/cru/platform/gui/Window.hpp
+++ b/include/cru/platform/gui/Window.hpp
@@ -18,9 +18,9 @@ struct WindowStyleFlags {
static constexpr WindowStyleFlag NoCaptionAndBorder{0b1};
};
-enum class WindowVisibilityType { Show, Hide };
+enum class WindowVisibilityType { Show, Hide, Minimize };
-enum class FocusChangeType { Gain, Lost };
+enum class FocusChangeType { Gain, Lose };
enum class MouseEnterLeaveType { Enter, Leave };
diff --git a/include/cru/ui/render/TextRenderObject.hpp b/include/cru/ui/render/TextRenderObject.hpp
index d6395f85..4e72e839 100644
--- a/include/cru/ui/render/TextRenderObject.hpp
+++ b/include/cru/ui/render/TextRenderObject.hpp
@@ -45,6 +45,9 @@ class TextRenderObject : public RenderObject {
bool IsEditMode();
void SetEditMode(bool enable);
+ Index GetLineCount();
+ Index GetLineIndexFromCharIndex(Index char_index);
+ float GetLineHeight(Index line_index);
std::vector<Rect> TextRangeRect(const TextRange& text_range);
Rect TextSinglePoint(gsl::index position, bool trailing);
platform::graphics::TextHitTestResult TextHitTest(const Point& point);