A simple canvas which can be drawn upon. More...
#include <canvas.hpp>
Classes | |
class | shape |
Abstract base class for all other shapes. More... | |
Public Member Functions | |
canvas () | |
canvas (const canvas &)=delete | |
canvas & | operator= (const canvas &)=delete |
canvas (canvas &&c) noexcept | |
bool | update_blur (const rect &screen_region, const bool force=false) |
Update the background blur texture, if relevant and necessary. More... | |
void | queue_reblur () |
Clear the cached blur texture, forcing it to regenerate. More... | |
void | draw () |
Draw the canvas' shapes onto the screen. 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 | update_size_variables () |
Update WFL size variables. More... | |
unsigned | get_width () const |
unsigned | get_height () const |
void | set_size (const point &size) |
void | set_variable (const std::string &key, wfl::variant &&value) |
wfl::variant | get_variable (const std::string &key) |
Private Member Functions | |
void | parse_cfg (const config &cfg) |
Parses a config object. More... | |
void | clear_shapes (const bool force) |
Private Attributes | |
std::vector< std::unique_ptr< shape > > | shapes_ |
Vector with the shapes to draw. More... | |
unsigned | blur_depth_ |
The depth of the blur to use in the pre committing. More... | |
texture | blur_texture_ |
Blurred background texture. More... | |
rect | blur_region_ |
The region of the screen we have blurred (if any). More... | |
bool | deferred_ |
Whether we have deferred rendering so we can capture for blur. More... | |
unsigned | w_ |
The full width of the canvas. More... | |
unsigned | h_ |
The full height of the canvas. More... | |
wfl::map_formula_callable | variables_ |
The variables of the canvas. More... | |
wfl::action_function_symbol_table | functions_ |
Action function definitions for 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 44 of file canvas.hpp.
gui2::canvas::canvas | ( | ) |
Definition at line 548 of file canvas.cpp.
|
delete |
|
noexcept |
Definition at line 560 of file canvas.cpp.
|
inline |
Appends data to the config.
cfg | The config object with the data to draw. |
Definition at line 132 of file canvas.hpp.
References parse_cfg().
Referenced by gui2::drawing::append_drawing_data(), and gui2::dialogs::story_viewer::draw_floating_image().
|
private |
Definition at line 716 of file canvas.cpp.
References utils::erase_if(), s, and shapes_.
Referenced by set_cfg().
void gui2::canvas::draw | ( | ) |
Draw the canvas' shapes onto the screen.
It makes sure the image on the canvas is up to date. Also executes the pre-blitting functions.
Definition at line 634 of file canvas.cpp.
References draw::blit(), blur_depth_, blur_texture_, DBG_GUI_D, deferred_, gui2::canvas::shape::draw(), texture::draw_size(), gui2::log_gui_draw, shapes_, and variables_.
Referenced by gui2::panel::impl_draw_background(), gui2::styled_widget::impl_draw_background(), and gui2::panel::impl_draw_foreground().
|
inline |
Definition at line 147 of file canvas.hpp.
References h_.
|
inline |
Definition at line 159 of file canvas.hpp.
References wfl::formula_callable::query_value(), and variables_.
|
inline |
Definition at line 142 of file canvas.hpp.
References w_.
|
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 |
Definition at line 662 of file canvas.cpp.
References config::all_children_view(), blur_depth_, data, DBG_GUI_P, ERR_GUI_P, functions_, gui2::log_gui_parse, log_scope2, and shapes_.
Referenced by append_cfg(), and set_cfg().
void gui2::canvas::queue_reblur | ( | ) |
Clear the cached blur texture, forcing it to regenerate.
Definition at line 629 of file canvas.cpp.
References blur_texture_, and texture::reset().
Referenced by gui2::dialogs::story_viewer::display_part(), and gui2::dialogs::title_screen::show_preferences().
|
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.
References clear_shapes(), and parse_cfg().
Referenced by gui2::dialogs::story_viewer::display_part(), and gui2::drawing::set_drawing_data().
void gui2::canvas::set_size | ( | const point & | size | ) |
Definition at line 709 of file canvas.cpp.
References h_, utf8::size(), update_size_variables(), and w_.
Referenced by gui2::styled_widget::place().
|
inline |
Definition at line 154 of file canvas.hpp.
References wfl::map_formula_callable::add(), and variables_.
Referenced by gui2::dialogs::story_viewer::display_part(), gui2::dialogs::attack_predictions::draw_hp_graph(), gui2::dialogs::title_screen::init_callbacks(), gui2::dialogs::loading_screen::layout(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::wml_message_double::pre_show(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::dialogs::outro::update(), gui2::styled_widget::update_canvas(), gui2::toggle_button::update_canvas(), gui2::dialogs::title_screen::update_static_labels(), and gui2::dialogs::debug_clock::update_time().
bool gui2::canvas::update_blur | ( | const rect & | screen_region, |
const bool | force = false |
||
) |
Update the background blur texture, if relevant and necessary.
This should be called sometime before draw(). Updating it later is less important as it's quite expensive.
screen_region | The area of the screen underneath the canvas. |
force | Regenerate the blur even if we already did it. |
Definition at line 574 of file canvas.cpp.
References blur_depth_, blur_region_, blur_surface(), blur_texture_, DBG_GUI_D, deferred_, video::read_pixels_low_res(), draw_manager::request_extra_render_pass(), texture::reset(), s, draw::set_render_target(), and setter.
void gui2::canvas::update_size_variables | ( | ) |
Update WFL size variables.
Definition at line 702 of file canvas.cpp.
References wfl::map_formula_callable::add(), gui2::get_screen_size_variables(), h_, variables_, and w_.
Referenced by gui2::dialogs::story_viewer::display_part(), gui2::dialogs::story_viewer::draw_floating_image(), set_size(), and gui2::dialogs::outro::update().
|
private |
The depth of the blur to use in the pre committing.
Definition at line 176 of file canvas.hpp.
Referenced by draw(), parse_cfg(), and update_blur().
|
private |
The region of the screen we have blurred (if any).
Definition at line 182 of file canvas.hpp.
Referenced by update_blur().
|
private |
Blurred background texture.
Definition at line 179 of file canvas.hpp.
Referenced by draw(), queue_reblur(), and update_blur().
|
private |
Whether we have deferred rendering so we can capture for blur.
Definition at line 185 of file canvas.hpp.
Referenced by draw(), and update_blur().
|
private |
Action function definitions for the canvas.
Definition at line 197 of file canvas.hpp.
Referenced by parse_cfg().
|
private |
The full height of the canvas.
Definition at line 191 of file canvas.hpp.
Referenced by get_height(), set_size(), and update_size_variables().
|
private |
Vector with the shapes to draw.
Definition at line 166 of file canvas.hpp.
Referenced by clear_shapes(), draw(), and parse_cfg().
|
private |
The variables of the canvas.
Definition at line 194 of file canvas.hpp.
Referenced by draw(), get_variable(), set_variable(), and update_size_variables().
|
private |
The full width of the canvas.
Definition at line 188 of file canvas.hpp.
Referenced by get_width(), set_size(), and update_size_variables().