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

#include <TTauri/GUI/DrawContext.hpp>

Public Member Functions

 DrawContext (Window &window, vspan< PipelineFlat::Vertex > &flatVertices, vspan< PipelineBox::Vertex > &boxVertices, vspan< PipelineImage::Vertex > &imageVertices, vspan< PipelineSDF::Vertex > &sdfVertices) noexcept
 
 DrawContext (DrawContext const &rhs) noexcept=default
 
 DrawContext (DrawContext &&rhs) noexcept=default
 
DrawContextoperator= (DrawContext const &rhs) noexcept=default
 
DrawContextoperator= (DrawContext &&rhs) noexcept=default
 
Windowwindow () const noexcept
 
GUIDevicedevice () const noexcept
 
void drawFilledQuad (vec p1, vec p2, vec p3, vec p4) const noexcept
 Draw a polygon with four corners of one color.
 
void drawFilledQuad (aarect r) const noexcept
 Draw a rectangle of one color.
 
void drawBox (aarect box) const noexcept
 Draw an axis aligned box This function will draw the given box.
 
void drawBoxIncludeBorder (aarect box) const noexcept
 Draw an axis aligned box This function will shrink to include the size of the border within the given rectangle.
 
void drawImage (PipelineImage::Image &image) const noexcept
 Draw an image This function will draw an image.
 
void drawText (ShapedText const &text) const noexcept
 Draw shaped text.
 
void drawTextSingleColor (ShapedText const &text) const noexcept
 Draw shaped text.
 
void drawGlyph (FontGlyphIDs const &glyph, aarect box) const noexcept
 

Data Fields

vec color = vec::color(1.0, 1.0, 1.0, 1.0)
 Foreground color.
 
vec fillColor = vec::color(0.0, 0.0, 0.0, 0.0)
 Fill color.
 
float lineWidth = 1.0
 Size of lines.
 
vec cornerShapes = vec{0.0, 0.0, 0.0, 0.0}
 Shape of the corners of a box.
 
aarect clippingRectangle
 The clipping rectangle when drawing.
 
mat transform = mat::I()
 Transform used on the given coordinates.
 

Detailed Description

Draw context for drawing using the TTauri shaders.

Member Function Documentation

◆ drawBox()

void tt::DrawContext::drawBox ( 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

◆ drawBoxIncludeBorder()

void tt::DrawContext::drawBoxIncludeBorder ( aarect box) const
inlinenoexcept

Draw an axis aligned box This function will shrink to include the size of the border within 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

◆ drawFilledQuad() [1/2]

void tt::DrawContext::drawFilledQuad ( 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

◆ drawFilledQuad() [2/2]

void tt::DrawContext::drawFilledQuad ( vec p1,
vec p2,
vec p3,
vec 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

◆ drawImage()

void tt::DrawContext::drawImage ( PipelineImage::Image & image) const
inlinenoexcept

Draw an image This function will draw an image.

This will use the current:

  • transform, to transform the image.
  • clippingRectangle

◆ drawText()

void tt::DrawContext::drawText ( ShapedText const & text) 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

◆ drawTextSingleColor()

void tt::DrawContext::drawTextSingleColor ( ShapedText const & text) 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

Field Documentation

◆ clippingRectangle

aarect tt::DrawContext::clippingRectangle

The clipping rectangle when drawing.

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

◆ color

vec tt::DrawContext::color = vec::color(1.0, 1.0, 1.0, 1.0)

Foreground color.

◆ cornerShapes

vec tt::DrawContext::cornerShapes = vec{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

◆ fillColor

vec tt::DrawContext::fillColor = vec::color(0.0, 0.0, 0.0, 0.0)

Fill color.

◆ lineWidth

float tt::DrawContext::lineWidth = 1.0

Size of lines.

◆ transform

mat tt::DrawContext::transform = mat::I()

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: