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

#include <hikogui/GFX/draw_context.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_vulkan &device, vector_span< pipeline_box::vertex > &box_vertices, vector_span< pipeline_image::vertex > &image_vertices, vector_span< pipeline_SDF::vertex > &sdf_vertices, vector_span< pipeline_alpha::vertex > &alpha_vertices) noexcept
 
 operator bool () const noexcept
 Check if the draw_context should be used for rendering.
 
void draw_box (widget_layout const &layout, quad const &box, quad_color const &fill_color, quad_color const &border_color, float border_width, hi::border_side border_side, hi::corner_radii const &corner_radius={}) const noexcept
 Draw a box with rounded corners.
 
void draw_box (widget_layout const &layout, aarectangle const &clipping_rectangle, quad const &box, quad_color const &fill_color, quad_color const &border_color, float border_width, hi::border_side border_side, hi::corner_radii const &corner_radius={}) const noexcept
 Draw a box with rounded corners.
 
void draw_box (widget_layout const &layout, quad const &box, quad_color const &fill_color, hi::corner_radii const &corner_radius={}) const noexcept
 Draw a box with rounded corners without a border.
 
void draw_box (widget_layout const &layout, aarectangle const &clipping_rectangle, quad const &box, quad_color const &fill_color, hi::corner_radii const &corner_radius={}) const noexcept
 Draw a box with rounded corners without a border.
 
void draw_line (widget_layout const &layout, line_segment const &line, float width, quad_color const &fill_color, line_end_cap c1=line_end_cap::flat, line_end_cap c2=line_end_cap::flat) const noexcept
 
void draw_line (widget_layout const &layout, aarectangle const &clipping_rectangle, line_segment const &line, float width, quad_color const &fill_color, line_end_cap c1=line_end_cap::flat, line_end_cap c2=line_end_cap::flat) const noexcept
 
void draw_circle (widget_layout const &layout, hi::circle const &circle, quad_color const &fill_color) const noexcept
 
void draw_circle (widget_layout const &layout, aarectangle const clipping_rectangle, hi::circle const &circle, quad_color const &fill_color) const
 
void draw_circle (widget_layout const &layout, hi::circle const &circle, quad_color const &fill_color, quad_color const &border_color, float border_width, hi::border_side border_side) const noexcept
 
void draw_circle (widget_layout const &layout, aarectangle const &clipping_rectangle, hi::circle const &circle, quad_color const &fill_color, quad_color const &border_color, float border_width, hi::border_side border_side) const noexcept
 
bool draw_image (widget_layout const &layout, quad const &box, paged_image &image) const noexcept
 Draw an image.
 
bool draw_image (widget_layout const &layout, aarectangle const &clipping_rectangle, quad const &box, paged_image &image) const noexcept
 Draw an image.
 
void draw_glyph (widget_layout const &layout, quad const &box, quad_color const &color, glyph_ids const &glyph) const noexcept
 Draw a glyph.
 
void draw_glyph (widget_layout const &layout, aarectangle clipping_rectangle, quad const &box, quad_color const &color, glyph_ids const &glyph) const noexcept
 Draw a glyph.
 
void draw_text (widget_layout const &layout, matrix3 const &transform, quad_color const &color, shaped_text const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, aarectangle const &clipping_rectangle, matrix3 const &transform, quad_color const &color, shaped_text const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, matrix3 const &transform, shaped_text const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, matrix3 const &transform, quad_color const &color, text_shaper const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, quad_color const &color, text_shaper const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, aarectangle const &clipping_rectangle, matrix3 const &transform, quad_color const &color, text_shaper const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, aarectangle const &clipping_rectangle, quad_color const &color, text_shaper const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, matrix3 const &transform, text_shaper const &text) const noexcept
 Draw shaped text.
 
void draw_text (widget_layout const &layout, text_shaper const &text) const noexcept
 Draw shaped text.
 
void draw_text_selection (widget_layout const &layout, text_shaper const &text, text_selection const &selection, hi::color color) const noexcept
 Draw text-selection of shaped text.
 
