1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4#pragma once
5
6#include <cstdint>
7
8namespace slint {
9
10/// The Size structure is used to represent a two-dimensional size
11/// with width and height.
12template<typename T>
13struct Size
14{
15 /// The width of the size
16 T width;
17 /// The height of the size
18 T height;
19
20 /// Compares with \a other and returns true if they are equal; false otherwise.
21 bool operator==(const Size &other) const = default;
22};
23
24namespace cbindgen_private {
25// The Size types are expanded to the Size2D<...> type from the euclid crate which
26// is binary compatible with Size<T>
27template<typename T>
28using Size2D = Size<T>;
29}
30
31/// A size given in logical pixels
32struct LogicalSize : public Size<float>
33{
34 /// Explicitly convert a Size<float> to a LogicalSize
35 explicit constexpr LogicalSize(const Size<float> s = { .width: 0, .height: 0 }) : Size<float>(s) { }
36};
37/// A size given in physical pixels.
38struct PhysicalSize : public Size<uint32_t>
39{
40 /// Explicitly convert a Size<uint32_t> to a LogicalSize
41 explicit constexpr PhysicalSize(const Size<uint32_t> s = { .width: 0, .height: 0 }) : Size<uint32_t>(s) { }
42};
43
44}
45

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