HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Friends
hi::v1::draw_context Class Reference

#include <hikogui/GFX/draw_context_intf.hpp>

Public Member Functions

 draw_context (draw_context const &rhs) noexcept=default
 
 draw_context (draw_context &&rhs) noexcept=default
 
draw_contextoperator= (draw_context const &rhs) noexcept=default
 
draw_contextoperator= (draw_context &&rhs) noexcept=default
 
 draw_context (gfx_device &device, vector_span< gfx_pipeline_box::vertex > &box_vertices, vector_span< gfx_pipeline_image::vertex > &image_vertices, vector_span< gfx_pipeline_SDF::vertex > &sdf_vertices, vector_span< gfx_pipeline_override::vertex > &override_vertices) noexcept
 
 operator bool () const noexcept
 Check if the draw_context should be used for rendering.
 
template<std::same_as< widget_layout > WidgetLayout>
void draw_box (WidgetLayout const &layout, quad const &box, draw_attributes const &attributes) const noexcept
 Draw a box.
 
template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void draw_box (WidgetLayout const &layout, Shape const &shape, Attributes const &...attributes) const noexcept
 Draw a box.
 
template<std::same_as< widget_layout > WidgetLayout>
void draw_line (WidgetLayout const &layout, line_segment const &line, draw_attributes const &attributes) const noexcept
 Draw a line.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void draw_line (WidgetLayout const &layout, line_segment const &line, Attributes const &...attributes) const noexcept
 Draw a line.
 
template<std::same_as< widget_layout > WidgetLayout>
void draw_circle (WidgetLayout const &layout, hi::circle const &circle, draw_attributes const &attributes) const noexcept
 Draw a circle.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void draw_circle (WidgetLayout const &layout, hi::circle const &circle, Attributes const &...attributes) const noexcept
 Draw a circle.
 
template<std::same_as< widget_layout > WidgetLayout>
bool draw_image (WidgetLayout const &layout, quad const &box, gfx_pipeline_image::paged_image &image, draw_attributes const &attributes) const noexcept
 Draw an image.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
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.
 
template<std::same_as< widget_layout > WidgetLayout>
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.
 
template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
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.
 
template<std::same_as< widget_layout > WidgetLayout>
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.
 
template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void draw_glyph (WidgetLayout const &layout, Shape const &box, font_book::font_glyph_type const &glyph, Attributes const &...attributes) const noexcept
 Draw a glyph.
 
template<std::same_as< widget_layout > WidgetLayout>
void draw_text (WidgetLayout const &layout, matrix3 const &transform, text_shaper const &text, draw_attributes const &attributes) const noexcept
 Draw shaped text.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void draw_text (WidgetLayout const &layout, matrix3 const &transform, text_shaper const &text, Attributes const &...attributes) const noexcept
 Draw shaped text.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void draw_text (WidgetLayout const &layout, text_shaper const &text, Attributes const &...attributes) const noexcept
 Draw shaped text.
 
template<std::same_as< widget_layout > WidgetLayout>
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.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
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.
 
template<std::same_as< widget_layout > WidgetLayout>
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.
 
template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
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.
 
template<std::same_as< widget_layout > WidgetLayout>
void draw_hole (WidgetLayout const &layout, quad const &box, draw_attributes attributes) const noexcept
 Make a hole in the user interface.
 
template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void draw_hole (WidgetLayout const &layout, Shape const &box, Attributes const &...attributes) const noexcept
 Make a hole in the user interface.
 

Data Fields

gfx_device * device
 
std::size_t frame_buffer_index
 The frame buffer index of the image we are currently rendering.
 
aarectangle scissor_rectangle
 This is the rectangle of the window that is being redrawn.
 
hi::subpixel_orientation subpixel_orientation
 The subpixel orientation for rendering glyphs.
 
float saturation
 The tone-mapper's saturation.
 
utc_nanoseconds display_time_point
 The time when the drawing will appear on the screen.
 

Friends

template<std::same_as< widget_layout > WidgetLayout>
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.
 

Detailed Description

Draw context for drawing using the HikoGUI shaders.

Member Function Documentation

◆ draw_box() [1/2]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_box ( WidgetLayout const & layout,
quad const & box,
draw_attributes const & attributes ) const
inlinenoexcept

Draw a box.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe four points of the box to draw.
attributesThe drawing attributes to use.

◆ draw_box() [2/2]

template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void hi::v1::draw_context::draw_box ( WidgetLayout const & layout,
Shape const & shape,
Attributes const &... attributes ) const
inlinenoexcept

Draw a box.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
shapeThe shape of the box.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_circle() [1/2]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void hi::v1::draw_context::draw_circle ( WidgetLayout const & layout,
hi::circle const & circle,
Attributes const &... attributes ) const
inlinenoexcept

Draw a circle.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
circleThe circle to draw.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_circle() [2/2]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_circle ( WidgetLayout const & layout,
hi::circle const & circle,
draw_attributes const & attributes ) const
inlinenoexcept

Draw a circle.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
circleThe circle to draw.
attributesThe drawing attributes to use.

◆ draw_glyph() [1/4]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_glyph ( WidgetLayout const & layout,
quad const & box,
font_book::font_glyph_type const & glyph,
draw_attributes const & attributes ) const
inlinenoexcept

Draw a glyph.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe size and position of the glyph.
glyphThe glyphs to draw.
attributesThe drawing attributes to use.

◆ draw_glyph() [2/4]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_glyph ( WidgetLayout const & layout,
quad const & box,
hi::font const & font,
glyph_id glyph,
draw_attributes const & attributes ) const
inlinenoexcept

Draw a glyph.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe size and position of the glyph.
glyphThe glyphs to draw.
attributesThe drawing attributes to use.

◆ draw_glyph() [3/4]

template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void hi::v1::draw_context::draw_glyph ( WidgetLayout const & layout,
Shape const & box,
font_book::font_glyph_type const & glyph,
Attributes const &... attributes ) const
inlinenoexcept

Draw a glyph.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe size and position of the glyph.
glyphThe glyphs to draw.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_glyph() [4/4]

template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void hi::v1::draw_context::draw_glyph ( WidgetLayout const & layout,
Shape const & box,
hi::font const & font,
hi::glyph_id glyph_id,
Attributes const &... attributes ) const
inlinenoexcept

Draw a glyph.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe size and position of the glyph.
glyphThe glyphs to draw.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_hole() [1/2]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_hole ( WidgetLayout const & layout,
quad const & box,
draw_attributes attributes ) const
inlinenoexcept

Make a hole in the user interface.

This function makes a hole in the user-interface so that fragments written in the swap-chain before the GUI is drawn will be visible.

Parameters
layoutThe layout of the widget.
boxThe box in local coordinates of the widget.
attributesThe drawing attributes to use.

◆ draw_hole() [2/2]

template<std::same_as< widget_layout > WidgetLayout, draw_quad_shape Shape, draw_attribute... Attributes>
void hi::v1::draw_context::draw_hole ( WidgetLayout const & layout,
Shape const & box,
Attributes const &... attributes ) const
inlinenoexcept

Make a hole in the user interface.

This function makes a hole in the user-interface so that fragments written in the swap-chain before the GUI is drawn will be visible.

Parameters
layoutThe layout of the widget.
boxThe box in local coordinates of the widget.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_image() [1/2]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
bool hi::v1::draw_context::draw_image ( WidgetLayout const & layout,
draw_quad_shape auto const & box,
gfx_pipeline_image::paged_image & image,
Attributes const &... attributes ) const
inlinenoexcept

Draw an image.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe four points of the box to draw.
imageThe image to show.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().
Returns
True when the image was drawn, false if the image is not ready yet. Widgets may want to request a redraw if the image is not ready.

◆ draw_image() [2/2]

template<std::same_as< widget_layout > WidgetLayout>
bool hi::v1::draw_context::draw_image ( WidgetLayout const & layout,
quad const & box,
gfx_pipeline_image::paged_image & image,
draw_attributes const & attributes ) const
inlinenoexcept

Draw an image.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe four points of the box to draw.
imageThe image to show.
attributesThe drawing attributes to use.
Returns
True when the image was drawn, false if the image is not ready yet. Widgets may want to request a redraw if the image is not ready.

◆ draw_line() [1/2]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void hi::v1::draw_context::draw_line ( WidgetLayout const & layout,
line_segment const & line,
Attributes const &... attributes ) const
inlinenoexcept