void draw_text_cursors (widget_layout const &layout, text_shaper const &text, text_cursor cursor, hi::color primary_color, hi::color secondary_color, bool overwrite_mode, bool dead_character_mode) const noexcept
 Draw text cursors of shaped text.
 
void make_hole (widget_layout const &layout, quad const &box) const noexcept
 Make a hole in the user interface.
 

Static Public Member Functions

static constexpr rectangle make_rectangle (line_segment const &line, float width, line_end_cap c1, line_end_cap c2) noexcept
 
static constexpr corner_radii make_corner_radii (float width, line_end_cap c1, line_end_cap c2) noexcept
 
static constexpr rectangle make_rectangle (hi::circle const &circle) noexcept
 
static constexpr corner_radii make_corner_radii (hi::circle const &circle) noexcept
 

Data Fields

gfx_device_vulkandevice
 
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.
 
color background_color
 The background color to clear the window with.
 
hi::subpixel_orientation subpixel_orientation
 The subpixel orientation for rendering glyphs.
 
bool active
 Window is active.
 
float saturation
 The tone-mapper's saturation.
 
utc_nanoseconds display_time_point
 The time when the drawing will appear on the screen.
 

Friends

bool overlaps (draw_context const &context, widget_layout const &layout) noexcept
 

Detailed Description

Draw context for drawing using the HikoGUI shaders.

Member Function Documentation

◆ draw_box() [1/4]

void v1::draw_context::draw_box ( widget_layout const & layout,
aarectangle const & clipping_rectangle,
quad const & box,
quad_color const & fill_color,
hi::corner_radii const & corner_radius = {} ) const
inlinenoexcept

Draw a box with rounded corners without a border.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleA more narrow clipping rectangle than supplied by layout.
boxThe four points of the box to draw.
fill_colorThe fill color of the inside of the box.
corner_radiusThe corner radii of each corner of the box.

◆ draw_box() [2/4]

void v1::draw_context::draw_box ( widget_layout const & layout,
aarectangle const & clipping_rectangle,
quad const & box,
quad_color const & fill_color,
quad_color const & border_color,
float border_width,
hi::border_side border_side,
hi::corner_radii const & corner_radius = {} ) const
inlinenoexcept

Draw a box with rounded corners.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleThe rectangle into which to draw the box.
boxThe four points of the box to draw.
fill_colorThe fill color of the inside of the box.
border_colorThe line color of the border of the box.
border_widthThe line width of the border.
border_sideThe side of the edge where the border is drawn.
corner_radiusThe corner radii of each corner of the box.

◆ draw_box() [3/4]

void v1::draw_context::draw_box ( widget_layout const & layout,
quad const & box,
quad_color const & fill_color,
hi::corner_radii const & corner_radius = {} ) const
inlinenoexcept

Draw a box with rounded corners without a border.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe four points of the box to draw.
fill_colorThe fill color of the inside of the box.
corner_radiusThe corner radii of each corner of the box.

◆ draw_box() [4/4]

void v1::draw_context::draw_box ( widget_layout const & layout,
quad const & box,
quad_color const & fill_color,
quad_color const & border_color,
float border_width,
hi::border_side border_side,
hi::corner_radii const & corner_radius = {} ) const
inlinenoexcept

Draw a box with rounded corners.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
boxThe four points of the box to draw.
fill_colorThe fill color of the inside of the box.
border_colorThe line color of the border of the box.
border_widthThe line width of the border.
border_sideThe side of the edge where the border is drawn.
corner_radiusThe corner radii of each corner of the box.

◆ draw_glyph() [1/2]

void v1::draw_context::draw_glyph ( widget_layout const & layout,
aarectangle clipping_rectangle,
quad const & box,
quad_color const & color,
glyph_ids const & glyph ) const
inlinenoexcept

Draw a glyph.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleA more narrow clipping rectangle than supplied by layout.
boxThe size and position of the glyph.
colorThe color that the glyph should be drawn in.
glyphThe glyphs to draw.

◆ draw_glyph() [2/2]

