1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
3
4#pragma once
5
6#include <cstdint>
7
8namespace slint {
9
10/// The Point structure is used to represent a two-dimensional point
11/// with x and y coordinates.
12template<typename T>
13struct Point
14{
15 /// The x coordinate of the point
16 T x;
17 /// The y coordinate of the point
18 T y;
19
20 /// Compares with \a other and returns true if they are equal; false otherwise.
21 bool operator==(const Point &other) const = default;
22};
23
24namespace cbindgen_private {
25// The Point types are expanded to the Point2D<...> type from the euclid crate which
26// is binary compatible with Point<T>
27template<typename T>
28using Point2D = Point<T>;
29}
30
31/// A position in logical pixel coordinates
32struct LogicalPosition : public Point<float>
33{
34 /// Explicitly convert a Point<float> to a LogicalPosition
35 explicit LogicalPosition(const Point<float> p) : Point<float>(p) {};
36 /// Default construct a LogicalPosition in the origin
37 LogicalPosition() : Point<float> { .x: 0., .y: 0. } {};
38};
39/// A position in physical pixel coordinates
40struct PhysicalPosition : public Point<int32_t>
41{
42 /// Explicitly convert a Point<int32_t> to a LogicalPosition
43 explicit PhysicalPosition(const Point<int32_t> p) : Point<int32_t>(p) {};
44 /// Default construct a PhysicalPosition in the origin
45 PhysicalPosition() : Point<int32_t> { .x: 0, .y: 0 } {};
46};
47
48}
49

source code of slint/api/cpp/include/slint_point.h