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

A simple canvas which can be drawn upon. More...

#include <canvas.hpp>

Classes

class  tshape
 Abstract base class for all other shapes. More...
 

Public Types

typedef boost::intrusive_ptr
< tshape
tshape_ptr
 
typedef boost::intrusive_ptr
< const tshape
const_tshape_ptr
 

Public Member Functions

 tcanvas ()
 
void draw (const bool force=false)
 Draws the canvas. More...
 
void blit (surface &surf, SDL_Rect rect)
 Blits the canvas unto another surface. More...
 
void set_cfg (const config &cfg)
 Sets the config. More...
 
void set_width (const unsigned width)
 
unsigned get_width () const
 
void set_height (const unsigned height)
 
unsigned get_height () const
 
surfacesurf ()
 
void set_variable (const std::string &key, const variant &value)
 

Private Member Functions

void set_is_dirty (const bool is_dirty)
 
void parse_cfg (const config &cfg)
 Parses a config object. More...
 

Private Attributes

std::vector< tshape_ptrshapes_
 Vector with the shapes to draw. More...
 
unsigned blur_depth_
 The depth of the blur to use in the pre committing. More...
 
unsigned w_
 Width of the canvas. More...
 
unsigned h_
 Height of the canvas. More...
 
surface canvas_
 The surface we draw all items on. More...
 
game_logic::map_formula_callable variables_
 The variables of the canvas. More...
 
bool is_dirty_
 The dirty state of the canvas. More...
 

Detailed Description

A simple canvas which can be drawn upon.

The class has a config which contains what to draw.

NOTE we might add some caching in a later state, for now every draw cycle does a full redraw.

The copy constructor does a shallow copy of the shapes to draw. a clone() will be implemented if really needed.

Definition at line 44 of file canvas.hpp.

Member Typedef Documentation

Definition at line 75 of file canvas.hpp.

Definition at line 74 of file canvas.hpp.

Constructor & Destructor Documentation

gui2::tcanvas::tcanvas ( )

Definition at line 1456 of file canvas.cpp.

Member Function Documentation

void gui2::tcanvas::blit ( surface surf,
SDL_Rect  rect 
)

Blits the canvas unto another surface.

It makes sure the image on the canvas is up to date. Also executes the pre-blitting functions.

Parameters
surfThe surface to blit upon.
rectThe place to blit to.

Definition at line 1497 of file canvas.cpp.

References blur_depth_, blur_surface(), canvas_, draw(), get_surface_portion(), get_video_surface(), is_neutral(), and sdl_blit().

void gui2::tcanvas::draw ( const bool  force = false)

Draws the canvas.

Parameters
forceIf the canvas isn't dirty it isn't redrawn unless force is set to true.

Definition at line 1467 of file canvas.cpp.

References game_logic::map_formula_callable::add(), surface::assign(), canvas_, create_neutral_surface(), DBG_GUI_D, gui2::get_screen_size_variables(), h_, is_dirty_, itor, gui2::log_gui_draw, log_scope2, shapes_, variables_, and w_.

Referenced by blit().

unsigned gui2::tcanvas::get_height ( ) const
inline

Definition at line 127 of file canvas.hpp.

References h_.

unsigned gui2::tcanvas::get_width ( ) const
inline

Definition at line 117 of file canvas.hpp.

References w_.

void gui2::tcanvas::parse_cfg ( const config cfg)
private

Parses a config object.

The config object is parsed and serialized by this function after which the config object is no longer required and thus not stored in the object.

Parameters
cfgThe config object with the data to draw, see http://www.wesnoth.org/wiki/GUICanvasWML

Definition at line 1521 of file canvas.cpp.

References config::all_children_range(), blur_depth_, DBG_GUI_P, ERR_GUI_P, gui2::log_gui_parse, log_scope2, and shapes_.

Referenced by set_cfg().

void gui2::tcanvas::set_cfg ( const config cfg)
inline

Sets the config.

Parameters
cfgThe config object with the data to draw, see http://www.wesnoth.org/wiki/GUICanvasWML for more information.

Definition at line 105 of file canvas.hpp.

References parse_cfg().

Referenced by gui2::tstate_definition::tstate_definition().

void gui2::tcanvas::set_height ( const unsigned  height)
inline

Definition at line 122 of file canvas.hpp.

References h_, and set_is_dirty().

void gui2::tcanvas::set_is_dirty ( const bool  is_dirty)
inlineprivate

Definition at line 172 of file canvas.hpp.

Referenced by set_height(), set_variable(), and set_width().

void gui2::tcanvas::set_variable ( const std::string key,
const variant value 
)
inline

Definition at line 137 of file canvas.hpp.

References game_logic::map_formula_callable::add(), set_is_dirty(), and variables_.

void gui2::tcanvas::set_width ( const unsigned  width)
inline

Definition at line 112 of file canvas.hpp.

References set_is_dirty(), and w_.

surface& gui2::tcanvas::surf ( )
inline

Definition at line 132 of file canvas.hpp.

References canvas_.

Member Data Documentation

unsigned gui2::tcanvas::blur_depth_
private

The depth of the blur to use in the pre committing.

Note
at the moment there's one pre commit function, namely the blurring so use a variable here, might get more functions in the future. When that happens need to evaluate whether variables are the best thing to use.

Definition at line 155 of file canvas.hpp.

Referenced by blit(), and parse_cfg().

surface gui2::tcanvas::canvas_
private

The surface we draw all items on.

Definition at line 164 of file canvas.hpp.

Referenced by blit(), draw(), and surf().

unsigned gui2::tcanvas::h_
private

Height of the canvas.

Definition at line 161 of file canvas.hpp.

Referenced by draw(), get_height(), and set_height().

bool gui2::tcanvas::is_dirty_
private

The dirty state of the canvas.

Definition at line 170 of file canvas.hpp.

Referenced by draw().

std::vector<tshape_ptr> gui2::tcanvas::shapes_
private

Vector with the shapes to draw.

Definition at line 145 of file canvas.hpp.

Referenced by draw(), and parse_cfg().

game_logic::map_formula_callable gui2::tcanvas::variables_
private

The variables of the canvas.

Definition at line 167 of file canvas.hpp.

Referenced by draw(), and set_variable().

unsigned gui2::tcanvas::w_
private

Width of the canvas.

Definition at line 158 of file canvas.hpp.

Referenced by draw(), get_width(), and set_width().


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