diff options
| author | crupest <crupest@outlook.com> | 2020-10-30 00:07:57 +0800 |
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2020-10-30 00:07:57 +0800 |
| commit | 6aa2201797a9ed64ce0178215ae941d0c5f09579 (patch) | |
| tree | 9a74ee8d9f616afbe693ef7825a71474850831b5 /include/cru/platform/graph | |
| parent | b4cb4fb7552d35c267bdb66913e4c822f16346ab (diff) | |
| download | cru-6aa2201797a9ed64ce0178215ae941d0c5f09579.tar.gz cru-6aa2201797a9ed64ce0178215ae941d0c5f09579.tar.bz2 cru-6aa2201797a9ed64ce0178215ae941d0c5f09579.zip | |
...
Diffstat (limited to 'include/cru/platform/graph')
| -rw-r--r-- | include/cru/platform/graph/Base.hpp | 24 | ||||
| -rw-r--r-- | include/cru/platform/graph/Brush.hpp | 11 | ||||
| -rw-r--r-- | include/cru/platform/graph/Factory.hpp | 25 | ||||
| -rw-r--r-- | include/cru/platform/graph/Font.hpp | 8 | ||||
| -rw-r--r-- | include/cru/platform/graph/Geometry.hpp | 20 | ||||
| -rw-r--r-- | include/cru/platform/graph/Painter.hpp | 29 | ||||
| -rw-r--r-- | include/cru/platform/graph/Resource.hpp | 10 | ||||
| -rw-r--r-- | include/cru/platform/graph/TextLayout.hpp | 24 | ||||
| -rw-r--r-- | include/cru/platform/graph/util/Painter.hpp | 17 |
9 files changed, 0 insertions, 168 deletions
diff --git a/include/cru/platform/graph/Base.hpp b/include/cru/platform/graph/Base.hpp deleted file mode 100644 index 61cfc5ef..00000000 --- a/include/cru/platform/graph/Base.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "../GraphBase.hpp" -#include "../Matrix.hpp" -#include "../Resource.hpp" - -#include <memory> - -namespace cru::platform::graph { -// forward declarations -struct IGraphFactory; -struct IBrush; -struct ISolidColorBrush; -struct IFont; -struct IGeometry; -struct IGeometryBuilder; -struct IPainter; -struct ITextLayout; - -struct TextHitTestResult { - int position; - bool trailing; - bool insideText; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/Brush.hpp b/include/cru/platform/graph/Brush.hpp deleted file mode 100644 index e67384de..00000000 --- a/include/cru/platform/graph/Brush.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "Resource.hpp" - -namespace cru::platform::graph { -struct IBrush : virtual IGraphResource {}; - -struct ISolidColorBrush : virtual IBrush { - virtual Color GetColor() = 0; - virtual void SetColor(const Color& color) = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/Factory.hpp b/include/cru/platform/graph/Factory.hpp deleted file mode 100644 index b4e68f12..00000000 --- a/include/cru/platform/graph/Factory.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "Resource.hpp" - -#include "Brush.hpp" -#include "Font.hpp" -#include "Geometry.hpp" -#include "TextLayout.hpp" - -#include <string> -#include <string_view> - -namespace cru::platform::graph { -// Entry point of the graph module. -struct IGraphFactory : virtual INativeResource { - virtual std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush() = 0; - - virtual std::unique_ptr<IGeometryBuilder> CreateGeometryBuilder() = 0; - - virtual std::unique_ptr<IFont> CreateFont(std::u16string font_family, - float font_size) = 0; - - virtual std::unique_ptr<ITextLayout> CreateTextLayout( - std::shared_ptr<IFont> font, std::u16string text) = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/Font.hpp b/include/cru/platform/graph/Font.hpp deleted file mode 100644 index 182cc15b..00000000 --- a/include/cru/platform/graph/Font.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "Resource.hpp" - -namespace cru::platform::graph { -struct IFont : virtual IGraphResource { - virtual float GetFontSize() = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/Geometry.hpp b/include/cru/platform/graph/Geometry.hpp deleted file mode 100644 index 354efd97..00000000 --- a/include/cru/platform/graph/Geometry.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "Resource.hpp" - -namespace cru::platform::graph { -struct IGeometry : virtual IGraphResource { - virtual bool FillContains(const Point& point) = 0; -}; - -// After called Build, calling every method will throw a - -struct IGeometryBuilder : virtual IGraphResource { - virtual void BeginFigure(const Point& point) = 0; - virtual void LineTo(const Point& point) = 0; - virtual void QuadraticBezierTo(const Point& control_point, - const Point& end_point) = 0; - virtual void CloseFigure(bool close) = 0; - - virtual std::unique_ptr<IGeometry> Build() = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/Painter.hpp b/include/cru/platform/graph/Painter.hpp deleted file mode 100644 index 27ae420b..00000000 --- a/include/cru/platform/graph/Painter.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "Resource.hpp" - -namespace cru::platform::graph { - -struct IPainter : virtual INativeResource { - virtual Matrix GetTransform() = 0; - virtual void SetTransform(const Matrix& matrix) = 0; - - virtual void Clear(const Color& color) = 0; - - virtual void StrokeRectangle(const Rect& rectangle, IBrush* brush, - float width) = 0; - virtual void FillRectangle(const Rect& rectangle, IBrush* brush) = 0; - - virtual void StrokeGeometry(IGeometry* geometry, IBrush* brush, - float width) = 0; - virtual void FillGeometry(IGeometry* geometry, IBrush* brush) = 0; - - virtual void DrawText(const Point& offset, ITextLayout* text_layout, - IBrush* brush) = 0; - - virtual void PushLayer(const Rect& bounds) = 0; - - virtual void PopLayer() = 0; - - virtual void EndDraw() = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/Resource.hpp b/include/cru/platform/graph/Resource.hpp deleted file mode 100644 index 8859360c..00000000 --- a/include/cru/platform/graph/Resource.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "Base.hpp" - -namespace cru::platform::graph { -struct IGraphFactory; - -struct IGraphResource : virtual INativeResource { - virtual IGraphFactory* GetGraphFactory() = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/TextLayout.hpp b/include/cru/platform/graph/TextLayout.hpp deleted file mode 100644 index a101983f..00000000 --- a/include/cru/platform/graph/TextLayout.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "Resource.hpp" - -#include <string> -#include <vector> - -namespace cru::platform::graph { -struct ITextLayout : virtual IGraphResource { - virtual std::u16string GetText() = 0; - virtual std::u16string_view GetTextView() = 0; - virtual void SetText(std::u16string 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 Rect GetTextBounds() = 0; - virtual std::vector<Rect> TextRangeRect(const TextRange& text_range) = 0; - virtual Point TextSinglePoint(Index position, bool trailing) = 0; - virtual TextHitTestResult HitTest(const Point& point) = 0; -}; -} // namespace cru::platform::graph diff --git a/include/cru/platform/graph/util/Painter.hpp b/include/cru/platform/graph/util/Painter.hpp deleted file mode 100644 index f9aec027..00000000 --- a/include/cru/platform/graph/util/Painter.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "../Painter.hpp" - -#include <functional> -#include <type_traits> - -namespace cru::platform::graph::util { -template <typename Fn> -void WithTransform(IPainter* painter, const Matrix& matrix, const Fn& action) { - static_assert(std::is_invocable_v<decltype(action), IPainter*>, - "Action must can be be invoked with painter."); - const auto old = painter->GetTransform(); - painter->SetTransform(old * matrix); - action(painter); - painter->SetTransform(old); -} -} // namespace cru::platform::graph::util |
