Fixed several bugs regarding resizing in the multiplayer lobby.
Made widgets not have a clip area by default.
This commit is contained in:
parent
135e62a151
commit
3c1e3f1a02
4 changed files with 27 additions and 17 deletions
|
@ -139,17 +139,22 @@ ui::result ui::set_result(ui::result res)
|
|||
|
||||
int ui::xscale(int x) const
|
||||
{
|
||||
return (x*disp().x())/1024;
|
||||
return (x * width())/1024;
|
||||
}
|
||||
|
||||
int ui::yscale(int y) const
|
||||
{
|
||||
return (y*disp().y())/768;
|
||||
return (y * height())/768;
|
||||
}
|
||||
|
||||
SDL_Rect ui::client_area() const
|
||||
{
|
||||
SDL_Rect res = { xscale(11)+6, yscale(40)+6, xscale(833)-12, yscale(524)-12 };
|
||||
SDL_Rect res;
|
||||
|
||||
res.x = xscale(11) + 6;
|
||||
res.y = yscale(40) + 6;
|
||||
res.w = xscale(833) > 12 ? xscale(833) - 12 : 0;
|
||||
res.h = yscale(524) > 12 ? yscale(524) - 12 : 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -257,10 +262,10 @@ void ui::hide_children(bool hide)
|
|||
void ui::layout_children(const SDL_Rect& rect)
|
||||
{
|
||||
users_menu_.set_width(xscale(156));
|
||||
users_menu_.set_location(xscale(856),yscale(42));
|
||||
chat_textbox_.set_location(xscale(11) + 4, xscale(573) + 4);
|
||||
chat_textbox_.set_measurements(xscale(833) - 8, xscale(143) - 8);
|
||||
entry_textbox_.set_location(xscale(11) + 4,yscale(732));
|
||||
users_menu_.set_location(xscale(856), yscale(42));
|
||||
chat_textbox_.set_location(xscale(11) + 4, yscale(573) + 4);
|
||||
chat_textbox_.set_measurements(xscale(833) - 8, yscale(143) - 8);
|
||||
entry_textbox_.set_location(xscale(11) + 4, yscale(732));
|
||||
entry_textbox_.set_width(xscale(833) - 8);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
*
|
||||
* @ret the underlying resource
|
||||
*/
|
||||
resource_type get() const { return resource; }
|
||||
resource_type get() const { return resource; }
|
||||
|
||||
/**
|
||||
* This function provides convenient direct access to the -> operator
|
||||
|
|
|
@ -12,19 +12,15 @@ namespace gui {
|
|||
widget::widget(const widget &o)
|
||||
: events::handler(), disp_(o.disp_), restorer_(o.restorer_), rect_(o.rect_),
|
||||
focus_(o.focus_), needs_restore_(o.needs_restore_),
|
||||
state_(o.state_), clip_rect_(o.clip_rect_), volatile_(o.volatile_),
|
||||
state_(o.state_), clip_(o.clip_), clip_rect_(o.clip_rect_), volatile_(o.volatile_),
|
||||
help_text_(o.help_text_), help_string_(o.help_string_)
|
||||
{
|
||||
}
|
||||
|
||||
widget::widget(display& disp)
|
||||
: disp_(&disp), rect_(EmptyRect), focus_(true), needs_restore_(false),
|
||||
state_(UNINIT), volatile_(false), help_string_(0)
|
||||
state_(UNINIT), clip_(false), volatile_(false), help_string_(0)
|
||||
{
|
||||
clip_rect_.x = 0;
|
||||
clip_rect_.y = 0;
|
||||
clip_rect_.w = disp.screen_area().w;
|
||||
clip_rect_.h = disp.screen_area().h;
|
||||
}
|
||||
|
||||
widget::~widget()
|
||||
|
@ -131,6 +127,7 @@ void widget::hide(bool value)
|
|||
void widget::set_clip_rect(const SDL_Rect& rect)
|
||||
{
|
||||
clip_rect_ = rect;
|
||||
clip_ = true;
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
|
@ -163,7 +160,9 @@ void widget::bg_update()
|
|||
|
||||
void widget::bg_restore() const
|
||||
{
|
||||
clip_rect_setter set_clip_rect(disp().video().getSurface(), clip_rect_);
|
||||
util::scoped_ptr<clip_rect_setter> clipper(NULL);
|
||||
if (clip_)
|
||||
clipper.assign(new clip_rect_setter(disp().video().getSurface(), clip_rect_));
|
||||
|
||||
if (needs_restore_) {
|
||||
for(std::vector< surface_restorer >::const_iterator i = restorer_.begin(),
|
||||
|
@ -179,7 +178,9 @@ void widget::bg_restore() const
|
|||
|
||||
void widget::bg_restore(SDL_Rect const &rect) const
|
||||
{
|
||||
clip_rect_setter set_clip_rect(disp().video().getSurface(), clip_rect_);
|
||||
util::scoped_ptr<clip_rect_setter> clipper(NULL);
|
||||
if (clip_)
|
||||
clipper.assign(new clip_rect_setter(disp().video().getSurface(), clip_rect_));
|
||||
|
||||
for(std::vector< surface_restorer >::const_iterator i = restorer_.begin(),
|
||||
i_end = restorer_.end(); i != i_end; ++i)
|
||||
|
@ -200,7 +201,10 @@ void widget::draw()
|
|||
|
||||
bg_restore();
|
||||
|
||||
clip_rect_setter set_clip_rect(disp().video().getSurface(), clip_rect_);
|
||||
util::scoped_ptr<clip_rect_setter> clipper(NULL);
|
||||
if (clip_)
|
||||
clipper.assign(new clip_rect_setter(disp().video().getSurface(), clip_rect_));
|
||||
|
||||
draw_contents();
|
||||
|
||||
update_rect(rect_);
|
||||
|
|
|
@ -82,6 +82,7 @@ private:
|
|||
mutable bool needs_restore_; // Have we drawn ourselves, so that if moved, we need to restore the background?
|
||||
|
||||
enum { UNINIT, HIDDEN, DIRTY, DRAWN } state_;
|
||||
bool clip_;
|
||||
SDL_Rect clip_rect_;
|
||||
|
||||
bool volatile_;
|
||||
|
|
Loading…
Add table
Reference in a new issue