7#include "../geometry/matrix.hpp"
8#include "../geometry/axis_aligned_rectangle.hpp"
9#include "../geometry/transform.hpp"
10#include "../geometry/translate.hpp"
11#include "../unicode/unicode_bidi_class.hpp"
13#include "../chrono.hpp"
15namespace hi::inline v1 {
23 static constexpr float redraw_overhang = 2.0f;
81 hi_axiom((lhs.to_parent == rhs.to_parent) == (lhs.from_parent == rhs.from_parent));
82 hi_axiom((lhs.to_window == rhs.to_window) == (lhs.from_window == rhs.from_window));
86 lhs.size == rhs.size and
87 lhs.to_parent == rhs.to_parent and
88 lhs.to_window == rhs.to_window and
89 lhs.clipping_rectangle == rhs.clipping_rectangle and
90 lhs.sub_pixel_size == rhs.sub_pixel_size and
91 lhs.writing_direction == rhs.writing_direction;
102 return rectangle().contains(mouse_position) and clipping_rectangle.
contains(mouse_position);
114 return bounding_rectangle(to_window * clipping_rectangle);
124 return bounding_rectangle(to_window * intersect(clipping_rectangle, narrow_clipping_rectangle));
127 [[nodiscard]]
constexpr float width() const noexcept
132 [[nodiscard]]
constexpr float height() const noexcept
142 unicode_bidi_class writing_direction,
143 utc_nanoseconds display_time_point) noexcept :
149 clipping_rectangle(window_size),
151 writing_direction(writing_direction),
152 display_time_point(display_time_point)
166 auto to_parent3 =
translate3{child_rectangle, elevation};
167 auto from_parent3 = ~to_parent3;
172 r.
to_window = to_parent3 * this->to_window;
174 r.
size = child_rectangle.size();
175 r.
clipping_rectangle = bounding_rectangle(from_parent3 * intersect(this->clipping_rectangle, new_clipping_rectangle));
190 return transform(child_rectangle, elevation, child_rectangle + redraw_overhang);
constexpr extent2 sub_pixel_size(subpixel_orientation orientation) noexcept
Get the size of a sub-pixel based on the sub-pixel orientation.
Definition subpixel_orientation.hpp:38
subpixel_orientation
The orientation of the RGB sub-pixels of and LCD/LED panel.
Definition subpixel_orientation.hpp:18
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:20
constexpr bool contains(point2 const &rhs) const noexcept
Check if a 2D coordinate is inside the rectangle.
Definition axis_aligned_rectangle.hpp:235
constexpr float & height() noexcept
Access the y-as-height element from the extent.
Definition extent.hpp:151
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent.hpp:140
A rectangle / parallelogram in 3D space.
Definition rectangle.hpp:20
Definition translate.hpp:15
Definition widget_layout.hpp:17
constexpr widget_layout(extent2 window_size, hi::subpixel_orientation subpixel_orientation, unicode_bidi_class writing_direction, utc_nanoseconds display_time_point) noexcept
Construct a widget_layout from inside the window.
Definition widget_layout.hpp:139
constexpr aarectangle window_clipping_rectangle() const noexcept
Get the clipping rectangle in window coordinate system.
Definition widget_layout.hpp:112
constexpr aarectangle window_clipping_rectangle(aarectangle narrow_clipping_rectangle) const noexcept
Get the clipping rectangle in window coordinate system.
Definition widget_layout.hpp:122
matrix3 to_window
This matrix transforms local coordinates to window coordinates.
Definition widget_layout.hpp:35
matrix3 to_parent
This matrix transforms local coordinates to the coordinates of the parent widget.
Definition widget_layout.hpp:27
aarectangle clipping_rectangle
The clipping rectangle.
Definition widget_layout.hpp:55
constexpr widget_layout transform(aarectangle const &child_rectangle, float elevation, aarectangle new_clipping_rectangle) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:164
extent2 sub_pixel_size
The size of a sub-pixel.
Definition widget_layout.hpp:61
extent2 size
Size of the widget.
Definition widget_layout.hpp:43
matrix3 from_parent
This matrix transforms parent widget's coordinates to local coordinates.
Definition widget_layout.hpp:31
matrix3 from_window
This matrix transforms window coordinates to local coordinates.
Definition widget_layout.hpp:39
utc_nanoseconds display_time_point
The layout created for displaying at this time point.
Definition widget_layout.hpp:71
constexpr bool contains(point3 mouse_position) const noexcept
Check if the mouse position is inside the widget.
Definition widget_layout.hpp:100
constexpr widget_layout override_clip(aarectangle new_clipping_rectangle) const noexcept
Override e context with the new clipping rectangle.
Definition widget_layout.hpp:198
constexpr widget_layout transform(aarectangle const &child_rectangle, float elevation=1.0f) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:188
unicode_bidi_class writing_direction
The default writing direction.
Definition widget_layout.hpp:67