void v1::draw_context::draw_glyph ( widget_layout const & layout,
quad const & box,
quad_color const & color,
glyph_ids const & glyph ) 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.
colorThe color that the glyph should be drawn in.
glyphThe glyphs to draw.

◆ draw_image() [1/2]

bool v1::draw_context::draw_image ( widget_layout const & layout,
aarectangle const & clipping_rectangle,
quad const & box,
paged_image & image ) const
inlinenoexcept

Draw an image.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleA more narrow clipping rectangle than supplied by layout.
boxThe four points of the box to draw.
imageThe image to show.
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]

bool v1::draw_context::draw_image ( widget_layout const & layout,
quad const & box,
paged_image & image ) 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.
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_text() [1/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
aarectangle const & clipping_rectangle,
matrix3 const & transform,
quad_color const & color,
shaped_text const & text ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleA more narrow clipping rectangle than supplied by layout.
transformHow to transform the shaped text relative to layout.
colorText-color overriding the colors from the shaped_text.
textThe shaped text to draw.

◆ draw_text() [2/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
aarectangle const & clipping_rectangle,
matrix3 const & transform,
quad_color const & color,
text_shaper const & text ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleA more narrow clipping rectangle than supplied by layout.
transformHow to transform the shaped text relative to layout.
colorText-color overriding the colors from the shaped_text.
textThe shaped text to draw.

◆ draw_text() [3/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
aarectangle const & clipping_rectangle,
quad_color const & color,
text_shaper const & text ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
clipping_rectangleA more narrow clipping rectangle than supplied by layout.
colorText-color overriding the colors from the shaped_text.
textThe shaped text to draw.

◆ draw_text() [4/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
matrix3 const & transform,
quad_color const & color,
shaped_text const & text ) 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.
colorText-color overriding the colors from the shaped_text.
textThe shaped text to draw.

◆ draw_text() [5/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
matrix3 const & transform,
quad_color const & color,
text_shaper const & text ) 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.
colorText-color overriding the colors from the shaped_text.
textThe shaped text to draw.

◆ draw_text() [6/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
matrix3 const & transform,
shaped_text const & text ) 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.

◆ draw_text() [7/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
matrix3 const & transform,
text_shaper const & text ) 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.

◆ draw_text() [8/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
quad_color const & color,
text_shaper const & text ) const
inlinenoexcept

Draw shaped text.

Parameters
layoutThe layout to use, specifically the to_window transformation matrix and the clipping rectangle.
colorText-color overriding the colors from the shaped_text.
textThe shaped text to draw.

◆ draw_text() [9/9]

void v1::draw_context::draw_text ( widget_layout const & layout,
text_shaper const & text ) 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.

◆ draw_text_cursors()

void v1::draw_context::draw_text_cursors ( widget_layout const & layout,
text_shaper const & text,
text_cursor cursor,
hi::color primary_color,
hi::color secondary_color,
bool overwrite_mode,
bool dead_character_mode ) 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.
primary_colorThe color of the primary cursor (the insertion cursor).
secondary_colorThe color of the secondary cursor (the append 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.

◆ draw_text_selection()

void v1::draw_context::draw_text_selection ( widget_layout const & layout,
text_shaper const & text,
text_selection const & selection,
hi::color color ) 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.
colorThe color of the selection.

◆ make_hole()

void v1::draw_context::make_hole ( widget_layout const & layout,
quad const & box ) 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.

◆ operator bool()

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

Check if the draw_context should be used for rendering.

Field Documentation

◆ active

bool v1::draw_context::active

Window is active.

◆ background_color

color v1::draw_context::background_color

The background color to clear the window with.

◆ display_time_point

utc_nanoseconds v1::draw_context::display_time_point

The time when the drawing will appear on the screen.

◆ frame_buffer_index

std::size_t v1::draw_context::frame_buffer_index

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

◆ saturation

float v1::draw_context::saturation

The tone-mapper's saturation.

◆ scissor_rectangle

aarectangle v1::draw_context::scissor_rectangle

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

◆ subpixel_orientation

hi::subpixel_orientation v1::draw_context::subpixel_orientation

The subpixel orientation for rendering glyphs.


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