Some experiments with drawing the slider's value:

Now we draw it over the thumb. The old implementation is there, just ifdeffed out. I'd like some feedback on this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12612 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2005-05-10 09:53:01 +00:00
parent 168bee472e
commit bc3465f998
+29 -5
View File
@@ -686,18 +686,41 @@ BChannelSlider::DrawThumbs()
DrawChannel(fBackingView, channel, channelArea, pressed); DrawChannel(fBackingView, channel, channelArea, pressed);
} }
#if 1
// This part draws the current value over the thumb.
// TODO: make it nicer. Simplify the code.
if (fCurrentChannel != -1 && fMinpoint != 0) {
char valueString[32];
snprintf(valueString, 32, "%ld", ValueFor(fCurrentChannel));
float width = fBackingView->StringWidth(valueString);
BRect valueRect(0, 0, width, 10);
rgb_color oldColor = fBackingView->HighColor();
if (Vertical())
valueRect.OffsetTo((ThumbFrameFor(fCurrentChannel).Width() - width) / 2 + fCurrentChannel * ThumbFrameFor(fCurrentChannel).Width(),
ThumbDeltaFor(fCurrentChannel));
else
valueRect.OffsetTo(ThumbDeltaFor(fCurrentChannel), ThumbFrameFor(fCurrentChannel).top - 10);
fBackingView->SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
fBackingView->StrokeRect(valueRect.InsetByCopy(-0.5, -0.5));
fBackingView->SetHighColor(tint_color(ViewColor(), B_DARKEN_2_TINT));
fBackingView->FillRect(valueRect);
fBackingView->SetHighColor(0, 0, 0);
valueRect.OffsetBy(1 , 9);
fBackingView->DrawString(valueString, valueRect.LeftTop());
fBackingView->SetHighColor(oldColor);
}
#endif
fBackingView->Sync(); fBackingView->Sync();
fBacking->Unlock(); fBacking->Unlock();
} }
DrawBitmapAsync(fBacking, drawHere); DrawBitmapAsync(fBacking, drawHere);
// We also draw the channel value, unlike R5. #if 0
// TODO: just a prototype for now, it isn't so cool. // this part draws the value at the bottom of the sliders.
// for Axel: Not sure if this is what you wanted, feel free to change this
if (fCurrentChannel != -1 && fMinpoint != 0) { if (fCurrentChannel != -1 && fMinpoint != 0) {
char valueString[64]; char valueString[32];
snprintf(valueString, 64, "%ld", ValueFor(fCurrentChannel)); snprintf(valueString, 32, "%ld", ValueFor(fCurrentChannel));
BPoint stringPoint = drawHere; BPoint stringPoint = drawHere;
float stringWidth = StringWidth(valueString); float stringWidth = StringWidth(valueString);
stringPoint.x += (fBacking->Bounds().Width() - stringWidth) / 2; stringPoint.x += (fBacking->Bounds().Width() - stringWidth) / 2;
@@ -713,6 +736,7 @@ BChannelSlider::DrawThumbs()
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
DrawString(valueString, stringPoint); DrawString(valueString, stringPoint);
} }
#endif
// fClickDelta is used in MouseMoved() // fClickDelta is used in MouseMoved()
fClickDelta = drawHere; fClickDelta = drawHere;