The Battle for Wesnoth  1.19.0+dev
Public Member Functions | Private Attributes | List of all members
gui2::line_shape Class Reference

#include <canvas_private.hpp>

Inheritance diagram for gui2::line_shape:

Public Member Functions

 line_shape (const config &cfg)
 Constructor. More...
 
void draw (wfl::map_formula_callable &variables) override
 Draws the canvas. More...
 
- Public Member Functions inherited from gui2::canvas::shape
 shape (const config &cfg)
 
virtual ~shape ()
 
bool immutable () const
 

Private Attributes

typed_formula< unsigned > x1_
 The start x coordinate of the line. More...
 
typed_formula< unsigned > y1_
 The start y coordinate of the line. More...
 
typed_formula< unsigned > x2_
 The end x coordinate of the line. More...
 
typed_formula< unsigned > y2_
 The end y coordinate of the line. More...
 
typed_formula< color_tcolor_
 The color of the line. More...
 
unsigned thickness_
 The thickness of the line. More...
 

Detailed Description

Definition at line 22 of file canvas_private.hpp.

Constructor & Destructor Documentation

◆ line_shape()

gui2::line_shape::line_shape ( const config cfg)
explicit

Constructor.

Parameters
cfgThe config object to define the line.

Definition at line 50 of file canvas.cpp.

References DBG_GUI_P, and debug.

Member Function Documentation

◆ draw()

void gui2::line_shape::draw ( wfl::map_formula_callable variables)
overridevirtual

Draws the canvas.

Parameters
variablesThe canvas can have formulas in it's definition, this parameter contains the values for these formulas.
Todo:
formulas are now recalculated every draw cycle which is a bit silly unless there has been a resize. So to optimize we should use an extra flag or do the calculation in a separate routine.

Implements gui2::canvas::shape.

Definition at line 65 of file canvas.cpp.

References color_, DBG_GUI_D, draw::line(), x1_, x2_, y1_, and y2_.

Member Data Documentation

◆ color_

typed_formula<color_t> gui2::line_shape::color_
private

The color of the line.

Definition at line 41 of file canvas_private.hpp.

Referenced by draw().

◆ thickness_

unsigned gui2::line_shape::thickness_
private

The thickness of the line.

if the value is odd the x and y are the middle of the line. if the value is even the x and y are the middle of a line with width - 1. (0 is special case, does nothing.)

Definition at line 50 of file canvas_private.hpp.

◆ x1_

typed_formula<unsigned> gui2::line_shape::x1_
private

The start x coordinate of the line.

Definition at line 35 of file canvas_private.hpp.

Referenced by draw().

◆ x2_

typed_formula<unsigned> gui2::line_shape::x2_
private

The end x coordinate of the line.

Definition at line 37 of file canvas_private.hpp.

Referenced by draw().

◆ y1_

typed_formula<unsigned> gui2::line_shape::y1_
private

The start y coordinate of the line.

Definition at line 36 of file canvas_private.hpp.

Referenced by draw().

◆ y2_

typed_formula<unsigned> gui2::line_shape::y2_
private

The end y coordinate of the line.

Definition at line 38 of file canvas_private.hpp.

Referenced by draw().


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