fixes display of replay widgets...

...and adds a "tooltip" attribute to theme-wml menu tags
This commit is contained in:
Jörg Hinrichs 2006-05-27 03:49:39 +00:00
parent 3e4590402b
commit 50bcf5e4ba
6 changed files with 31 additions and 11 deletions

View file

@ -457,7 +457,9 @@ height=768
id=replay-label
text= _ "Replay"
ref=replay-panel
rect="=+3,=+1,+60,=-4"
rect="=+3,=+3,+60,=-4"
font_size={FONT_SMALL}
font_rgb=160,160,160
xanchor=fixed
yanchor=fixed
[/label]
@ -469,8 +471,9 @@ height=768
type=image
image=play
title= _ "Play"
tooltip= _ "continous replay"
items=playreplay
rect="+4,=-2,+23,="
rect="+4,=-4,+23,="
xanchor=fixed
yanchor=fixed
[/menu]
@ -482,6 +485,7 @@ height=768
type=image
image=pause
title= _ "Stop"
tooltip= _ "pause at end of turn"
items=stopreplay
rect="+4,=,+23,="
xanchor=fixed
@ -495,6 +499,7 @@ height=768
type=image
image=stop
title= _ "Reset"
tooltip= _ "reset to beginning"
items=resetreplay
rect="+4,=,+23,="
xanchor=fixed
@ -508,6 +513,7 @@ height=768
type=image
image=fast-fwd
title= _ "Next Turn"
tooltip= _ "play turn"
items=replaynextturn
rect="+4,=,+23,="
xanchor=fixed
@ -521,6 +527,7 @@ height=768
type=image
image=frame-fwd
title= _ "Next Side"
tooltip= _ "play side turn"
items=replaynextside
rect="+4,=,+23,="
xanchor=fixed

View file

@ -747,9 +747,19 @@ void draw_panel(CVideo& video, const theme::panel& panel, std::vector<gui::butto
update_rect(loc);
}
static bool first_time = true;
for(std::vector<gui::button>::iterator b = buttons.begin(); b != buttons.end(); ++b) {
if(rects_overlap(b->location(),loc)) {
b->set_dirty(true);
if (first_time){
//FixMe
//YogiHH: This is only made to have the buttons store their background information,
//otherwise the background will appear completely black. It would more
//straightforward to call bg_update, but that is not public and there seems to be
//no other way atm to call it. I will check if bg_update can be made public.
b->hide(true);
b->hide(false);
}
}
}
}
@ -2296,7 +2306,9 @@ void display::create_buttons()
gui::button b(screen_,i->title(),string_to_button_type(i->type()),i->image());
const SDL_Rect& loc = i->location(screen_area());
b.set_location(loc.x,loc.y);
if (!i->tooltip().empty()){
tooltips::add_tooltip(loc, i->tooltip());
}
if(rects_overlap(b.location(),map_area())) {
b.set_volatile(true);
}

View file

@ -528,14 +528,17 @@ theme::menu::menu() : context_(false)
theme::menu::menu(const config& cfg) : object(cfg), context_(cfg["is_context_menu"] == "true"),
title_(cfg["title"].str() + cfg["title_literal"].str()),
image_(cfg["image"]), type_(cfg["type"]),
items_(utils::split(cfg["items"]))
tooltip_(cfg["tooltip"]),
image_(cfg["image"]), type_(cfg["type"]),
items_(utils::split(cfg["items"]))
{}
bool theme::menu::is_context() const { return context_; }
const std::string& theme::menu::title() const { return title_; }
const std::string& theme::menu::tooltip() const { return tooltip_; }
const std::string& theme::menu::type() const { return type_; }
const std::string& theme::menu::image() const { return image_; }

View file

@ -140,6 +140,8 @@ public:
const std::string& title() const;
const std::string& tooltip() const;
const std::string& type() const;
const std::string& image() const;
@ -147,7 +149,7 @@ public:
const std::vector<std::string>& items() const;
private:
bool context_;
std::string title_, image_, type_;
std::string title_, tooltip_, image_, type_;
std::vector<std::string> items_;
};

View file

@ -255,10 +255,6 @@ void button::mouse_motion(SDL_MouseMotionEvent const &event)
state_ = ACTIVE;
else if (state_ == PRESSED && type_ == TYPE_CHECK)
state_ = PRESSED_ACTIVE;
if (type_ == TYPE_CHECK){
//bg_update();
//draw();
}
} else {
// the cursor is not over the widget
if (state_ == PRESSED_ACTIVE)

View file

@ -44,6 +44,7 @@ public:
void set_label(const std::string& val);
bool pressed();
bool hit(int x, int y) const;
void enable(bool new_val);
bool enabled() const;
@ -78,7 +79,6 @@ private:
int base_height_, base_width_;
bool hit(int x, int y) const;
}; //end class button
}