aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/graphics/quartz/Brush.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-05-15 14:08:06 +0800
committercrupest <crupest@outlook.com>2022-05-15 14:08:06 +0800
commit8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6 (patch)
tree77e41cc14264060517c0f7ed95837012afb8342e /include/cru/platform/graphics/quartz/Brush.h
parent9e0c9d3499bc50c3534b4dc500d8b5d0b5f22752 (diff)
downloadcru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.gz
cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.tar.bz2
cru-8ad2966933957ac5d6ff8dcd5e732736fd5e4dc6.zip
...
Diffstat (limited to 'include/cru/platform/graphics/quartz/Brush.h')
-rw-r--r--include/cru/platform/graphics/quartz/Brush.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/cru/platform/graphics/quartz/Brush.h b/include/cru/platform/graphics/quartz/Brush.h
new file mode 100644
index 00000000..f3579771
--- /dev/null
+++ b/include/cru/platform/graphics/quartz/Brush.h
@@ -0,0 +1,47 @@
+#pragma once
+#include "Resource.h"
+#include "cru/common/Base.h"
+#include "cru/platform/graphics/Base.h"
+#include "cru/platform/graphics/Brush.h"
+
+#include <CoreGraphics/CoreGraphics.h>
+
+#include <functional>
+
+namespace cru::platform::graphics::quartz {
+class QuartzBrush : public OsxQuartzResource, public virtual IBrush {
+ public:
+ QuartzBrush(IGraphicsFactory* graphics_factory)
+ : OsxQuartzResource(graphics_factory) {}
+ CRU_DELETE_COPY(QuartzBrush)
+ CRU_DELETE_MOVE(QuartzBrush)
+ ~QuartzBrush() override = default;
+
+ public:
+ virtual void Select(CGContextRef context) = 0;
+};
+
+class QuartzSolidColorBrush : public QuartzBrush,
+ public virtual ISolidColorBrush {
+ public:
+ QuartzSolidColorBrush(IGraphicsFactory* graphics_factory, const Color& color);
+
+ CRU_DELETE_COPY(QuartzSolidColorBrush)
+ CRU_DELETE_MOVE(QuartzSolidColorBrush)
+
+ ~QuartzSolidColorBrush() override;
+
+ Color GetColor() override { return color_; }
+ void SetColor(const Color& color) override;
+
+ CGColorRef GetCGColorRef() const { return cg_color_; }
+
+ void Select(CGContextRef context) override;
+
+ String GetDebugString() override;
+
+ private:
+ Color color_;
+ CGColorRef cg_color_;
+};
+} // namespace cru::platform::graphics::quartz