7#include "gfx_pipeline_box_vulkan.hpp"
8#include "gfx_pipeline_image_vulkan.hpp"
9#include "gfx_pipeline_SDF_vulkan.hpp"
10#include "gfx_pipeline_alpha_vulkan.hpp"
11#include "../settings/settings.hpp"
12#include "../geometry/module.hpp"
13#include "../unicode/unicode.hpp"
14#include "../text/module.hpp"
15#include "../color/module.hpp"
16#include "../container/module.hpp"
17#include "../utility/utility.hpp"
18#include "../macros.hpp"
20namespace hi {
inline namespace v1 {
23struct gfx_pipeline_image::paged_image;
41template<
typename Context>
43 std::same_as<Context, border_side>
or std::same_as<Context, line_end_cap>
or std::same_as<Context, corner_radii>
or
44 std::same_as<Context, aarectangle>
or std::same_as<Context, float>
or std::same_as<Context, int>;
49 unsigned char num_colors = 0;
50 unsigned char num_line_caps = 0;
126 template<draw_attribute T>
127 constexpr void add(T
const&
attribute)
noexcept
129 if constexpr (std::is_same_v<T, quad_color>) {
130 if (num_colors++ == 0) {
135 hi_axiom(num_colors <= 2);
137 }
else if constexpr (std::is_same_v<T, color>) {
138 if (num_colors++ == 0) {
143 hi_axiom(num_colors <= 2);
145 }
else if constexpr (std::is_same_v<T, line_end_cap>) {
146 if (num_line_caps++ == 0) {
152 hi_axiom(num_line_caps <= 2);
154 }
else if constexpr (std::is_same_v<T, hi::border_side>) {
157 hi_assert(
not _has_border_side);
158 _has_border_side =
true;
161 }
else if constexpr (std::is_same_v<T, corner_radii>) {
164 hi_assert(
not _has_corner_radii);
165 _has_corner_radii =
true;
168 }
else if constexpr (std::is_same_v<T, aarectangle>) {
171 hi_assert(
not _has_clipping_rectangle);
172 _has_clipping_rectangle =
true;
175 }
else if constexpr (std::is_same_v<T, float>
or std::is_same_v<T, int>) {
178 hi_assert(
not _has_line_width);
179 _has_line_width =
true;
182 hi_static_no_default();
186 template<draw_attribute
First, draw_attribute
Second, draw_attribute...
Rest>
195 bool _has_border_side =
false;
196 bool _has_corner_radii =
false;
197 bool _has_clipping_rectangle =
false;
198 bool _has_line_width =
false;
202template<
typename Context>
203concept draw_quad_shape = std::same_as<Context, quad>
or std::same_as<Context, rectangle>
or std::same_as<Context, aarectangle>
or
204 std::same_as<Context, aarectangle>;
262 template<std::same_as<w
idget_layout> W
idgetLayout>
275 template<std::same_as<w
idget_layout> W
idgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
287 template<std::same_as<w
idget_layout> W
idgetLayout>
305 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
317 template<std::same_as<w
idget_layout> W
idgetLayout>
331 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
346 template<std::same_as<w
idget_layout> W
idgetLayout>
350 return _draw_image(layout.clipping_rectangle_on_window(
attributes.clipping_rectangle), layout.to_window3() *
box, image);
362 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
377 template<std::same_as<w
idget_layout> W
idgetLayout>
381 hi::font
const& font,
386 layout.clipping_rectangle_on_window(
attributes.clipping_rectangle), layout.to_window3() *
box, font, glyph,
attributes);
396 template<std::same_as<w
idget_layout> W
idgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
400 hi::font
const& font,
401 hi::glyph_id glyph_id,
414 template<std::same_as<w
idget_layout> W
idgetLayout>
418 font_book::font_glyph_type
const& glyph,
422 layout.clipping_rectangle_on_window(
attributes.clipping_rectangle), layout.to_window3() *
box, *glyph.font, glyph.id,
attributes);
432 template<std::same_as<w
idget_layout> W
idgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
436 font_book::font_glyph_type
const& glyph,
449 template<std::same_as<w
idget_layout> W
idgetLayout>
455 layout.clipping_rectangle_on_window(
attributes.clipping_rectangle),
456 layout.to_window3() * transform,
468 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
481 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
494 template<std::same_as<w
idget_layout> W
idgetLayout>
497 text_shaper
const& text,
498 text_selection
const& selection,
501 return _draw_text_selection(
502 layout.clipping_rectangle_on_window(
attributes.clipping_rectangle), layout.to_window3(), text, selection,
attributes);
512 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
515 text_shaper
const& text,
516 text_selection
const& selection,
531 template<std::same_as<w
idget_layout> W
idgetLayout>
534 text_shaper
const& text,
540 return _draw_text_cursors(
541 layout.clipping_rectangle_on_window(
attributes.clipping_rectangle),
559 template<std::same_as<w
idget_layout> W
idgetLayout, draw_attribute... Attributes>
562 text_shaper
const& text,
580 template<std::same_as<w
idget_layout> W
idgetLayout>
583 return _override_alpha(
596 template<std::same_as<w
idget_layout> W
idgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
609 template<std::same_as<w
idget_layout> W
idgetLayout>
612 return overlaps(
context.scissor_rectangle, layout.clipping_rectangle_on_window());
621 template<draw_quad_shape Shape>
622 [[
nodiscard]]
constexpr static quad make_quad(
Shape const& shape)
noexcept
624 if constexpr (std::is_same_v<Shape, quad>) {
634 auto right = line.direction();
636 hilet radius = width * 0.5f;
637 hilet n = normal(
right, 0.0f);
638 hilet up = n * width;
639 hilet t = normalize(
right);
641 auto origin = line.origin() - n * radius;
661 hilet up = vector3{
circle_._0w00() * 2.0f};
667 auto r = f32x4::broadcast(width * 0.5f);
676 return corner_radii{r};
679 [[
nodiscard]]
constexpr static corner_radii make_corner_radii(
hi::circle const& circle)
noexcept
681 return corner_radii{
f32x4{circle}.wwww()};
684 void _override_alpha(aarectangle
const& clipping_rectangle, quad
box, draw_attributes
const&
attributes)
const noexcept;
686 void _draw_box(aarectangle
const& clipping_rectangle, quad
box, draw_attributes
const&
attributes)
const noexcept;
689 aarectangle
const& clipping_rectangle,
690 matrix3
const& transform,
691 text_shaper
const& text,
692 draw_attributes
const&
attributes)
const noexcept;
694 void _draw_text_selection(
695 aarectangle
const& clipping_rectangle,
696 matrix3
const& transform,
697 text_shaper
const& text,
698 text_selection
const& selection,
699 draw_attributes
const&
attributes)
const noexcept;
701 void _draw_text_insertion_cursor_empty(
702 aarectangle
const& clipping_rectangle,
703 matrix3
const& transform,
704 text_shaper
const& text,
705 draw_attributes
const&
attributes)
const noexcept;
707 void _draw_text_insertion_cursor(
708 aarectangle
const& clipping_rectangle,
709 matrix3
const& transform,
710 text_shaper
const& text,
713 draw_attributes
const&
attributes)
const noexcept;
715 void _draw_text_overwrite_cursor(
716 aarectangle
const& clipping_rectangle,
717 matrix3
const& transform,
718 text_shaper::char_const_iterator
it,
719 draw_attributes
const&
attributes)
const noexcept;
721 void _draw_text_cursors(
722 aarectangle
const& clipping_rectangle,
723 matrix3
const& transform,
724 text_shaper
const& text,
728 draw_attributes
const&
attributes)
const noexcept;
731 aarectangle
const& clipping_rectangle,
733 hi::font
const& font,
735 draw_attributes
const&
attributes)
const noexcept;
738 _draw_image(aarectangle
const& clipping_rectangle, quad
const&
box, gfx_pipeline_image::paged_image
const& image)
const noexcept;
line_end_cap
The way two lines should be joined.
Definition line_end_cap.hpp:18
@ right
Align the text to the right side.
@ flat
The end cap of the line is flat.
@ round
The end cap of the line is round.
@ rectangle
The gui_event has rectangle data.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
border_side
The side where the border is drawn.
Definition draw_context.hpp:27
@ inside
The border is drawn inside the edge of a quad.
@ outside
The border is drawn outside the edge of a quad.
@ on
The border is drawn on the edge of a quad.
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A color for each corner of a quad.
Definition quad_color.hpp:20
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
static constexpr aarectangle large() noexcept
Create a large axis aligned rectangle.
Definition aarectangle.hpp:42
A type defining a 2D circle.
Definition circle.hpp:19
The 4 radii of the corners of a quad or rectangle.
Definition corner_radii.hpp:19
Line segment.
Definition line_segment.hpp:21
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix3.hpp:30
The draw attributes used to draw shaped into the draw context.
Definition draw_context.hpp:48
aarectangle clipping_rectangle
The rectangle used the clip the shape when drawing.
Definition draw_context.hpp:82
hi::border_side border_side
The side on which side of the edge of a shape the border should be drawn.
Definition draw_context.hpp:71
float line_width
The width of a line, or the width of a border.
Definition draw_context.hpp:67
line_end_cap end_line_cap
The shape of the beginning of a line.
Definition draw_context.hpp:90
quad_color fill_color
The fill color used for the color of a box inside the border.
Definition draw_context.hpp:57
quad_color line_color
The line color used for the color of the border of the box.
Definition draw_context.hpp:63
line_end_cap begin_line_cap
The shape of the beginning of a line.
Definition draw_context.hpp:86
hi::corner_radii corner_radius
The radii of each corner of a quad.
Definition draw_context.hpp:75
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:208
void draw_glyph(WidgetLayout const &layout, quad const &box, font_book::font_glyph_type const &glyph, draw_attributes const &attributes) const noexcept
Draw a glyph.
Definition draw_context.hpp:415
void draw_text(WidgetLayout const &layout, text_shaper const &text, Attributes const &...attributes) const noexcept
Draw shaped text.
Definition draw_context.hpp:482
void draw_circle(WidgetLayout const &layout, hi::circle const &circle, Attributes const &...attributes) const noexcept
Draw a circle.
Definition draw_context.hpp:332
void draw_text_cursors(WidgetLayout const &layout, text_shaper const &text, text_cursor cursor, bool overwrite_mode, bool dead_character_mode, Attributes const &...attributes) const noexcept
Draw text cursors of shaped text.
Definition draw_context.hpp:560
hi::subpixel_orientation subpixel_orientation
The subpixel orientation for rendering glyphs.
Definition draw_context.hpp:222
friend bool overlaps(draw_context const &context, WidgetLayout const &layout) noexcept
Checks if a widget's layout overlaps with the part of the window that is being drawn.
Definition draw_context.hpp:610
void draw_box(WidgetLayout const &layout, Shape const &shape, Attributes const &...attributes) const noexcept
Draw a box.
Definition draw_context.hpp:276
bool draw_image(WidgetLayout const &layout, draw_quad_shape auto const &box, gfx_pipeline_image::paged_image &image, Attributes const &...attributes) const noexcept
Draw an image.
Definition draw_context.hpp:364
void draw_circle(WidgetLayout const &layout, hi::circle const &circle, draw_attributes const &attributes) const noexcept
Draw a circle.
Definition draw_context.hpp:318
float saturation
The tone-mapper's saturation.
Definition draw_context.hpp:230
void draw_text(WidgetLayout const &layout, matrix3 const &transform, text_shaper const &text, Attributes const &...attributes) const noexcept
Draw shaped text.
Definition draw_context.hpp:469
bool active
Window is active.
Definition draw_context.hpp:226
void draw_glyph(WidgetLayout const &layout, Shape const &box, hi::font const &font, hi::glyph_id glyph_id, Attributes const &...attributes) const noexcept
Draw a glyph.
Definition draw_context.hpp:397
void draw_text_selection(WidgetLayout const &layout, text_shaper const &text, text_selection const &selection, draw_attributes const &attributes) const noexcept
Draw text-selection of shaped text.
Definition draw_context.hpp:495
aarectangle scissor_rectangle
This is the rectangle of the window that is being redrawn.
Definition draw_context.hpp:218
void draw_line(WidgetLayout const &layout, line_segment const &line, Attributes const &...attributes) const noexcept
Draw a line.
Definition draw_context.hpp:306
void draw_glyph(WidgetLayout const &layout, Shape const &box, font_book::font_glyph_type const &glyph, Attributes const &...attributes) const noexcept
Draw a glyph.
Definition draw_context.hpp:433
std::size_t frame_buffer_index
The frame buffer index of the image we are currently rendering.
Definition draw_context.hpp:214
void draw_hole(WidgetLayout const &layout, quad const &box, draw_attributes const &attributes) const noexcept
Make a hole in the user interface.
Definition draw_context.hpp:581
void draw_hole(WidgetLayout const &layout, Shape const &box, Attributes const &...attributes) const noexcept
Make a hole in the user interface.
Definition draw_context.hpp:597
void draw_text_cursors(WidgetLayout const &layout, text_shaper const &text, text_cursor cursor, bool overwrite_mode, bool dead_character_mode, draw_attributes const &attributes) const noexcept
Draw text cursors of shaped text.
Definition draw_context.hpp:532
void draw_line(WidgetLayout const &layout, line_segment const &line, draw_attributes const &attributes) const noexcept
Draw a line.
Definition draw_context.hpp:288
bool draw_image(WidgetLayout const &layout, quad const &box, gfx_pipeline_image::paged_image &image, draw_attributes const &attributes) const noexcept
Draw an image.
Definition draw_context.hpp:348
void draw_text_selection(WidgetLayout const &layout, text_shaper const &text, text_selection const &selection, Attributes const &...attributes) const noexcept
Draw text-selection of shaped text.
Definition draw_context.hpp:513
void draw_glyph(WidgetLayout const &layout, quad const &box, hi::font const &font, glyph_id glyph, draw_attributes const &attributes) const noexcept
Draw a glyph.
Definition draw_context.hpp:378
void draw_box(WidgetLayout const &layout, quad const &box, draw_attributes const &attributes) const noexcept
Draw a box.
Definition draw_context.hpp:263
utc_nanoseconds display_time_point
The time when the drawing will appear on the screen.
Definition draw_context.hpp:234
void draw_text(WidgetLayout const &layout, matrix3 const &transform, text_shaper const &text, draw_attributes const &attributes) const noexcept
Draw shaped text.
Definition draw_context.hpp:451
This is a image that is uploaded into the texture atlas.
Definition gfx_pipeline_image_vulkan.hpp:79
Definition draw_context.hpp:42
Definition draw_context.hpp:203