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

#include <ttauri/GUI/draw_context.hpp>

Public Member Functions

 draw_context (gui_window &window, aarect scissor_rectangle, vspan< pipeline_flat::vertex > &flatVertices, vspan< pipeline_box::vertex > &boxVertices, vspan< pipeline_image::vertex > &imageVertices, vspan< pipeline_SDF::vertex > &sdfVertices) noexcept
 
 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
 
gui_windowwindow () const noexcept
 
gui_devicedevice () const noexcept
 
void draw_filled_quad (f32x4 p1, f32x4 p2, f32x4 p3, f32x4 p4) const noexcept
 Draw a polygon with four corners of one color.
 
void draw_filled_quad (aarect r) const noexcept
 Draw a rectangle of one color.
 
void draw_box (aarect box) const noexcept
 Draw an axis aligned box This function will draw the given box.
 
void draw_box_with_border_inside (aarect rectangle) const noexcept
 Draw an axis aligned box This function will shrink to include the size of the border inside the given rectangle.
 
void draw_box_with_border_outside (aarect rectangle) const noexcept
 Draw an axis aligned box This function will expand to include the size of the border outside the given rectangle.
 
void draw_image (pipeline_image::Image &image) const noexcept
 Draw an image This function will draw an image.
 
void draw_text (shaped_text const &text, bool useContextColor=false) const noexcept
 Draw shaped text.
 
void draw_glyph (font_glyph_ids const &glyph, aarect box) const noexcept
 

Data Fields

color line_color = color(1.0, 1.0, 1.0, 1.0)
 Foreground color.
 
color fill_color = color(0.0, 0.0, 0.0, 0.0)
 Fill color.
 
float line_width = 1.0
 Size of lines.
 
f32x4 corner_shapes = f32x4{0.0, 0.0, 0.0, 0.0}
 Shape of the corners of a box.
 
aarect clipping_rectangle
 The clipping rectangle when drawing.
 
matrix3 transform = geo::identity{}
 Transform used on the given coordinates.
 
aarect _scissor_rectangle
 

Friends

bool overlaps (draw_context const &context, aarect const &rectangle) noexcept
 

Detailed Description

Draw context for drawing using the TTauri shaders.

Member Function Documentation

◆ draw_box()

void tt::draw_context::draw_box ( aarect box) const
inlinenoexcept

Draw an axis aligned box This function will draw the given box.

This will use the current:

  • transform, to transform the opposite corner (rotation is not recommended).
  • clippingRectangle
  • fillColor
  • borderSize
  • borderColor
  • shadowSize
  • cornerShapes

◆ draw_box_with_border_inside()

void tt::draw_context::draw_box_with_border_inside ( aarect rectangle) const
inlinenoexcept

Draw an axis aligned box This function will shrink to include the size of the border inside the given rectangle.

This will make the border be drawn sharply.

This will also adjust rounded corners to the shrunk box.

This function will draw the given box. This will use the current:

  • transform, to transform the opposite corner (rotation is not recommended).
  • clipping_rectangle
  • fill_color
  • border_size
  • border_color
  • corner_shapes

◆ draw_box_with_border_outside()

void tt::draw_context::draw_box_with_border_outside ( aarect rectangle) const
inlinenoexcept

Draw an axis aligned box This function will expand to include the size of the border outside the given rectangle.

This will make the border be drawn sharply.

This will also adjust rounded corners to the shrunk box.

This function will draw the given box. This will use the current:

  • transform, to transform the opposite corner (rotation is not recommended).
  • clippingRectangle
  • fillColor
  • borderSize
  • borderColor
  • shadowSize
  • cornerShapes

◆ draw_filled_quad() [1/2]

void tt::draw_context::draw_filled_quad ( aarect r) const
inlinenoexcept

Draw a rectangle of one color.

This function will draw the given rectangle. This will use the current:

  • transform, to transform each corner of the rectangle.
  • clippingRectangle
  • fillColor

◆ draw_filled_quad() [2/2]

void tt::draw_context::draw_filled_quad ( f32x4 p1,
f32x4 p2,
f32x4 p3,
f32x4 p4 ) const
inlinenoexcept

Draw a polygon with four corners of one color.

This function will draw a polygon between the four given points. This will use the current:

  • transform, to transform each point.
  • clippingRectangle
  • fillColor

◆ draw_image()

void tt::draw_context::draw_image ( pipeline_image::Image & image) const
inlinenoexcept

Draw an image This function will draw an image.

This will use the current:

  • transform, to transform the image.
  • clippingRectangle

◆ draw_text()

void tt::draw_context::draw_text ( shaped_text const & text,
bool useContextColor = false ) const
inlinenoexcept

Draw shaped text.

This function will draw the shaped text. The SDF-image-atlas needs to be prepared ahead of time. This will use the current:

  • transform, to transform the shaped-text's bounding box
  • clippingRectangle
Parameters
textThe shaped text to draw.
useContextColorWhen true display the text in the context's color, if false use text style color

Field Documentation

◆ clipping_rectangle

aarect tt::draw_context::clipping_rectangle

The clipping rectangle when drawing.

The clipping rectangle is passes as-is to the pipelines and is not modified by the transform.

◆ corner_shapes

f32x4 tt::draw_context::corner_shapes = f32x4{0.0, 0.0, 0.0, 0.0}

Shape of the corners of a box.

The vector holds information for each corner:

  • x: left-bottom
  • y: right-bottom
  • z: left-top
  • w: right-top

The value means:

  • zero: Sharp corner
  • positive: Rounded corner of that radius
  • negative: Cur corner of that radius

◆ fill_color

color tt::draw_context::fill_color = color(0.0, 0.0, 0.0, 0.0)

Fill color.

◆ line_color

color tt::draw_context::line_color = color(1.0, 1.0, 1.0, 1.0)

Foreground color.

◆ line_width

float tt::draw_context::line_width = 1.0

Size of lines.

◆ transform

matrix3 tt::draw_context::transform = geo::identity{}

Transform used on the given coordinates.

The z-axis translate is used for specifying the elevation (inverse depth buffer) of the shape.


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