Styled Widget: renamed multi-canvas getter get_canvases()
The single-canvas getter remains, and I deployed it in a few cases where multi-canvas fetching doesn't make sense.
This commit is contained in:
parent
f6408b0736
commit
a4647b5300
13 changed files with 20 additions and 20 deletions
|
@ -149,7 +149,7 @@ void debug_clock::update_time(const bool force)
|
|||
}
|
||||
|
||||
if(clock_) {
|
||||
for(auto & canvas : clock_->get_canvas())
|
||||
for(auto & canvas : clock_->get_canvases())
|
||||
{
|
||||
canvas.set_variable("hour", variant(hour_stamp));
|
||||
canvas.set_variable("minute", variant(minute_stamp));
|
||||
|
|
|
@ -109,7 +109,7 @@ void end_credits::pre_show(window& window)
|
|||
}
|
||||
|
||||
// TODO: implement showing all available images as the credits scroll
|
||||
window.get_canvas()[0].set_variable("background_image", variant(backgrounds_[0]));
|
||||
window.get_canvas(0).set_variable("background_image", variant(backgrounds_[0]));
|
||||
|
||||
text_widget_ = find_widget<scroll_label>(&window, "text", false, true);
|
||||
|
||||
|
|
|
@ -239,13 +239,13 @@ void title_screen::pre_show(window& win)
|
|||
ERR_CF << "No title image defined" << std::endl;
|
||||
}
|
||||
|
||||
win.get_canvas()[0].set_variable("title_image", variant(game_config::images::game_title));
|
||||
win.get_canvas(0).set_variable("title_image", variant(game_config::images::game_title));
|
||||
|
||||
if(game_config::images::game_title_background.empty()) {
|
||||
ERR_CF << "No title background image defined" << std::endl;
|
||||
}
|
||||
|
||||
win.get_canvas()[0].set_variable("background_image", variant(game_config::images::game_title_background));
|
||||
win.get_canvas(0).set_variable("background_image", variant(game_config::images::game_title_background));
|
||||
|
||||
find_widget<image>(&win, "logo-bg", false).set_image(game_config::images::game_logo_background);
|
||||
find_widget<image>(&win, "logo", false).set_image(game_config::images::game_logo);
|
||||
|
@ -259,7 +259,7 @@ void title_screen::pre_show(window& win)
|
|||
version_label->set_label(version_string);
|
||||
}
|
||||
|
||||
win.get_canvas()[0].set_variable("revision_number", variant(version_string));
|
||||
win.get_canvas(0).set_variable("revision_number", variant(version_string));
|
||||
|
||||
//
|
||||
// Tip-of-the-day browser
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
canvas& get_drawing_canvas()
|
||||
{
|
||||
return get_canvas().front();
|
||||
return get_canvas(0);
|
||||
}
|
||||
|
||||
void set_drawing_data(const ::config& cfg)
|
||||
|
|
|
@ -54,7 +54,7 @@ void progress_bar::set_percentage(unsigned percentage)
|
|||
if(percentage_ != percentage) {
|
||||
percentage_ = percentage;
|
||||
|
||||
for(auto & c : get_canvas())
|
||||
for(auto & c : get_canvases())
|
||||
{
|
||||
c.set_variable("percentage", variant(percentage));
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void scrollbar_base::set_item_position(const unsigned item_position)
|
|||
void scrollbar_base::update_canvas()
|
||||
{
|
||||
|
||||
for(auto & tmp : get_canvas())
|
||||
for(auto & tmp : get_canvases())
|
||||
{
|
||||
tmp.set_variable("positioner_offset", variant(positioner_offset_));
|
||||
tmp.set_variable("positioner_length", variant(positioner_length_));
|
||||
|
@ -306,7 +306,7 @@ void scrollbar_base::move_positioner(const int distance)
|
|||
void scrollbar_base::load_config_extra()
|
||||
{
|
||||
// These values won't change so set them here.
|
||||
for(auto & tmp : get_canvas())
|
||||
for(auto & tmp : get_canvases())
|
||||
{
|
||||
tmp.set_variable("offset_before", variant(offset_before()));
|
||||
tmp.set_variable("offset_after", variant(offset_after()));
|
||||
|
|
|
@ -265,7 +265,7 @@ void slider::update_canvas()
|
|||
// Inherited.
|
||||
scrollbar_base::update_canvas();
|
||||
|
||||
for(auto & tmp : get_canvas())
|
||||
for(auto & tmp : get_canvases())
|
||||
{
|
||||
tmp.set_variable("text", variant(get_value_label()));
|
||||
}
|
||||
|
|
|
@ -452,14 +452,14 @@ void styled_widget::definition_load_configuration(const std::string& control_typ
|
|||
assert(!config());
|
||||
|
||||
set_config(get_control(control_type, definition_));
|
||||
if(get_canvas().size() != config()->state.size())
|
||||
if(get_canvases().size() != config()->state.size())
|
||||
{
|
||||
// TODO: Some widgets (toggle panel, toggle button) have a variable canvas count which is determined by its definition.
|
||||
// I think we should remove the canvas_count from tcontrols constructor and always read it from the definition.
|
||||
DBG_GUI_L << "Corrected canvas count to " << config()->state.size() << std::endl;
|
||||
get_canvas() = std::vector<canvas>(config()->state.size());
|
||||
get_canvases() = std::vector<canvas>(config()->state.size());
|
||||
}
|
||||
for(size_t i = 0; i < get_canvas().size(); ++i) {
|
||||
for(size_t i = 0; i < get_canvases().size(); ++i) {
|
||||
get_canvas(i) = config()->state[i].canvas_;
|
||||
}
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ public:
|
|||
}
|
||||
|
||||
// const versions will be added when needed
|
||||
std::vector<canvas>& get_canvas()
|
||||
std::vector<canvas>& get_canvases()
|
||||
{
|
||||
return canvas_;
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ void text_box::update_canvas()
|
|||
const int max_width = get_text_maximum_width();
|
||||
const int max_height = get_text_maximum_height();
|
||||
|
||||
for(auto & tmp : get_canvas())
|
||||
for(auto & tmp : get_canvases())
|
||||
{
|
||||
|
||||
tmp.set_variable("text", variant(get_value()));
|
||||
|
@ -263,7 +263,7 @@ void text_box::update_offsets()
|
|||
|
||||
// Since this variable doesn't change set it here instead of in
|
||||
// update_canvas().
|
||||
for(auto & tmp : get_canvas())
|
||||
for(auto & tmp : get_canvases())
|
||||
{
|
||||
tmp.set_variable("text_font_height", variant(text_height_));
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ void text_box_base::cursor_timer_callback()
|
|||
cursor_alpha_ = (~cursor_alpha_) & 0xFF;
|
||||
}
|
||||
|
||||
for(auto& tmp : get_canvas()) {
|
||||
for(auto& tmp : get_canvases()) {
|
||||
tmp.set_variable("cursor_alpha", variant(cursor_alpha_));
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ void text_box_base::reset_cursor_state()
|
|||
|
||||
cursor_alpha_ = 255;
|
||||
|
||||
for(auto& tmp : get_canvas()) {
|
||||
for(auto& tmp : get_canvases()) {
|
||||
tmp.set_variable("cursor_alpha", variant(cursor_alpha_));
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ void toggle_button::update_canvas()
|
|||
styled_widget::update_canvas();
|
||||
|
||||
// set icon in canvases
|
||||
std::vector<canvas>& canvases = styled_widget::get_canvas();
|
||||
std::vector<canvas>& canvases = styled_widget::get_canvases();
|
||||
for(auto & canvas : canvases)
|
||||
{
|
||||
canvas.set_variable("icon", variant(icon_name_));
|
||||
|
|
|
@ -718,7 +718,7 @@ int intf_set_dialog_canvas(lua_State *L)
|
|||
gui2::styled_widget *c = dynamic_cast<gui2::styled_widget *>(w);
|
||||
if (!c) return luaL_argerror(L, lua_gettop(L), "unsupported widget");
|
||||
|
||||
std::vector<gui2::canvas> &cv = c->get_canvas();
|
||||
std::vector<gui2::canvas> &cv = c->get_canvases();
|
||||
if (i < 1 || unsigned(i) > cv.size())
|
||||
return luaL_argerror(L, 1, "out of bounds");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue