A simple canvas which can be drawn upon. More...
#include <canvas.hpp>
Classes | |
class | shape |
Abstract base class for all other shapes. More... | |
Public Types | |
typedef std::shared_ptr< shape > | shape_ptr |
typedef std::shared_ptr< const shape > | const_shape_ptr |
Public Member Functions | |
canvas () | |
canvas (const canvas &)=delete | |
canvas (canvas &&c) noexcept | |
~canvas () | |
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, const bool force=false) |
Sets the config. More... | |
void | append_cfg (const config &cfg) |
Appends data to the config. More... | |
void | set_width (const unsigned width) |
unsigned | get_width () const |
void | set_height (const unsigned height) |
unsigned | get_height () const |
surface & | surf () |
void | set_variable (const std::string &key, const wfl::variant &value) |
void | set_is_dirty (const bool is_dirty) |
Private Member Functions | |
void | parse_cfg (const config &cfg) |
Parses a config object. More... | |
void | clear_shapes (const bool force) |
void | invalidate_cache () |
Private Attributes | |
std::vector< shape_ptr > | shapes_ |
Vector with the shapes to draw. More... | |
std::vector< shape_ptr > | drawn_shapes_ |
All shapes which have been already drawn. 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... | |
SDL_Renderer * | renderer_ |
wfl::map_formula_callable | variables_ |
The variables of the canvas. More... | |
wfl::action_function_symbol_table | functions_ |
Action function definitions for the canvas. More... | |
bool | is_dirty_ |
The dirty state of the canvas. More... | |
A simple canvas which can be drawn upon.
The class has a config which contains what to draw.
The copy constructor does a shallow copy of the shapes to draw. a clone() will be implemented if really needed.
Definition at line 41 of file canvas.hpp.
typedef std::shared_ptr<const shape> gui2::canvas::const_shape_ptr |
Definition at line 88 of file canvas.hpp.
typedef std::shared_ptr<shape> gui2::canvas::shape_ptr |
Definition at line 87 of file canvas.hpp.
gui2::canvas::canvas | ( | ) |
Definition at line 799 of file canvas.cpp.
|
delete |
|
noexcept |
Definition at line 813 of file canvas.cpp.
gui2::canvas::~canvas | ( | ) |
Definition at line 827 of file canvas.cpp.
References renderer_.
|
inline |
Appends data to the config.
cfg | The config object with the data to draw. |
Definition at line 133 of file canvas.hpp.
Referenced by gui2::dialogs::story_viewer::draw_floating_image().
void gui2::canvas::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.
surf | The surface to blit upon. |
rect | The place to blit to. |
Definition at line 878 of file canvas.cpp.
References blur_depth_, blur_surface(), canvas_, draw(), CVideo::get_singleton(), get_surface_portion(), surface::is_neutral(), s, and sdl_blit().
Referenced by gui2::panel::impl_draw_background(), gui2::styled_widget::impl_draw_background(), and gui2::panel::impl_draw_foreground().
|
private |
Definition at line 948 of file canvas.cpp.
References drawn_shapes_, s, and shapes_.
void gui2::canvas::draw | ( | const bool | force = false | ) |
Draws the canvas.
force | If the canvas isn't dirty it isn't redrawn unless force is set to true. |
Definition at line 833 of file canvas.cpp.
References wfl::map_formula_callable::add(), canvas_, DBG_GUI_D, gui2::canvas::shape::draw(), drawn_shapes_, gui2::get_screen_size_variables(), h_, is_dirty_, gui2::log_gui_draw, log_scope2, renderer_, shapes_, variables_, and w_.
Referenced by blit().
|
inline |
Definition at line 159 of file canvas.hpp.
|
inline |
Definition at line 147 of file canvas.hpp.
References w_.
|
private |
Definition at line 964 of file canvas.cpp.
References canvas_, drawn_shapes_, and shapes_.
|
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.
cfg | The config object with the data to draw, see GUICanvasWML |
Definition at line 902 of file canvas.cpp.
References config::all_children_range(), blur_depth_, DBG_GUI_P, ERR_GUI_P, functions_, gui2::log_gui_parse, log_scope2, and shapes_.
|
inline |
Sets the config.
cfg | The config object with the data to draw. |
force | Whether to clear all shapes or not. |
Definition at line 121 of file canvas.hpp.
Referenced by gui2::dialogs::story_viewer::display_part().
|
inline |
Definition at line 152 of file canvas.hpp.
Referenced by gui2::styled_widget::place().
|
inline |
Definition at line 176 of file canvas.hpp.
Referenced by gui2::dialogs::story_viewer::display_part(), gui2::dialogs::outro::draw_callback(), and gui2::dialogs::story_viewer::draw_floating_image().
|
inline |
Definition at line 169 of file canvas.hpp.
Referenced by gui2::dialogs::story_viewer::display_part(), gui2::dialogs::outro::draw_callback(), gui2::dialogs::attack_predictions::draw_hp_graph(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::outro::pre_show(), gui2::dialogs::title_screen::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::wml_message_double::pre_show(), gui2::toggle_button::update_canvas(), gui2::styled_widget::update_canvas(), and gui2::dialogs::debug_clock::update_time().
|
inline |
Definition at line 140 of file canvas.hpp.
References w_.
Referenced by gui2::styled_widget::place().
|
inline |
Definition at line 164 of file canvas.hpp.
|
private |
The depth of the blur to use in the pre committing.
Definition at line 197 of file canvas.hpp.
Referenced by blit(), and parse_cfg().
|
private |
The surface we draw all items on.
Definition at line 206 of file canvas.hpp.
Referenced by blit(), draw(), and invalidate_cache().
|
private |
All shapes which have been already drawn.
Kept around in case the cache needs to be invalidated.
Definition at line 187 of file canvas.hpp.
Referenced by clear_shapes(), draw(), and invalidate_cache().
|
private |
Action function definitions for the canvas.
Definition at line 214 of file canvas.hpp.
Referenced by parse_cfg().
|
private |
|
private |
|
private |
Definition at line 208 of file canvas.hpp.
|
private |
Vector with the shapes to draw.
Definition at line 183 of file canvas.hpp.
Referenced by clear_shapes(), draw(), invalidate_cache(), and parse_cfg().
|
private |
|
private |