Vivoe Lite 0.5.0
Lightweight GVA like HMI for military displays.
Loading...
Searching...
No Matches
gva::RendererCairo Class Reference

Class definition of the Renderer Cairo. More...

#include <renderer_cairo.h>

Inheritance diagram for gva::RendererCairo:
Inheritance graph
Collaboration diagram for gva::RendererCairo:
Collaboration graph

Public Member Functions

 RendererCairo (uint32_t width, uint32_t height)
 Construct a new Renderer Cairo object.
 
 ~RendererCairo () override
 Destroy the Renderer Cairo object.
 
HandleTypeInit (uint32_t width, uint32_t height, bool fullscreen=false)
 Initalise the renderer with display parameters.
 
void SetPixel (uint32_t x, uint32_t y) override
 
void SetColour (uint8_t red, uint8_t green, uint8_t blue) override
 Set the Colour object.
 
void SetColour (uint32_t rgb)
 Set the Colour object.
 
void SetColourForeground (ColourType colour)
 Set the Colour Foreground object.
 
void SetColourForeground (uint8_t red, uint8_t green, uint8_t blue) override
 Set the Colour Foreground object.
 
void SetColourForeground (uint32_t rgb)
 Set the Colour Foreground object.
 
void SetColourBackground (ColourType colour)
 Set the Colour Background attribute.
 
void SetColourBackground (uint8_t red, uint8_t green, uint8_t blue) override
 Set the Colour Background object.
 
void SetColourBackground (uint32_t rgb)
 Set the Colour Background object.
 
void SetLineType (uint32_t type)
 Set the Line Type object.
 
void SetLineThickness (uint32_t thickness, LineType fill)
 Set the Line Thickness object.
 
void SetLineThickness (uint32_t thickness, LineType fill, LineCapEnd end)
 Set the Line Thickness object.
 
uint32_t MovePen (int32_t x, int32_t y)
 
uint32_t DrawPen (uint32_t x, uint32_t y, bool close)
 
uint32_t DrawPen (uint32_t x, uint32_t y)
 
uint32_t MovePenRaw (int32_t x, int32_t y)
 
uint32_t DrawPenRaw (int32_t x, int32_t y)
 
void DrawArcRaw (uint32_t x, uint32_t y, uint32_t radius, uint32_t angle1, uint32_t angle2)
 
uint32_t DrawLine (uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) override
 
void Save ()
 Save the current state of the renderer.
 
void Restore ()
 Restore the last saved state of the renderer.
 
void Scale (double x, double y)
 Scale the renderer.
 
void Translate (uint32_t x, uint32_t y)
 Translate the renderer.
 
void Rotate (double radians)
 Rotate the renderer.
 
uint32_t ClosePath (bool fill)
 Close drawing path.
 
void DrawCircle (uint32_t x, uint32_t y, uint32_t radius, bool fill) override
 Draw a circle.
 
void DrawRectangle (uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool fill) override
 Draw a rectangle.
 
void DrawRoundedRectangle (uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t corner, bool fill)
 Draw a rounded rectangle.
 
void DrawTriangle (uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3, bool fill)
 Draw a triangle.
 
uint32_t DrawColor (ColourType colour)
 Set the Colour object to draw with.
 
uint32_t DrawColor (uint8_t r, uint8_t g, uint8_t b) override
 Set the Colour object to draw with.
 
uint32_t CurveTo (uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, uint32_t x3, uint32_t y3)
 Adds a cubic Bézier spline to the path from the current point to position (x3 , y3 ) in user-space coordinates, using (x1 , y1 ) and (x2 , y2 ) as the control points. After this call the current point will be (x3 , y3 ).
 
uint32_t DrawColor (uint32_t rgb)
 Set the draw colour.
 
void SetTextFont (uint32_t slope, widget::WeightType weight, std::string_view font_name, double size)
 Set the Text Font object.
 
void Push ()
 Push the current state of the renderer.
 
void Pop ()
 Pop the last saved state of the renderer.
 
uint32_t GetTextWidth (std::string_view str, uint32_t fontSize) const
 Get the Text Width object.
 
uint32_t GetTextHeight (std::string_view str, uint32_t fontSize) const
 Get the Text Height object.
 
void DrawString (uint32_t x, uint32_t y, std::string_view text)
 Draw some text on the screen.
 
void DrawLabel (uint32_t x, uint32_t y, std::string_view text)
 Draw an on screen label.
 
void DrawTextCentre (uint32_t x, std::string_view text, uint32_t size)
 Draw some text on the screen and centre it.
 
uint32_t TextureRGB (uint32_t x, uint32_t y, unsigned char *buffer, std::string_view file) override
 Set a texture (file) to use as a bitmap.
 