Draw a line.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
lineThe line segment to draw.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_line() [2/2]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_line ( WidgetLayout const & layout,
line_segment const & line,
draw_attributes const & attributes ) const
inlinenoexcept

Draw a line.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
lineThe line segment to draw.
attributesThe drawing attributes to use.

◆ draw_text() [1/3]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void hi::v1::draw_context::draw_text ( WidgetLayout const & layout,
matrix3 const & transform,
text_shaper const & text,
Attributes const &... attributes ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
transformHow to transform the shaped text relative to layout.
textThe shaped text to draw.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_text() [2/3]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_text ( WidgetLayout const & layout,
matrix3 const & transform,
text_shaper const & text,
draw_attributes const & attributes ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
transformHow to transform the shaped text relative to layout.
textThe shaped text to draw.
attributesThe drawing attributes to use.

◆ draw_text() [3/3]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void hi::v1::draw_context::draw_text ( WidgetLayout const & layout,
text_shaper const & text,
Attributes const &... attributes ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
textThe shaped text to draw.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_text_cursors() [1/2]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void hi::v1::draw_context::draw_text_cursors ( WidgetLayout const & layout,
text_shaper const & text,
text_cursor cursor,
bool overwrite_mode,
bool dead_character_mode,
Attributes const &... attributes ) const
inlinenoexcept

Draw text cursors of shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
textThe shaped text to draw.
cursorThe position of the cursor.
overwrite_modeIf true draw overwrite mode cursor; if false draw insertion mode cursors,
dead_character_modeIf true draw the dead-character cursor. The dead_character_mode overrides all other cursors.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_text_cursors() [2/2]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::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
inlinenoexcept

Draw text cursors of shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
textThe shaped text to draw.
cursorThe position of the cursor.
overwrite_modeIf true draw overwrite mode cursor; if false draw insertion mode cursors,
dead_character_modeIf true draw the dead-character cursor. The dead_character_mode overrides all other cursors.
attributesThe drawing attributes to use.

◆ draw_text_selection() [1/2]

template<std::same_as< widget_layout > WidgetLayout, draw_attribute... Attributes>
void hi::v1::draw_context::draw_text_selection ( WidgetLayout const & layout,
text_shaper const & text,
text_selection const & selection,
Attributes const &... attributes ) const
inlinenoexcept

Draw text-selection of shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
textThe shaped text to draw.
selectionThe text selection.
attributesThe drawing attributes to use, see: draw_attributes::draw_attributes().

◆ draw_text_selection() [2/2]

template<std::same_as< widget_layout > WidgetLayout>
void hi::v1::draw_context::draw_text_selection ( WidgetLayout const & layout,
text_shaper const & text,
text_selection const & selection,
draw_attributes const & attributes ) const
inlinenoexcept

Draw text-selection of shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
textThe shaped text to draw.
selectionThe text selection.
attributesThe drawing attributes to use.

◆ operator bool()

hi::v1::draw_context::operator bool ( ) const
inlinenoexcept

Check if the draw_context should be used for rendering.

Friends And Related Symbol Documentation

◆ overlaps

template<std::same_as< widget_layout > WidgetLayout>
bool overlaps ( draw_context const & context,
WidgetLayout const & layout )
friend

Checks if a widget's layout overlaps with the part of the window that is being drawn.

Parameters
contextThe draw context which contains the scissor rectangle.
layoutThe layout of a widget which contains the rectangle where the widget is located on the window
Returns
True if the widget needs to draw into the context.

Field Documentation

◆ display_time_point

utc_nanoseconds hi::v1::draw_context::display_time_point

The time when the drawing will appear on the screen.

◆ frame_buffer_index

std::size_t hi::v1::draw_context::frame_buffer_index

The frame buffer index of the image we are currently rendering.

◆ saturation

float hi::v1::draw_context::saturation

The tone-mapper's saturation.

◆ scissor_rectangle

aarectangle hi::v1::draw_context::scissor_rectangle

This is the rectangle of the window that is being redrawn.

◆ subpixel_orientation

hi::subpixel_orientation hi::v1::draw_context::subpixel_orientation

The subpixel orientation for rendering glyphs.


The documentation for this class was generated from the following files: