diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-03 16:44:12 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-03 16:44:12 (GMT) |
| commit | 40e5ce5d37cde6d923d9ca68efd0fe49e4940986 (patch) | |
| tree | 3447fd070de5764a19dad606b4323ae7a9b92148 /src/interface | |
| parent | c7dd248ae3b3b71617ade8a1bbe3a28f25d3d03a (diff) | |
| download | powder-40e5ce5d37cde6d923d9ca68efd0fe49e4940986.zip powder-40e5ce5d37cde6d923d9ca68efd0fe49e4940986.tar.gz | |
Fix context menu position #65
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Component.cpp | 11 | ||||
| -rw-r--r-- | src/interface/Component.h | 2 | ||||
| -rw-r--r-- | src/interface/Label.cpp | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/interface/Component.cpp b/src/interface/Component.cpp index e4c6811..b925430 100644 --- a/src/interface/Component.cpp +++ b/src/interface/Component.cpp @@ -156,6 +156,17 @@ void Component::SetParent(Panel* new_parent) this->_parent = new_parent; } +Point Component::GetScreenPos() +{ + Point newPos(0,0); + if(GetParentWindow()) + newPos += GetParentWindow()->Position; + if(GetParent()) + newPos += GetParent()->Position; + newPos += Position; + return newPos; +} + // ***** OVERRIDEABLES ***** // Kept empty. diff --git a/src/interface/Component.h b/src/interface/Component.h index 5ef672d..c034952 100644 --- a/src/interface/Component.h +++ b/src/interface/Component.h @@ -50,6 +50,8 @@ namespace ui virtual void TextPosition(std::string); void Refresh(); + + Point GetScreenPos(); /* See the parent of this component. * If new_parent is NULL, this component will have no parent. (THIS DOES NOT delete THE COMPONENT. See XComponent::RemoveChild) diff --git a/src/interface/Label.cpp b/src/interface/Label.cpp index 4be7fb7..e388e12 100644 --- a/src/interface/Label.cpp +++ b/src/interface/Label.cpp @@ -121,7 +121,7 @@ void Label::OnMouseClick(int x, int y, unsigned button) if(button == BUTTON_RIGHT) { if(menu) - menu->Show(GetParentWindow()->Position + Position + ui::Point(x, y)); + menu->Show(GetScreenPos() + ui::Point(x, y)); } else { |
