Fixed some font sensitivity issues.
Fixed a small glitch in drawing. Removed an unneeded Sync() in Draw(). Removed some unnecessary virtual method calls. Improved drawing of the current slider's value. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12505 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -57,6 +57,8 @@ sPropertyInfo[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const static float kPadding = 10.0;
|
||||||
|
|
||||||
BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
|
BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
|
||||||
BMessage *model, int32 channels, uint32 resizeMode, uint32 flags)
|
BMessage *model, int32 channels, uint32 resizeMode, uint32 flags)
|
||||||
: BChannelControl(area, name, label, model, channels, resizeMode, flags)
|
: BChannelControl(area, name, label, model, channels, resizeMode, flags)
|
||||||
@@ -234,7 +236,6 @@ BChannelSlider::Draw(BRect updateRect)
|
|||||||
float labelWidth = StringWidth(Label());
|
float labelWidth = StringWidth(Label());
|
||||||
|
|
||||||
DrawString(Label(), BPoint((bounds.Width() - labelWidth) / 2, fBaseLine));
|
DrawString(Label(), BPoint((bounds.Width() - labelWidth) / 2, fBaseLine));
|
||||||
Sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,18 +259,19 @@ BChannelSlider::MouseDown(BPoint where)
|
|||||||
fMinpoint = frame.top + frame.Height() / 2;
|
fMinpoint = frame.top + frame.Height() / 2;
|
||||||
frame.bottom += range;
|
frame.bottom += range;
|
||||||
} else {
|
} else {
|
||||||
// TODO: Fix this
|
// TODO: Fix this, the clickzone isn't perfect
|
||||||
frame.right += range;
|
frame.right += range;
|
||||||
fMinpoint = frame.Width();
|
fMinpoint = frame.Width();
|
||||||
}
|
}
|
||||||
// Found. Now set the initial values
|
|
||||||
|
// Click was on a slider.
|
||||||
if (frame.Contains(where)) {
|
if (frame.Contains(where)) {
|
||||||
fCurrentChannel = channel;
|
fCurrentChannel = channel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Click wasn't on a slider.
|
// Click wasn't on a slider. Bail out.
|
||||||
if (fCurrentChannel == -1)
|
if (fCurrentChannel == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -286,10 +288,10 @@ BChannelSlider::MouseDown(BPoint where)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fInitialValues == NULL)
|
if (fInitialValues == NULL)
|
||||||
fInitialValues = new int32[CountChannels()];
|
fInitialValues = new int32[numChannels];
|
||||||
|
|
||||||
if (fAllChannels) {
|
if (fAllChannels) {
|
||||||
for (int32 i = 0; i < CountChannels(); i++)
|
for (int32 i = 0; i < numChannels; i++)
|
||||||
fInitialValues[i] = ValueFor(i);
|
fInitialValues[i] = ValueFor(i);
|
||||||
} else
|
} else
|
||||||
fInitialValues[fCurrentChannel] = ValueFor(fCurrentChannel);
|
fInitialValues[fCurrentChannel] = ValueFor(fCurrentChannel);
|
||||||
@@ -533,9 +535,9 @@ BChannelSlider::ThumbFrameFor(int32 channel)
|
|||||||
if (thumb != NULL) {
|
if (thumb != NULL) {
|
||||||
frame = thumb->Bounds();
|
frame = thumb->Bounds();
|
||||||
if (Vertical())
|
if (Vertical())
|
||||||
frame.OffsetBy(channel * frame.Width(), fLineFeed * 2);
|
frame.OffsetBy(channel * frame.Width(), fLineFeed + kPadding);
|
||||||
else
|
else
|
||||||
frame.OffsetBy(fLineFeed, fLineFeed + channel * frame.Height());
|
frame.OffsetBy(kPadding, fLineFeed + channel * frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
return frame;
|
return frame;
|
||||||
@@ -568,9 +570,9 @@ BChannelSlider::ThumbRangeFor(int32 channel)
|
|||||||
BRect bounds = Bounds();
|
BRect bounds = Bounds();
|
||||||
BRect frame = ThumbFrameFor(channel);
|
BRect frame = ThumbFrameFor(channel);
|
||||||
if (Vertical())
|
if (Vertical())
|
||||||
range = bounds.Height() - frame.Height() - fLineFeed * 4;
|
range = bounds.Height() - frame.Height() - (kPadding + fLineFeed) * 2;
|
||||||
else
|
else
|
||||||
range = bounds.Width() - frame.Width() - fLineFeed * 2;
|
range = bounds.Width() - frame.Width() - kPadding * 2;
|
||||||
|
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
@@ -661,14 +663,15 @@ BChannelSlider::DrawThumbs()
|
|||||||
|
|
||||||
BPoint drawHere;
|
BPoint drawHere;
|
||||||
drawHere.x = (Bounds().Width() - fBacking->Bounds().Width()) / 2;
|
drawHere.x = (Bounds().Width() - fBacking->Bounds().Width()) / 2;
|
||||||
drawHere.y = (Bounds().Height() - fBacking->Bounds().Height()) / 2;
|
drawHere.y = (Bounds().Height() - fBacking->Bounds().Height() + fLineFeed) / 2;
|
||||||
|
|
||||||
if (fBacking->Lock()) {
|
if (fBacking->Lock()) {
|
||||||
// Clear the view's background
|
// Clear the view's background
|
||||||
fBackingView->FillRect(fBackingView->Bounds(), B_SOLID_LOW);
|
fBackingView->FillRect(fBackingView->Bounds(), B_SOLID_LOW);
|
||||||
|
|
||||||
BRect channelArea;
|
BRect channelArea;
|
||||||
for (int32 channel = 0; channel < CountChannels(); channel++) {
|
int32 channelCount = CountChannels();
|
||||||
|
for (int32 channel = 0; channel < channelCount; channel++) {
|
||||||
channelArea = ThumbFrameFor(channel);
|
channelArea = ThumbFrameFor(channel);
|
||||||
// TODO: This is (apparently) needed because ThumbFrameFor() doesn't
|
// TODO: This is (apparently) needed because ThumbFrameFor() doesn't
|
||||||
// take into account that the view we draw on is attached to an offscreen
|
// take into account that the view we draw on is attached to an offscreen
|
||||||
@@ -696,15 +699,15 @@ BChannelSlider::DrawThumbs()
|
|||||||
char valueString[64];
|
char valueString[64];
|
||||||
snprintf(valueString, 64, "%ld", ValueFor(fCurrentChannel));
|
snprintf(valueString, 64, "%ld", ValueFor(fCurrentChannel));
|
||||||
BPoint stringPoint = drawHere;
|
BPoint stringPoint = drawHere;
|
||||||
float stringWidth = StringWidth("100");
|
float stringWidth = StringWidth(valueString);
|
||||||
stringPoint.x += (fBacking->Bounds().Width() - stringWidth) / 2;
|
stringPoint.x += (fBacking->Bounds().Width() - stringWidth) / 2;
|
||||||
stringPoint.y += fBacking->Bounds().Height() + fLineFeed;
|
stringPoint.y += fBacking->Bounds().Height() + fBaseLine;
|
||||||
BRect stringRect(stringPoint, stringPoint);
|
BRect stringRect(stringPoint, stringPoint);
|
||||||
stringRect.right += stringWidth;
|
stringRect.left -= 10;
|
||||||
|
stringRect.right += StringWidth("100");
|
||||||
stringRect.top -= fLineFeed;
|
stringRect.top -= fLineFeed;
|
||||||
|
|
||||||
SetHighColor(ViewColor());
|
SetHighColor(ViewColor());
|
||||||
stringRect.InsetBy(-5, -2);
|
|
||||||
FillRect(stringRect);
|
FillRect(stringRect);
|
||||||
|
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
@@ -714,6 +717,7 @@ BChannelSlider::DrawThumbs()
|
|||||||
// fClickDelta is used in MouseMoved()
|
// fClickDelta is used in MouseMoved()
|
||||||
fClickDelta = drawHere;
|
fClickDelta = drawHere;
|
||||||
|
|
||||||
|
// TODO: See above
|
||||||
if (Vertical())
|
if (Vertical())
|
||||||
fClickDelta.y -= ThumbFrameFor(0).top;
|
fClickDelta.y -= ThumbFrameFor(0).top;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user