mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 18:31:32 +00:00
refactored widget class
This commit is contained in:
parent
9cfb77b5e0
commit
6aa75f6a03
@ -34,7 +34,7 @@ protected:
|
||||
virtual ~handler();
|
||||
|
||||
private:
|
||||
const int unicode_;
|
||||
int unicode_;
|
||||
};
|
||||
|
||||
//event_context objects control the handler objects that SDL events are sent
|
||||
|
@ -14,31 +14,18 @@ widget::widget(const widget &o) :
|
||||
}
|
||||
|
||||
widget::widget(display& disp) :
|
||||
disp_(disp), rect_(EmptyRect), focus_(true), dirty_(true)
|
||||
disp_(&disp), rect_(EmptyRect), focus_(true), dirty_(true)
|
||||
{
|
||||
bg_backup();
|
||||
}
|
||||
|
||||
widget::widget(display& disp, SDL_Rect& rect) :
|
||||
disp_(disp), rect_(EmptyRect), focus_(true), dirty_(true)
|
||||
disp_(&disp), rect_(EmptyRect), focus_(true), dirty_(true)
|
||||
{
|
||||
set_location(rect);
|
||||
bg_backup();
|
||||
}
|
||||
|
||||
widget& widget::operator=(const widget& o)
|
||||
{
|
||||
// Things seem to wrok without reassinging the disp_
|
||||
// but i'm not sure why...
|
||||
// disp_ = o.disp();
|
||||
rect_ = o.location();
|
||||
focus_ = o.focus();
|
||||
dirty_ = o.dirty();
|
||||
bg_backup();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void widget::set_location(const SDL_Rect& rect)
|
||||
{
|
||||
bg_restore();
|
||||
@ -107,7 +94,7 @@ const bool widget::dirty() const
|
||||
|
||||
void widget::bg_backup()
|
||||
{
|
||||
restorer_ = surface_restorer(&disp_.video(), rect_);
|
||||
restorer_ = surface_restorer(&disp().video(), rect_);
|
||||
}
|
||||
|
||||
void widget::bg_restore() const
|
||||
|
@ -26,16 +26,14 @@ protected:
|
||||
widget(display& disp, SDL_Rect& rect);
|
||||
virtual ~widget() { restorer_.cancel(); }
|
||||
|
||||
widget& operator=(const widget& o);
|
||||
|
||||
void bg_restore() const;
|
||||
void set_dirty(bool dirty);
|
||||
const bool dirty() const;
|
||||
|
||||
display& disp() const { return disp_; }
|
||||
display& disp() const { return *disp_; }
|
||||
|
||||
private:
|
||||
mutable display& disp_;
|
||||
mutable display* disp_;
|
||||
mutable surface_restorer restorer_;
|
||||
SDL_Rect rect_;
|
||||
bool focus_; // Should user input be ignored?
|
||||
|
Loading…
x
Reference in New Issue
Block a user