Fix #5809 by making the context menu sticky and also offsetting the open point

by 5 pixels. Add a check so that multiple context menus aren't opened.

Also don't draw a 0 x 0 selection rect.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36799 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood
2010-05-13 03:43:05 +00:00
parent 36c176518b
commit 016233a96c
+24 -20
View File
@@ -1021,19 +1021,21 @@ ShowImageView::Draw(BRect updateRect)
void void
ShowImageView::_DrawSelectionBox() ShowImageView::_DrawSelectionBox()
{ {
BRect r(fSelectionRect); if (fSelectionRect.Height() > 0.0 && fSelectionRect.Width() > 0.0) {
_ConstrainToImage(r); BRect r(fSelectionRect);
r = _ImageToView(r); _ConstrainToImage(r);
// draw selection box *around* selection r = _ImageToView(r);
r.InsetBy(-1, -1); // draw selection box *around* selection
PushState(); r.InsetBy(-1, -1);
rgb_color white = {255, 255, 255}; PushState();
SetLowColor(white); rgb_color white = {255, 255, 255};
StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top), fPatternLeft); SetLowColor(white);
StrokeLine(BPoint(r.right, r.top+1), BPoint(r.right, r.bottom-1), fPatternUp); StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top), fPatternLeft);
StrokeLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom), fPatternRight); StrokeLine(BPoint(r.right, r.top+1), BPoint(r.right, r.bottom-1), fPatternUp);
StrokeLine(BPoint(r.left, r.top+1), BPoint(r.left, r.bottom-1), fPatternDown); StrokeLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom), fPatternRight);
PopState(); StrokeLine(BPoint(r.left, r.top+1), BPoint(r.left, r.bottom-1), fPatternDown);
PopState();
}
} }
@@ -1780,15 +1782,17 @@ ShowImageView::_MouseWheelChanged(BMessage *msg)
void void
ShowImageView::_ShowPopUpMenu(BPoint screen) ShowImageView::_ShowPopUpMenu(BPoint screen)
{ {
BPopUpMenu* menu = new PopUpMenu("PopUpMenu", this); if (!fShowingPopUpMenu) {
PopUpMenu* menu = new PopUpMenu("PopUpMenu", this);
ShowImageWindow* showImage = dynamic_cast<ShowImageWindow*>(Window()); ShowImageWindow* showImage = dynamic_cast<ShowImageWindow*>(Window());
if (showImage) if (showImage)
showImage->BuildContextMenu(menu); showImage->BuildContextMenu(menu);
screen -= BPoint(10, 10); screen += BPoint(5, 5);
menu->Go(screen, true, false, true); menu->Go(screen, true, true, true);
fShowingPopUpMenu = true; fShowingPopUpMenu = true;
}
} }