Skip to content

Commit

Permalink
Resize action buttons dynamically on the main display
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aginor committed Feb 24, 2016
1 parent d00e207 commit 12d1fd0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions data/themes/_initial.cfg
Expand Up @@ -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"
Expand All @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/display.cpp
Expand Up @@ -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()));
}
Expand All @@ -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()));
}
Expand Down Expand Up @@ -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");

Expand Down
6 changes: 5 additions & 1 deletion src/display.hpp
Expand Up @@ -602,7 +602,11 @@ class display : public filter_context, public video2::draw_layering
* 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;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/button.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit 12d1fd0

Please sign in to comment.