diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/common/Logger.hpp | 16 | ||||
-rw-r--r-- | include/cru/osx/graphics/quartz/Painter.hpp | 20 | ||||
-rw-r--r-- | include/cru/osx/graphics/quartz/TextLayout.hpp | 2 | ||||
-rw-r--r-- | include/cru/platform/Color.hpp | 5 |
4 files changed, 36 insertions, 7 deletions
diff --git a/include/cru/common/Logger.hpp b/include/cru/common/Logger.hpp index 3dabeb91..7d43fc5a 100644 --- a/include/cru/common/Logger.hpp +++ b/include/cru/common/Logger.hpp @@ -94,4 +94,20 @@ void TagError(StringView tag, TArgs&&... args) { Logger::GetInstance()->Log(LogLevel::Error, tag, Format(std::forward<TArgs>(args)...)); } + +class StdioLogSource : public Object, public virtual ILogSource { + public: + explicit StdioLogSource(bool use_lock = false); + + CRU_DELETE_COPY(StdioLogSource) + CRU_DELETE_MOVE(StdioLogSource) + + ~StdioLogSource() override; + + public: + void Write(LogLevel level, StringView s) override; + + private: + bool use_lock_; +}; } // namespace cru::log diff --git a/include/cru/osx/graphics/quartz/Painter.hpp b/include/cru/osx/graphics/quartz/Painter.hpp index 8d693d8b..ea64c3d5 100644 --- a/include/cru/osx/graphics/quartz/Painter.hpp +++ b/include/cru/osx/graphics/quartz/Painter.hpp @@ -6,17 +6,19 @@ #include <CoreGraphics/CoreGraphics.h> +#include <functional> + namespace cru::platform::graphics::osx::quartz { class QuartzCGContextPainter : public OsxQuartzResource, public virtual IPainter { + CRU_DEFINE_CLASS_LOG_TAG( + u"cru::platform::graphics::osx::quartz::QuartzCGContextPainter") + public: - explicit QuartzCGContextPainter(IGraphicsFactory* graphics_factory, - CGContextRef cg_context, bool auto_release, - const Size& size) - : OsxQuartzResource(graphics_factory), - cg_context_(cg_context), - auto_release_(auto_release), - size_(size) {} + explicit QuartzCGContextPainter( + IGraphicsFactory* graphics_factory, CGContextRef cg_context, + bool auto_release, const Size& size, + std::function<void(QuartzCGContextPainter*)> on_end_draw); CRU_DELETE_COPY(QuartzCGContextPainter) CRU_DELETE_MOVE(QuartzCGContextPainter) @@ -48,6 +50,8 @@ class QuartzCGContextPainter : public OsxQuartzResource, void EndDraw() override; private: + void DoEndDraw(); + void Validate(); private: @@ -56,5 +60,7 @@ class QuartzCGContextPainter : public OsxQuartzResource, bool auto_release_; Size size_; + + std::function<void(QuartzCGContextPainter*)> on_end_draw_; }; } // namespace cru::platform::graphics::osx::quartz diff --git a/include/cru/osx/graphics/quartz/TextLayout.hpp b/include/cru/osx/graphics/quartz/TextLayout.hpp index 4d23a76e..dd170142 100644 --- a/include/cru/osx/graphics/quartz/TextLayout.hpp +++ b/include/cru/osx/graphics/quartz/TextLayout.hpp @@ -33,6 +33,8 @@ class OsxCTTextLayout : public OsxQuartzResource, public virtual ITextLayout { Point TextSinglePoint(Index position, bool trailing) override; TextHitTestResult HitTest(const Point& point) override; + CTFrameRef GetCTFrameRef() const { return ct_frame_; } + private: void RecreateFrame(); diff --git a/include/cru/platform/Color.hpp b/include/cru/platform/Color.hpp index 3a72aa65..f60ab692 100644 --- a/include/cru/platform/Color.hpp +++ b/include/cru/platform/Color.hpp @@ -257,4 +257,9 @@ extern const std::unordered_map<StringView, Color> predefined_name_color_map; } // namespace details std::optional<Color> GetPredefinedColorByName(StringView name); + +inline String ToString(const Color& color) { + return cru::Format(u"rgba({}, {}, {}, {})", color.red, color.green, + color.blue, color.alpha); +} } // namespace cru::platform |