diff options
author | crupest <crupest@outlook.com> | 2022-02-27 20:26:17 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-27 20:26:17 +0800 |
commit | c0817f5494e6a08c0db9e22a7195daedd1a6b4c3 (patch) | |
tree | fe353c2369643c58fd93dca22c6bd4cdf556e75d /src | |
parent | afcf935a739c60d9141e2d53fb62e30ff4fc1f80 (diff) | |
download | cru-c0817f5494e6a08c0db9e22a7195daedd1a6b4c3.tar.gz cru-c0817f5494e6a08c0db9e22a7195daedd1a6b4c3.tar.bz2 cru-c0817f5494e6a08c0db9e22a7195daedd1a6b4c3.zip |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/osx/graphics/quartz/Geometry.cpp | 27 | ||||
-rw-r--r-- | src/ui/render/BorderRenderObject.cpp | 2 | ||||
-rw-r--r-- | src/ui/render/ScrollBar.cpp | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/src/osx/graphics/quartz/Geometry.cpp b/src/osx/graphics/quartz/Geometry.cpp index 284f5c4d..37e4645b 100644 --- a/src/osx/graphics/quartz/Geometry.cpp +++ b/src/osx/graphics/quartz/Geometry.cpp @@ -1,4 +1,5 @@ #include "cru/osx/graphics/quartz/Geometry.h" +#include "cru/osx/graphics/quartz/Convert.h" #include <memory> @@ -23,24 +24,42 @@ QuartzGeometryBuilder::~QuartzGeometryBuilder() { CGPathRelease(cg_mutable_path_); } -void QuartzGeometryBuilder::BeginFigure(const Point &point) { - CGPathMoveToPoint(cg_mutable_path_, nullptr, point.x, point.y); +Point QuartzGeometryBuilder::GetCurrentPosition() { + return Convert(CGPathGetCurrentPoint(cg_mutable_path_)); } -void QuartzGeometryBuilder::CloseFigure(bool close) { - if (close) CGPathCloseSubpath(cg_mutable_path_); +void QuartzGeometryBuilder::MoveTo(const Point &point) { + CGPathMoveToPoint(cg_mutable_path_, nullptr, point.x, point.y); } void QuartzGeometryBuilder::LineTo(const Point &point) { CGPathAddLineToPoint(cg_mutable_path_, nullptr, point.x, point.y); } +void QuartzGeometryBuilder::CubicBezierTo(const Point &start_control_point, + const Point &end_control_point, + const Point &end_point) { + CGPathAddCurveToPoint(cg_mutable_path_, nullptr, start_control_point.x, + start_control_point.y, end_control_point.x, + end_control_point.y, end_point.x, end_point.y); +} + void QuartzGeometryBuilder::QuadraticBezierTo(const Point &control_point, const Point &end_point) { CGPathAddQuadCurveToPoint(cg_mutable_path_, nullptr, control_point.x, control_point.y, end_point.x, end_point.y); } +void QuartzGeometryBuilder::ArcTo(const Point &radius, float angle, + bool is_large_arc, bool is_clockwise, + const Point &end_point) { + // TODO: Implement this! +} + +void QuartzGeometryBuilder::CloseFigure(bool close) { + if (close) CGPathCloseSubpath(cg_mutable_path_); +} + std::unique_ptr<IGeometry> QuartzGeometryBuilder::Build() { return std::make_unique<QuartzGeometry>(GetGraphicsFactory(), CGPathCreateCopy(cg_mutable_path_)); diff --git a/src/ui/render/BorderRenderObject.cpp b/src/ui/render/BorderRenderObject.cpp index abba47e9..40ab506a 100644 --- a/src/ui/render/BorderRenderObject.cpp +++ b/src/ui/render/BorderRenderObject.cpp @@ -184,7 +184,7 @@ void BorderRenderObject::RecreateGeometry() { auto f = [](platform::graphics::IGeometryBuilder* builder, const Rect& rect, const CornerRadius& corner) { - builder->BeginFigure(Point(rect.left + corner.left_top.x, rect.top)); + builder->MoveTo(Point(rect.left + corner.left_top.x, rect.top)); builder->LineTo(Point(rect.GetRight() - corner.right_top.x, rect.top)); builder->QuadraticBezierTo( Point(rect.GetRight(), rect.top), diff --git a/src/ui/render/ScrollBar.cpp b/src/ui/render/ScrollBar.cpp index 695caa03..710ca832 100644 --- a/src/ui/render/ScrollBar.cpp +++ b/src/ui/render/ScrollBar.cpp @@ -77,7 +77,7 @@ String GenerateScrollBarThemeColorKey(ScrollBarBrushUsageKind usage, namespace { std::unique_ptr<platform::graphics::IGeometry> CreateScrollBarArrowGeometry() { auto geometry_builder = GetGraphicsFactory()->CreateGeometryBuilder(); - geometry_builder->BeginFigure({-kScrollBarArrowHeight / 2, 0}); + geometry_builder->MoveTo({-kScrollBarArrowHeight / 2, 0}); geometry_builder->LineTo({kScrollBarArrowHeight / 2, kScrollBarArrowHeight}); geometry_builder->LineTo({kScrollBarArrowHeight / 2, -kScrollBarArrowHeight}); geometry_builder->CloseFigure(true); |