Resize action buttons dynamically on the main display

This adds the necessary bells and whistles to resize the GUI1 buttons
used in the main game display. It is rather painful as it involves
re-setting most of the attributes that affect the size.

These changes also adds two new draw-methods to the display class and
gets rid of the default parameters. This is to avoid warnings from
clang since the draw() method comes from a superclass to display now.

The GUI1 button's set_image has been updated to treat the image path
in the same way as it is treated in the constructor. This should not
be a problem since the method is not called from anywhere but the
display class, and that call is added in this commit.
This commit is contained in:
Andreas Löf 2016-02-24 20:45:50 +13:00
parent d00e207202
commit 12d1fd006f
4 changed files with 19 additions and 4 deletions

View file

@ -266,7 +266,7 @@
id=minimap-button-3
items=minimap-draw-units
type=checkbox
overlay=icons/action/editor-tool-unit_25
overlay=icons/action/editor-tool-unit
image=button_square/button_square_25
auto_tooltip=yes
rect="+1,=,+25,+25"
@ -276,7 +276,7 @@
[action]
id=minimap-button-4
items=minimap-draw-villages
overlay=icons/action/editor-tool-village_25
overlay=icons/action/editor-tool-village
type=checkbox
image=button_square/button_square_25
tooltip_name_prepend=yes

View file

@ -898,6 +898,7 @@ void display::layout_buttons()
b->set_location(loc);
b->set_measurements(0,0);
b->set_label(i->title());
b->set_image(i->image());
b->set_volatile(
sdl::rects_overlap(b->location(),map_outside_area()));
}
@ -912,6 +913,7 @@ void display::layout_buttons()
b->set_location(loc);
b->set_measurements(0,0);
b->set_label(i->title());
b->set_image(i->image());
b->set_volatile(
sdl::rects_overlap(b->location(),map_outside_area()));
}
@ -2746,6 +2748,15 @@ void display::clear_redraw_observers()
redraw_observers_.clear();
}
void display::draw() {
draw(true, false);
}
void display::draw(bool update) {
draw(update, false);
}
void display::draw(bool update,bool force) {
// log_scope("display::draw");

View file

@ -602,7 +602,11 @@ public:
* Not virtual, since it gathers common actions. Calls various protected
* virtuals (further below) to allow specialized behavior in derived classes.
*/
void draw(bool update=true, bool force=false);
virtual void draw();
void draw(bool update);
void draw(bool update, bool force);
map_labels& labels();
const map_labels& labels() const;

View file

@ -572,7 +572,7 @@ static bool not_image(const std::string& str) { return !str.empty() && str[0] !=
void button::set_image(const std::string& image_file)
{
button_image_name_ = image_file;
button_image_name_ = "buttons/" + image_file;
load_images();
set_dirty();
}