uint32_t TextureRGB (uint32_t x, uint32_t y, unsigned char *buffer)
 Set a texture (file) to use as a bitmap.
 
uint32_t TextureRGB (uint32_t x, uint32_t y, cairo_surface_t *surface)
 Set a texture (cairo surface) to use as a bitmap.
 
void Draw ()
 Redraw the screen.
 
void Reset ()
 Redraw the screen.
 
void SetHeight (uint32_t height) const
 Set the Height object.
 
void SetWidth (uint32_t width) const
 Set the Width object.
 
uint32_t GetHeight () const
 Get the Height object.
 
uint32_t GetWidth () const
 Get the Width object.
 
void SetSurface (cairo_surface_t *surface)
 Set the Surface attribute, used by application.
 
void DrawSurface (cairo_t *cr)
 Draw the new cairo surface to the screen.
 
void Configure (uint32_t height, uint32_t width)
 Configure the surface to use new dimensions.
 
- Public Member Functions inherited from gva::Renderer
 Renderer (uint32_t width, uint32_t height)
 Construct a new Renderer object.
 
virtual ~Renderer ()=default
 Destroy the Renderer object.
 
uint32_t UnpackRed (uint32_t rgb) const
 Unpack a red value.
 
uint32_t UnpackGreen (uint32_t rgb) const
 Unpack a green value.
 
uint32_t UnpackBlue (uint32_t rgb) const
 Unpack a blue value.
 
RgbUnpackedType UnpackRgb (uint64_t rgb) const
 Unpack red, green and blue values.
 

Static Public Member Functions

static void DestroySurface ()
 Destroy the current cairo surface, usually called during shutdown.
 
- Static Public Member Functions inherited from gva::Renderer
static uint32_t GetWidth ()
 Get the Width attribute.
 
static uint32_t GetHeight ()
 Get the Height attribute.
 
static void SetWidth (uint32_t width)
 Set the Width attribute.
 
static void SetHeight (uint32_t height)
 Set the Height attribute.
 
static uint32_t PackRgb (ColourType colour)
 Pack the colour to RGB.
 
static uint32_t PackRgb (uint8_t r, uint8_t g, uint8_t b)
 Pack three red, green, blue values.
 

Static Public Attributes

static HandleType render_
 Class definition of the HandleType.
 

Additional Inherited Members

- Static Protected Attributes inherited from gva::Renderer
static uint32_t height_ = kMinimumHeight
 The height of the renderer.
 
static uint32_t width_ = kMinimumWidth
 The width of the renderer.
 

Detailed Description

Class definition of the Renderer Cairo.

Constructor & Destructor Documentation

◆ RendererCairo()

gva::RendererCairo::RendererCairo ( uint32_t  width,
uint32_t  height 
)

Construct a new Renderer Cairo object.

Parameters
width
height

Member Function Documentation

◆ ClosePath()

uint32_t gva::RendererCairo::ClosePath ( bool  fill)

Close drawing path.

Parameters
fillFill if true
Returns
uint32_t

◆ Configure()

void gva::RendererCairo::Configure ( uint32_t  height,
uint32_t  width 
)

Configure the surface to use new dimensions.

Parameters
height
width

◆ CurveTo()

uint32_t gva::RendererCairo::CurveTo ( uint32_t  x1,
uint32_t  y1,
uint32_t  x2,
uint32_t  y2,
uint32_t  x3,
uint32_t  y3 
)

Adds a cubic Bézier spline to the path from the current point to position (x3 , y3 ) in user-space coordinates, using (x1 , y1 ) and (x2 , y2 ) as the control points. After this call the current point will be (x3 , y3 ).

Parameters
x1first point of x in pixels
y1first point of y in pixels
x2second point of x in pixels
y2second point of y in pixels
x3third point of x in pixels
y3third point of y in pixels
Returns
uint32_t

◆ DrawArcRaw()

void gva::RendererCairo::DrawArcRaw ( uint32_t  x,
uint32_t  y,
uint32_t  radius,
uint32_t  angle1,
uint32_t  angle2 
)
Parameters
x
y
radius
angle1
angle2

◆ DrawCircle()

void gva::RendererCairo::DrawCircle ( uint32_t  x,
uint32_t  y,
uint32_t  radius,
bool  fill 
)
overridevirtual

Draw a circle.

Parameters
xThe x position
yThe y position
radiusThe radius in pixels
fillFill if true

Implements gva::Renderer.

◆ DrawColor() [1/3]

uint32_t gva::RendererCairo::DrawColor ( ColourType  colour)

Set the Colour object to draw with.

Parameters
colourThe colour to draw with
Returns
uint32_t

◆ DrawColor() [2/3]

uint32_t gva::RendererCairo::DrawColor ( uint32_t  rgb)

