The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | List of all members
gui2::line_shape Class Reference

Definition of a line shape. More...

#include <canvas_private.hpp>

Inheritance diagram for gui2::line_shape:
Inheritance graph

Public Member Functions

 line_shape (const config &cfg)
 Constructor. More...
 
void draw (surface &canvas, SDL_Renderer *renderer, wfl::map_formula_callable &variables) override
 Implement shape::draw(). 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 of a line shape.

Definition at line 21 of file canvas_private.hpp.

Constructor & Destructor Documentation

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

Constructor.

Parameters
cfgThe config object to define the line see http://www.wesnoth.org/wiki/GUICanvasWML#Line for more information.

Definition at line 584 of file canvas.cpp.

References DBG_GUI_P, and debug.

Member Function Documentation

void gui2::line_shape::draw ( surface canvas,
SDL_Renderer *  renderer,
wfl::map_formula_callable variables 
)
overridevirtual

Implement shape::draw().

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 599 of file canvas.cpp.

References _(), color_, DBG_GUI_D, VALIDATE, x1_, x2_, y1_, and y2_.

Member Data Documentation

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

The color of the line.

Definition at line 44 of file canvas_private.hpp.

Referenced by draw().

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 53 of file canvas_private.hpp.

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

The start x coordinate of the line.

Definition at line 38 of file canvas_private.hpp.

Referenced by draw().

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

The end x coordinate of the line.

Definition at line 38 of file canvas_private.hpp.

Referenced by draw().

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

The start y coordinate of the line.

Definition at line 38 of file canvas_private.hpp.

Referenced by draw().

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: