tibia-client/src/framework/ui/uianchor.cpp

32 lines
1.0 KiB
C++
Raw Normal View History

2011-08-14 04:09:11 +02:00
#include "uianchor.h"
#include "uiwidget.h"
2011-08-21 21:43:05 +02:00
UIAnchor::UIAnchor(AnchorEdge anchoredEdge, const std::string& hookedWidgetId, AnchorEdge hookedEdge) :
m_anchoredEdge(anchoredEdge), m_hookedWidgetId(hookedWidgetId), m_hookedEdge(hookedEdge) {
2011-08-14 04:09:11 +02:00
}
2011-08-21 21:43:05 +02:00
int UIAnchor::getHookedPoint() const {
UIWidgetPtr hookedWidget = getHookedWidget();
2011-08-14 04:09:11 +02:00
2011-08-21 21:43:05 +02:00
if(hookedWidget) {
switch(m_hookedEdge) {
2011-08-14 04:09:11 +02:00
case AnchorLeft:
2011-08-21 21:43:05 +02:00
return hookedWidget->getRect().left();
2011-08-14 04:09:11 +02:00
case AnchorRight:
2011-08-21 21:43:05 +02:00
return hookedWidget->getRect().right();
2011-08-14 04:09:11 +02:00
case AnchorTop:
2011-08-21 21:43:05 +02:00
return hookedWidget->getRect().top();
2011-08-14 04:09:11 +02:00
case AnchorBottom:
2011-08-21 21:43:05 +02:00
return hookedWidget->getRect().bottom();
2011-08-14 04:09:11 +02:00
case AnchorHorizontalCenter:
2011-08-21 21:43:05 +02:00
return hookedWidget->getRect().horizontalCenter();
2011-08-14 04:09:11 +02:00
case AnchorVerticalCenter:
2011-08-21 21:43:05 +02:00
return hookedWidget->getRect().verticalCenter();
2011-08-14 04:09:11 +02:00
default:
break;
}
}
2011-08-21 21:43:05 +02:00
return INVALID_POINT;
}