Set the draw colour.

Parameters
rgbThe colour to draw with, packed RGB
Returns
uint32_t

◆ DrawColor() [3/3]

uint32_t gva::RendererCairo::DrawColor ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
overridevirtual

Set the Colour object to draw with.

Parameters
rThe red value
gThe green value
bThe blue value
Returns
uint32_t

Implements gva::Renderer.

◆ DrawLabel()

void gva::RendererCairo::DrawLabel ( uint32_t  x,
uint32_t  y,
std::string_view  text 
)

Draw an on screen label.

Parameters
xaxis pixel postion
yaxis pixel postion
text

◆ DrawLine()

uint32_t gva::RendererCairo::DrawLine ( uint32_t  x1,
uint32_t  y1,
uint32_t  x2,
uint32_t  y2 
)
overridevirtual
Parameters
x1
y1
x2
y2
Returns
uint32_t

Implements gva::Renderer.

◆ DrawPen() [1/2]

uint32_t gva::RendererCairo::DrawPen ( uint32_t  x,
uint32_t  y 
)
inline
Parameters
x
y
Returns
uint32_t

◆ DrawPen() [2/2]

uint32_t gva::RendererCairo::DrawPen ( uint32_t  x,
uint32_t  y,
bool  close 
)
Parameters
x
y
close
Returns
uint32_t

◆ DrawPenRaw()

uint32_t gva::RendererCairo::DrawPenRaw ( int32_t  x,
int32_t  y 
)
Parameters
x
y
Returns
uint32_t

◆ DrawRectangle()

void gva::RendererCairo::DrawRectangle ( uint32_t  x,
uint32_t  y,
uint32_t  width,
uint32_t  height,
bool  fill 
)
overridevirtual

Draw a rectangle.

Parameters
xThe x position
yThe y position
widthThe width in pixels
heightThe height in pixels
fillFill if true

Implements gva::Renderer.

◆ DrawRoundedRectangle()

void gva::RendererCairo::DrawRoundedRectangle ( uint32_t  x,
uint32_t  y,
uint32_t  width,
uint32_t  height,
uint32_t  corner,
bool  fill 
)

Draw a rounded rectangle.

Parameters
xThe x position
yThe y position
widthThe width
heightThe height in pixels
cornerThe corner radius
fillFill if true

◆ DrawString()

void gva::RendererCairo::DrawString ( uint32_t  x,
uint32_t  y,
std::string_view  text 
)

Draw some text on the screen.

Parameters
xaxis pixel postion
yaxis pixel postion
text

◆ DrawSurface()

void gva::RendererCairo::DrawSurface ( cairo_t *  cr)

Draw the new cairo surface to the screen.

Returns
gboolean

◆ DrawTextCentre()

void gva::RendererCairo::DrawTextCentre ( uint32_t  x,
std::string_view  text,
uint32_t  size 
)

Draw some text on the screen and centre it.

Parameters
xaxis pixel postion
textto draw
sizeof the text

◆ DrawTriangle()

void gva::RendererCairo::DrawTriangle ( uint32_t  x1,
uint32_t  y1,
uint32_t  x2,
uint32_t  y2,
uint32_t  x3,
uint32_t  y3,
bool  fill 
)

Draw a triangle.

Parameters
x1The first x position
y1The first y position
x2The second x position
y2The second y position
x3The third x position
y3The third y position
fillFill if true

◆ GetHeight()

uint32_t gva::RendererCairo::GetHeight ( ) const
inline

Get the Height object.

Returns
uint32_t

◆ GetTextHeight()

uint32_t gva::RendererCairo::GetTextHeight ( std::string_view  str,
uint32_t  fontSize 
) const

Get the Text Height object.

Parameters
str
fontSize
Returns
uint32_t

◆ GetTextWidth()

uint32_t gva::RendererCairo::GetTextWidth ( std::string_view  str,
uint32_t  fontSize 
) const

Get the Text Width object.

Parameters
str
fontSize
Returns
uint32_t

◆ GetWidth()

uint32_t gva::RendererCairo::GetWidth ( ) const
inline

Get the Width object.

Returns
uint32_t

◆ Init()

HandleType * gva::RendererCairo::Init ( uint32_t  width,
uint32_t  height,
bool  fullscreen = false 
)

Initalise the renderer with display parameters.

Parameters
widthCanvas width in pixels
heightCanvas height in pixels
fullscreenFullscreen mode when true
Returns
HandleType* a pointer to the renderer handler

◆ MovePen()

uint32_t gva::RendererCairo::MovePen ( int32_t  x,
int32_t  y 
)
Parameters
x
y
Returns
uint32_t

◆ MovePenRaw()

