mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-14 11:34:58 +00:00
GUI2/Styled Widget: initialize canvases using range ctor
Also adds a proper move assignment operator to canvas. styled_widget::set_config was removed since it's not needed as of dfa09cd9d9
.
This commit is contained in:
parent
f111ab1f7b
commit
1e833ba094
|
@ -552,7 +552,7 @@ void text_shape::draw(wfl::map_formula_callable& variables)
|
|||
|
||||
/***** ***** ***** ***** ***** CANVAS ***** ***** ***** ***** *****/
|
||||
|
||||
canvas::canvas()
|
||||
canvas::canvas(const config& cfg)
|
||||
: shapes_()
|
||||
, blur_depth_(0)
|
||||
, blur_region_(sdl::empty_rect)
|
||||
|
@ -562,18 +562,7 @@ canvas::canvas()
|
|||
, variables_()
|
||||
, functions_()
|
||||
{
|
||||
}
|
||||
|
||||
canvas::canvas(canvas&& c) noexcept
|
||||
: shapes_(std::move(c.shapes_))
|
||||
, blur_depth_(c.blur_depth_)
|
||||
, blur_region_(c.blur_region_)
|
||||
, deferred_(c.deferred_)
|
||||
, w_(c.w_)
|
||||
, h_(c.h_)
|
||||
, variables_(c.variables_)
|
||||
, functions_(c.functions_)
|
||||
{
|
||||
parse_cfg(cfg);
|
||||
}
|
||||
|
||||
// It would be better if the blur effect was managed at a higher level.
|
||||
|
|
|
@ -83,10 +83,13 @@ public:
|
|||
bool immutable_;
|
||||
};
|
||||
|
||||
canvas();
|
||||
explicit canvas(const config& cfg);
|
||||
|
||||
canvas(const canvas&) = delete;
|
||||
canvas& operator=(const canvas&) = delete;
|
||||
canvas(canvas&& c) noexcept;
|
||||
|
||||
canvas(canvas&& c) noexcept = default;
|
||||
canvas& operator=(canvas&&) noexcept = default;
|
||||
|
||||
/**
|
||||
* Update the background blur texture, if relevant and necessary.
|
||||
|
|
|
@ -38,6 +38,12 @@ struct state_definition
|
|||
explicit state_definition(const config& cfg);
|
||||
|
||||
config canvas_cfg_;
|
||||
|
||||
/** Allows us to use this object in vector's range constructor */
|
||||
operator const config&() const
|
||||
{
|
||||
return canvas_cfg_;
|
||||
}
|
||||
};
|
||||
|
||||
struct resolution_definition
|
||||
|
|
|
@ -53,22 +53,12 @@ styled_widget::styled_widget(const implementation::builder_styled_widget& builde
|
|||
, tooltip_(builder.tooltip)
|
||||
, help_message_(builder.help)
|
||||
, config_(get_control(control_type, definition_))
|
||||
, canvases_(config_->state.size()) // One canvas per state
|
||||
, canvases_(config_->state.begin(), config_->state.end())
|
||||
, renderer_()
|
||||
, text_alignment_(PANGO_ALIGN_LEFT)
|
||||
, text_ellipse_mode_(PANGO_ELLIPSIZE_END)
|
||||
, shrunken_(false)
|
||||
{
|
||||
/*
|
||||
* Fill in each canvas from the widget state definitons.
|
||||
*
|
||||
* Most widgets have a single canvas. However, some widgets such as toggle_panel
|
||||
* and toggle_button have a variable canvas count determined by their definitions.
|
||||
*/
|
||||
for(unsigned i = 0; i < config_->state.size(); ++i) {
|
||||
canvases_[i].set_shapes(config_->state[i].canvas_cfg_);
|
||||
}
|
||||
|
||||
// Initialize all the canvas variables.
|
||||
update_canvas();
|
||||
|
||||
|
|
|
@ -306,11 +306,6 @@ protected:
|
|||
return std::static_pointer_cast<const typename T::resolution>(get_config());
|
||||
}
|
||||
|
||||
void set_config(resolution_definition_ptr config)
|
||||
{
|
||||
config_ = std::move(config);
|
||||
}
|
||||
|
||||
/***** ***** ***** ***** miscellaneous ***** ***** ***** *****/
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user