From 2be2b6b54be18fbc8c56aaf7c49bb06a17e99178 Mon Sep 17 00:00:00 2001 From: mniip Date: Sun, 10 Nov 2013 12:28:29 +0400 Subject: [PATCH] Adjust position of ContextMenu if it's too close to bottom or right edges #188 --- src/gui/interface/ContextMenu.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/interface/ContextMenu.cpp b/src/gui/interface/ContextMenu.cpp index aa9eeb5d2..e052d0d4f 100644 --- a/src/gui/interface/ContextMenu.cpp +++ b/src/gui/interface/ContextMenu.cpp @@ -30,9 +30,14 @@ void ContextMenu::Show(ui::Point position) } buttons.clear(); - Position = position; - Size.Y = items.size()*16; Size.X = 100; + Size.Y = items.size()*16-1; + + if(position.X+Size.X > XRES+BARSIZE) + position.X -= std::min(position.X, Size.X); + if(position.Y+Size.Y > YRES+MENUSIZE) + position.Y -= std::min(position.Y, Size.Y); + Position = position; int currentY = 1; for(int i = 0; i < items.size(); i++)