a bunch of stuff

This commit is contained in:
Eduardo Bart
2011-05-11 19:16:11 -03:00
parent 42c1ae090c
commit c6753747fb
63 changed files with 663 additions and 375 deletions

View File

@@ -106,17 +106,6 @@ UIElementPtr UIContainer::getChildById(const std::string& id)
return UIElementPtr();
}
UIElementPtr UIContainer::getChildByPos(const Point& pos)
{
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
const UIElementPtr& element = (*it);
if(element->getRect().contains(pos))
return element;
}
return UIElementPtr();
}
UIElementPtr UIContainer::recursiveGetChildById(const std::string& id)
{
if(getId() == id || id == "self")
@@ -144,6 +133,35 @@ UIElementPtr UIContainer::recursiveGetChildById(const std::string& id)
return UIElementPtr();
}
UIElementPtr UIContainer::getChildByPos(const Point& pos)
{
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
const UIElementPtr& element = (*it);
if(element->getRect().contains(pos))
return element;
}
return UIElementPtr();
}
UIElementPtr UIContainer::recursiveGetChildByPos(const Point& pos)
{
for(auto it = m_children.rbegin(); it != m_children.rend(); ++it) {
const UIElementPtr& element = (*it);
if(element->getRect().contains(pos)) {
if(UIContainerPtr container = element->asUIContainer()) {
if(UIElementPtr containerChild = container->recursiveGetChildByPos(pos))
return containerChild;
else
return container;
}
return element;
}
}
return UIElementPtr();
}
void UIContainer::pushChildToTop(const UIElementPtr& child)
{
auto it = std::find(m_children.begin(), m_children.end(), child);
@@ -227,12 +245,13 @@ void UIContainer::focusNextElement()
void UIContainer::setFocusedElement(const UIElementPtr& focusedElement)
{
if(focusedElement != m_focusedElement) {
if(m_focusedElement)
m_focusedElement->onFocusChange();
UIElementPtr oldFocused = m_focusedElement;
m_focusedElement = focusedElement;
if(m_focusedElement)
m_focusedElement->onFocusChange();
if(oldFocused)
oldFocused->onFocusChange();
if(focusedElement)
focusedElement->onFocusChange();
}
// when containers are focused they go to the top