Remove a bunch of unnecessary draws of GUI1 widgets

They are currently TLDs and draw themselves.
This commit is contained in:
Tommy 2022-07-29 02:22:54 +12:00
parent 422b856eec
commit ae46b86f67
5 changed files with 37 additions and 28 deletions

View File

@ -949,21 +949,24 @@ void display::create_buttons()
void display::draw_buttons()
{
const rect clip = draw::get_clip();
for(auto& btn : menu_buttons_) {
if(clip.overlaps(btn->location())) {
//btn->set_dirty(true);
// TODO: draw_manager - this won't actually draw, because it's not "dirty", but dirty can't be set because that invalidates. Overhaul.
btn->draw();
}
}
// This is currently unnecessary because every GUI1 widget is a TLD.
// They will draw themselves.
return;
for(auto& btn : action_buttons_) {
if(clip.overlaps(btn->location())) {
//btn->set_dirty(true);
btn->draw();
}
}
//const rect clip = draw::get_clip();
//for(auto& btn : menu_buttons_) {
// if(clip.overlaps(btn->location())) {
// btn->set_dirty(true);
// btn->draw();
// }
//}
//for(auto& btn : action_buttons_) {
// if(clip.overlaps(btn->location())) {
// btn->set_dirty(true);
// btn->draw();
// }
//}
}
std::vector<texture> display::get_fog_shroud_images(const map_location& loc, image::TYPE image_type)

View File

@ -353,10 +353,11 @@ void editor_palette<Item>::layout()
template<class Item>
void editor_palette<Item>::draw_contents()
{
for(std::size_t i = 0; i < buttons_.size(); ++i) {
gui::tristate_button& tile = buttons_[i];
tile.draw();
}
// This is unnecessary as every GUI1 widget is a TLD.
//for(std::size_t i = 0; i < buttons_.size(); ++i) {
// gui::tristate_button& tile = buttons_[i];
// tile.draw();
//}
}
// Force compilation of the following template instantiations

View File

@ -127,7 +127,7 @@ public:
{
state_.selected = selected;
}
void draw() override { gui::widget::draw(); }
private:
std::string id_;
std::string desc_;
@ -216,7 +216,7 @@ bool location_palette::scroll_up()
scrolled = true;
set_dirty(true);
}
draw();
return scrolled;
}
bool location_palette::can_scroll_up()
@ -237,7 +237,7 @@ bool location_palette::scroll_down()
scrolled = true;
set_dirty(true);
}
draw();
return scrolled;
}
@ -392,10 +392,11 @@ void location_palette::layout()
void location_palette::draw_contents()
{
for(std::size_t i = 0; i < num_visible_items(); ++i) {
location_palette_item& tile = buttons_[i];
tile.draw();
}
// This is unnecessary as every GUI1 widget is a TLD.
//for(std::size_t i = 0; i < num_visible_items(); ++i) {
// location_palette_item& tile = buttons_[i];
// tile.draw();
//}
}
std::vector<std::string> location_palette::action_pressed() const

View File

@ -128,7 +128,8 @@ void palette_manager::layout()
void palette_manager::draw_contents()
{
active_palette().draw();
// This is unnecessary as every GUI1 widget is a TLD.
//active_palette().draw();
}
sdl_handler_vector palette_manager::handler_members()

View File

@ -80,8 +80,11 @@ public:
/** The current draw location of the display, on the screen. */
virtual rect screen_location() override { return location(); }
public:
virtual void draw() override; // TODO: draw_manager - private nonvirtual
private:
// This could be made public again, but GUI1 widgets are deprecated.
// It's better to replace with GUI2 systems than to improve this.
void draw();
protected:
virtual void draw_contents() {}
virtual void update_location(const SDL_Rect&) {};