Fixed caption hiding method so that whenever any kind of scrolling is done, the caption is hidden in full screen mode. Previously, the caption would only hide during click-and-drag scrolling and using other scrolling would cause the caption to be painted in various places on top of the image.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5384 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -538,6 +538,32 @@ ShowImageView::DrawCaption()
|
|||||||
PopState();
|
PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageView::EraseCaption()
|
||||||
|
{
|
||||||
|
font_height fontHeight;
|
||||||
|
float width, height;
|
||||||
|
BRect bounds(Bounds());
|
||||||
|
BFont font(be_plain_font);
|
||||||
|
BPoint pos;
|
||||||
|
BRect rect;
|
||||||
|
width = font.StringWidth(fCaption.String())+1; // 1 for text shadow
|
||||||
|
font.GetHeight(&fontHeight);
|
||||||
|
height = fontHeight.ascent + fontHeight.descent;
|
||||||
|
// center text horizontally
|
||||||
|
pos.x = (bounds.left + bounds.right - width)/2;
|
||||||
|
// flush bottom
|
||||||
|
pos.y = bounds.bottom - fontHeight.descent - 5;
|
||||||
|
|
||||||
|
// background rectangle
|
||||||
|
rect.Set(0, 0, (width-1)+2, (height-1)+2+1); // 2 for border and 1 for text shadow
|
||||||
|
rect.OffsetTo(pos);
|
||||||
|
rect.OffsetBy(-1, -1-fontHeight.ascent); // -1 for border
|
||||||
|
|
||||||
|
// draw over portion of image where caption is located
|
||||||
|
Draw(rect);
|
||||||
|
}
|
||||||
|
|
||||||
Scaler*
|
Scaler*
|
||||||
ShowImageView::GetScaler()
|
ShowImageView::GetScaler()
|
||||||
{
|
{
|
||||||
@@ -583,8 +609,10 @@ ShowImageView::Draw(BRect updateRect)
|
|||||||
// Draw image
|
// Draw image
|
||||||
DrawImage(rect);
|
DrawImage(rect);
|
||||||
|
|
||||||
if (fShowCaption && !fMovesImage) {
|
if (fShowCaption) {
|
||||||
// to avoid flickering, disabled during moving with mouse
|
// fShowCaption is set to false by ScrollRestricted()
|
||||||
|
// to prevent the caption from dirtying up the image
|
||||||
|
// during scrolling.
|
||||||
DrawCaption();
|
DrawCaption();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,7 +1004,21 @@ ShowImageView::ScrollRestricted(float x, float y, bool absolute)
|
|||||||
y = LimitToRange(y, B_VERTICAL, absolute);
|
y = LimitToRange(y, B_VERTICAL, absolute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// hide the caption when using mouse wheel
|
||||||
|
// in full screen mode
|
||||||
|
bool caption = fShowCaption;
|
||||||
|
if (caption) {
|
||||||
|
fShowCaption = false;
|
||||||
|
EraseCaption();
|
||||||
|
}
|
||||||
|
|
||||||
ScrollBy(x, y);
|
ScrollBy(x, y);
|
||||||
|
|
||||||
|
if (caption) {
|
||||||
|
// show the caption again
|
||||||
|
fShowCaption = true;
|
||||||
|
DrawCaption();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX method is not unused
|
// XXX method is not unused
|
||||||
@@ -1048,6 +1090,7 @@ ShowImageView::MouseWheelChanged(BMessage *msg)
|
|||||||
if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK) {
|
if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK) {
|
||||||
y = dy * kscrollBy;
|
y = dy * kscrollBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollRestrictedBy(x, y);
|
ScrollRestrictedBy(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ private:
|
|||||||
void UpdateSelectionRect(BPoint point, bool final);
|
void UpdateSelectionRect(BPoint point, bool final);
|
||||||
void DrawBorder(BRect border);
|
void DrawBorder(BRect border);
|
||||||
void DrawCaption();
|
void DrawCaption();
|
||||||
|
void EraseCaption();
|
||||||
void DrawSelectionBox(BRect &rect);
|
void DrawSelectionBox(BRect &rect);
|
||||||
Scaler* GetScaler();
|
Scaler* GetScaler();
|
||||||
void DrawImage(BRect rect);
|
void DrawImage(BRect rect);
|
||||||
|
|||||||
Reference in New Issue
Block a user