Made the caption in full screen mode a bit easier to look at (boring yes, but some

people out there just aren't colour blind :-)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16279 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-02-07 12:23:26 +00:00
parent 71a34702d3
commit c70cd57756
+41 -45
View File
@@ -844,18 +844,18 @@ ShowImageView::LayoutCaption(BFont &font, BPoint &pos, BRect &rect)
float width, height; float width, height;
BRect bounds(Bounds()); BRect bounds(Bounds());
font = be_plain_font; font = be_plain_font;
width = font.StringWidth(fCaption.String()) + 1; // 1 for text shadow width = font.StringWidth(fCaption.String());
font.GetHeight(&fontHeight); font.GetHeight(&fontHeight);
height = fontHeight.ascent + fontHeight.descent; height = fontHeight.ascent + fontHeight.descent;
// center text horizontally // center text horizontally
pos.x = (bounds.left + bounds.right - width)/2; pos.x = (bounds.left + bounds.right - width) / 2;
// flush bottom // flush bottom
pos.y = bounds.bottom - fontHeight.descent - 5; pos.y = bounds.bottom - fontHeight.descent - 7;
// background rectangle // background rectangle
rect.Set(0, 0, (width-1)+2, (height-1)+2+1); // 2 for border and 1 for text shadow rect.Set(0, 0, width + 4, height + 4);
rect.OffsetTo(pos); rect.OffsetTo(pos);
rect.OffsetBy(-1, -1-fontHeight.ascent); // -1 for border rect.OffsetBy(-2, -2 - fontHeight.ascent); // -2 for border
} }
@@ -863,28 +863,24 @@ void
ShowImageView::DrawCaption() ShowImageView::DrawCaption()
{ {
BFont font; BFont font;
BPoint pos; BPoint position;
BRect rect; BRect rect;
LayoutCaption(font, pos, rect); LayoutCaption(font, position, rect);
PushState(); PushState();
// draw background // draw background
SetDrawingMode(B_OP_ALPHA); SetDrawingMode(B_OP_ALPHA);
SetHighColor(0, 0, 255, 128); SetHighColor(255, 255, 255, 128);
FillRect(rect); FillRect(rect);
// draw text // draw text
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
SetFont(&font); SetFont(&font);
SetLowColor(B_TRANSPARENT_COLOR); SetLowColor(B_TRANSPARENT_COLOR);
// text shadow
pos += BPoint(1, 1);
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
SetPenSize(1); DrawString(fCaption.String(), position);
DrawString(fCaption.String(), pos);
// text
pos -= BPoint(1, 1);
SetHighColor(255, 255, 0);
DrawString(fCaption.String(), pos);
PopState(); PopState();
} }
@@ -952,41 +948,39 @@ ShowImageView::DrawImage(BRect rect)
void void
ShowImageView::Draw(BRect updateRect) ShowImageView::Draw(BRect updateRect)
{ {
if (fBitmap) { if (fBitmap == NULL)
if (!IsPrinting()) { return;
BRect rect = AlignBitmap();
Setup(rect);
BRect border(rect); if (IsPrinting()) {
border.InsetBy(-PEN_SIZE, -PEN_SIZE); DrawBitmap(fBitmap);
return;
}
DrawBorder(border); BRect rect = AlignBitmap();
Setup(rect);
// Draw black rectangle around image BRect border(rect);
StrokeRect(border); border.InsetBy(-PEN_SIZE, -PEN_SIZE);
// Draw image DrawBorder(border);
DrawImage(rect);
if (fShowCaption) { // Draw black rectangle around image
// fShowCaption is set to false by ScrollRestricted() StrokeRect(border);
// to prevent the caption from dirtying up the image
// during scrolling.
DrawCaption();
}
if (HasSelection()) { // Draw image
if (fSelBitmap) { DrawImage(rect);
BRect srcBits, destRect;
GetSelMergeRects(srcBits, destRect); if (fShowCaption)
destRect = ImageToView(destRect); DrawCaption();
DrawBitmap(fSelBitmap, srcBits, destRect);
} if (HasSelection()) {
DrawSelectionBox(); if (fSelBitmap) {
} BRect srcBits, destRect;
} else { GetSelMergeRects(srcBits, destRect);
DrawBitmap(fBitmap); destRect = ImageToView(destRect);
DrawBitmap(fSelBitmap, srcBits, destRect);
} }
DrawSelectionBox();
} }
} }
@@ -1572,6 +1566,8 @@ ShowImageView::ScrollRestricted(float x, float y, bool absolute)
// hide the caption when using mouse wheel // hide the caption when using mouse wheel
// in full screen mode // in full screen mode
// to prevent the caption from dirtying up the image
// during scrolling.
bool caption = fShowCaption; bool caption = fShowCaption;
if (caption) { if (caption) {
fShowCaption = false; fShowCaption = false;