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"
14#include "widget_baseline.hpp"
16namespace hi::inline v1 {
24 static constexpr float redraw_overhang = 2.0f;
86 hi_axiom((lhs.to_parent == rhs.to_parent) == (lhs.from_parent == rhs.from_parent));
87 hi_axiom((lhs.to_window == rhs.to_window) == (lhs.from_window == rhs.from_window));
90 return lhs.size == rhs.size and lhs.to_parent == rhs.to_parent and lhs.to_window == rhs.to_window and
91 lhs.clipping_rectangle == rhs.clipping_rectangle and lhs.sub_pixel_size == rhs.sub_pixel_size and
92 lhs.writing_direction == rhs.writing_direction and lhs.baseline == rhs.baseline;
103 return rectangle().contains(mouse_position) and clipping_rectangle.
contains(mouse_position);
115 return bounding_rectangle(to_window * clipping_rectangle);
125 return bounding_rectangle(to_window * intersect(clipping_rectangle, narrow_clipping_rectangle));
128 [[nodiscard]]
constexpr float width() const noexcept
133 [[nodiscard]]
constexpr float height() const noexcept
143 unicode_bidi_class writing_direction,
144 utc_nanoseconds display_time_point) noexcept :
150 clipping_rectangle(window_size),
152 writing_direction(writing_direction),
153 display_time_point(display_time_point),
169 auto to_parent3 =
translate3{child_rectangle, elevation};
170 auto from_parent3 = ~to_parent3;
173 r.to_parent = to_parent3;
174 r.from_parent = from_parent3;
175 r.to_window = to_parent3 * this->to_window;
176 r.from_window = from_parent3 * this->from_window;
177 r.size = child_rectangle.
size();
178 r.clipping_rectangle = bounding_rectangle(from_parent3 * intersect(this->clipping_rectangle, new_clipping_rectangle));
179 r.sub_pixel_size = this->sub_pixel_size;
180 r.writing_direction = this->writing_direction;
181 r.display_time_point = this->display_time_point;
182 if (new_baseline.empty()) {
183 r.baseline = this->baseline - child_rectangle.bottom();
185 r.baseline = new_baseline.absolute(child_rectangle.height());
198 return transform(child_rectangle, elevation, child_rectangle + redraw_overhang, new_baseline);
208 return transform(child_rectangle, 1.0f, child_rectangle + redraw_overhang, new_baseline);
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 extent2 size() const noexcept
Get size of the rectangle.
Definition axis_aligned_rectangle.hpp:162
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
The base-line of a widget on which to set the text and graphics.
Definition widget_baseline.hpp:13
Definition widget_layout.hpp:18
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:140
constexpr aarectangle window_clipping_rectangle() const noexcept
Get the clipping rectangle in window coordinate system.
Definition widget_layout.hpp:113
constexpr aarectangle window_clipping_rectangle(aarectangle narrow_clipping_rectangle) const noexcept
Get the clipping rectangle in window coordinate system.
Definition widget_layout.hpp:123
matrix3 to_window
This matrix transforms local coordinates to window coordinates.
Definition widget_layout.hpp:36
matrix3 to_parent
This matrix transforms local coordinates to the coordinates of the parent widget.
Definition widget_layout.hpp:28
float baseline
The base-line in widget local y-coordinate.
Definition widget_layout.hpp:76
aarectangle clipping_rectangle
The clipping rectangle.
Definition widget_layout.hpp:56
constexpr widget_layout transform(aarectangle const &child_rectangle, float elevation=1.0f, widget_baseline new_baseline=widget_baseline{}) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:196
extent2 sub_pixel_size
The size of a sub-pixel.
Definition widget_layout.hpp:62
extent2 size
Size of the widget.
Definition widget_layout.hpp:44
matrix3 from_parent
This matrix transforms parent widget's coordinates to local coordinates.
Definition widget_layout.hpp:32
constexpr widget_layout transform(aarectangle const &child_rectangle, float elevation, aarectangle new_clipping_rectangle, widget_baseline new_baseline=widget_baseline{}) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:167
matrix3 from_window
This matrix transforms window coordinates to local coordinates.
Definition widget_layout.hpp:40
utc_nanoseconds display_time_point
The layout created for displaying at this time point.
Definition widget_layout.hpp:72
constexpr bool contains(point3 mouse_position) const noexcept
Check if the mouse position is inside the widget.
Definition widget_layout.hpp:101
constexpr widget_layout override_clip(aarectangle new_clipping_rectangle) const noexcept
Override e context with the new clipping rectangle.
Definition widget_layout.hpp:216
constexpr widget_layout transform(aarectangle const &child_rectangle, widget_baseline new_baseline) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:206
unicode_bidi_class writing_direction
The default writing direction.
Definition widget_layout.hpp:68