refator some stuff, button implementation

This commit is contained in:
Eduardo Bart
2011-04-09 16:07:35 -03:00
parent a5cd0bed74
commit 22c4b0976a
20 changed files with 91 additions and 224 deletions

View File

@@ -30,5 +30,17 @@ void UIButton::render()
{
UIElement::render();
g_fonts.get("tibia-8px-antialised")->renderText(m_text, m_rect, ALIGN_CENTER);
g_fonts.get("tibia-8px-antialised")->renderText(m_text, getRect(), ALIGN_CENTER);
}
bool UIButton::onInputEvent(const InputEvent& event)
{
if(event.type == EV_MOUSE_LDOWN &&
getRect().contains(Point(event.mouse.x, event.mouse.y))) {
m_state = UI::ButtonDown;
} else if(m_state == UI::ButtonDown &&
event.type == EV_MOUSE_LUP) {
m_state = UI::ButtonUp;
}
return false;
}