uint32_t gva::RendererCairo::MovePenRaw ( int32_t  x,
int32_t  y 
)
Parameters
x
y
Returns
uint32_t

◆ Rotate()

void gva::RendererCairo::Rotate ( double  radians)

Rotate the renderer.

Parameters
radiansThe angle to rotate by

◆ Scale()

void gva::RendererCairo::Scale ( double  x,
double  y 
)

Scale the renderer.

Parameters
xThe x scale
yThe y scale

◆ SetColour() [1/2]

void gva::RendererCairo::SetColour ( uint32_t  rgb)

Set the Colour object.

Parameters
rgb

◆ SetColour() [2/2]

void gva::RendererCairo::SetColour ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)
overridevirtual

Set the Colour object.

Parameters
red
green
blue

Implements gva::Renderer.

◆ SetColourBackground() [1/3]

void gva::RendererCairo::SetColourBackground ( ColourType  colour)

Set the Colour Background attribute.

Parameters
colour

◆ SetColourBackground() [2/3]

void gva::RendererCairo::SetColourBackground ( uint32_t  rgb)

Set the Colour Background object.

Parameters
rgb

◆ SetColourBackground() [3/3]

void gva::RendererCairo::SetColourBackground ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)
overridevirtual

Set the Colour Background object.

Parameters
red
green
blue

Implements gva::Renderer.

◆ SetColourForeground() [1/3]

void gva::RendererCairo::SetColourForeground ( ColourType  colour)

Set the Colour Foreground object.

Parameters
colourThe colour to set

◆ SetColourForeground() [2/3]

void gva::RendererCairo::SetColourForeground ( uint32_t  rgb)

Set the Colour Foreground object.

Parameters
rgb

◆ SetColourForeground() [3/3]

void gva::RendererCairo::SetColourForeground ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)
overridevirtual

Set the Colour Foreground object.

Parameters
red
green
blue

Implements gva::Renderer.

◆ SetHeight()

void gva::RendererCairo::SetHeight ( uint32_t  height) const
inline

Set the Height object.

Parameters
height

◆ SetLineThickness() [1/2]

void gva::RendererCairo::SetLineThickness ( uint32_t  thickness,
LineType  fill 
)

Set the Line Thickness object.

Parameters
thickness
fill

◆ SetLineThickness() [2/2]

void gva::RendererCairo::SetLineThickness ( uint32_t  thickness,
LineType  fill,
LineCapEnd  end 
)

Set the Line Thickness object.

Parameters
thickness
fill
end

◆ SetLineType()

void gva::RendererCairo::SetLineType ( uint32_t  type)

Set the Line Type object.

Parameters
type

◆ SetPixel()

void gva::RendererCairo::SetPixel ( uint32_t  x,
uint32_t  y 
)
overridevirtual
Parameters
x
y

Implements gva::Renderer.

◆ SetSurface()

void gva::RendererCairo::SetSurface ( cairo_surface_t *  surface)

Set the Surface attribute, used by application.

Parameters
surface

◆ SetTextFont()

void gva::RendererCairo::SetTextFont ( uint32_t  slope,
widget::WeightType  weight,
std::string_view  font_name,
double  size 
)

Set the Text Font object.

Parameters
slopeThe font slope
weightThe font weight
font_nameThe font name
sizeThe font size

◆ SetWidth()

void gva::RendererCairo::SetWidth ( uint32_t  width) const
inline

Set the Width object.

Parameters
width

◆ TextureRGB() [1/3]

uint32_t gva::RendererCairo::TextureRGB ( uint32_t  x,
uint32_t  y,
cairo_surface_t *  surface 
)

Set a texture (cairo surface) to use as a bitmap.

Parameters
xaxis pixel postion
yaxis pixel postion
surfaceto load the image into
Returns
uint32_t the texture id

◆ TextureRGB() [2/3]

uint32_t gva::RendererCairo::TextureRGB ( uint32_t  x,
uint32_t  y,
unsigned char *  buffer 
)

Set a texture (file) to use as a bitmap.

Parameters
xaxis pixel postion
yaxis pixel postion
bufferto load the image into
Returns
uint32_t the texture id

◆ TextureRGB() [3/3]

uint32_t gva::RendererCairo::TextureRGB ( uint32_t  x,
uint32_t  y,
unsigned char *  buffer,
std::string_view  file 
)
overridevirtual

Set a texture (file) to use as a bitmap.

Parameters
xaxis pixel postion
yaxis pixel postion
bufferunused when file set
fileto load
Returns
uint32_t the texture id

Implements gva::Renderer.

◆ Translate()

void gva::RendererCairo::Translate ( uint32_t  x,
uint32_t  y 
)

Translate the renderer.

Parameters
xThe x position to translate to
yThe y position to translate to

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