aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-03-13 17:40:18 +0800
committercrupest <crupest@outlook.com>2021-03-13 17:40:18 +0800
commit7703063a5816b089483e78ccd74bb9902ccfbea8 (patch)
treeb4b0fd45eb6a89831921d6b78c322e6aa882c239 /include
parent49dfb2bc9f965b398aa12e711148696d28443eaf (diff)
downloadcru-7703063a5816b089483e78ccd74bb9902ccfbea8.tar.gz
cru-7703063a5816b089483e78ccd74bb9902ccfbea8.tar.bz2
cru-7703063a5816b089483e78ccd74bb9902ccfbea8.zip
...
Diffstat (limited to 'include')
-rw-r--r--include/cru/platform/Matrix.hpp5
-rw-r--r--include/cru/platform/graphics/Painter.hpp4
-rw-r--r--include/cru/platform/graphics/util/Painter.hpp2
-rw-r--r--include/cru/ui/render/ScrollBar.hpp3
-rw-r--r--include/cru/win/graphics/direct/Painter.hpp2
5 files changed, 14 insertions, 2 deletions
diff --git a/include/cru/platform/Matrix.hpp b/include/cru/platform/Matrix.hpp
index e702df90..8ec5faaa 100644
--- a/include/cru/platform/Matrix.hpp
+++ b/include/cru/platform/Matrix.hpp
@@ -50,10 +50,15 @@ struct Matrix {
return Matrix{1.0f, 0.0f, 0.0f, 1.0f, x, y};
}
+ static Matrix Translation(const Point& point) {
+ return Translation(point.x, point.y);
+ }
+
static Matrix Scale(float sx, float sy) {
return Matrix{sx, 0.0f, 0.0f, sy, 0.0f, 0.0f};
}
+ // Clockwise.
static Matrix Rotation(float angle) {
float r = AngleToRadian(angle);
float s = std::sin(r);
diff --git a/include/cru/platform/graphics/Painter.hpp b/include/cru/platform/graphics/Painter.hpp
index 76140c32..f75ea52b 100644
--- a/include/cru/platform/graphics/Painter.hpp
+++ b/include/cru/platform/graphics/Painter.hpp
@@ -9,6 +9,8 @@ struct IPainter : virtual INativeResource {
virtual void Clear(const Color& color) = 0;
+ virtual void DrawLine(const Point& start, const Point& end, IBrush* brush,
+ float width) = 0;
virtual void StrokeRectangle(const Rect& rectangle, IBrush* brush,
float width) = 0;
virtual void FillRectangle(const Rect& rectangle, IBrush* brush) = 0;
@@ -26,4 +28,4 @@ struct IPainter : virtual INativeResource {
virtual void EndDraw() = 0;
};
-} // namespace cru::platform::graph
+} // namespace cru::platform::graphics
diff --git a/include/cru/platform/graphics/util/Painter.hpp b/include/cru/platform/graphics/util/Painter.hpp
index af3a1997..90457cf4 100644
--- a/include/cru/platform/graphics/util/Painter.hpp
+++ b/include/cru/platform/graphics/util/Painter.hpp
@@ -10,7 +10,7 @@ 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);
+ painter->SetTransform(matrix * old);
action(painter);
painter->SetTransform(old);
}
diff --git a/include/cru/ui/render/ScrollBar.hpp b/include/cru/ui/render/ScrollBar.hpp
index 7cfd2576..3293e9d0 100644
--- a/include/cru/ui/render/ScrollBar.hpp
+++ b/include/cru/ui/render/ScrollBar.hpp
@@ -3,6 +3,7 @@
#include "cru/common/Base.hpp"
#include "cru/common/Event.hpp"
#include "cru/platform/graphics/Base.hpp"
+#include "cru/platform/graphics/Geometry.hpp"
#include "cru/platform/graphics/Painter.hpp"
#include "cru/platform/gui/Cursor.hpp"
#include "cru/platform/gui/UiApplication.hpp"
@@ -102,6 +103,8 @@ class ScrollBar : public Object {
protected:
gsl::not_null<ScrollRenderObject*> render_object_;
+ std::unique_ptr<platform::graphics::IGeometry> arrow_geometry_;
+
private:
Direction direction_;
diff --git a/include/cru/win/graphics/direct/Painter.hpp b/include/cru/win/graphics/direct/Painter.hpp
index 93c768e7..b34c1563 100644
--- a/include/cru/win/graphics/direct/Painter.hpp
+++ b/include/cru/win/graphics/direct/Painter.hpp
@@ -27,6 +27,8 @@ class D2DPainter : public DirectResource,
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;