* Finished rewriting the header.

* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-08-25 14:13:59 +00:00
parent f1f6eacd46
commit d89b690d3b
2 changed files with 235 additions and 228 deletions
+39 -47
View File
@@ -1,15 +1,7 @@
/******************************************************************************* /*
/ * Copyright 2009, Haiku Inc. All rights reserved.
/ File: ChannelSlider.h * Distributed under the terms of the MIT license.
/ */
/ Description: BChannelSlider implements a slider which can have a number
/ of (on-screen) related values. A typical use is for a stereo
/ volume control.
/
/ Copyright 1998-99, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _CHANNEL_SLIDER_H #ifndef _CHANNEL_SLIDER_H
#define _CHANNEL_SLIDER_H #define _CHANNEL_SLIDER_H
@@ -41,13 +33,8 @@ public:
virtual ~BChannelSlider(); virtual ~BChannelSlider();
static BArchivable* Instantiate(BMessage* from); static BArchivable* Instantiate(BMessage* from);
virtual status_t Archive(BMessage* into, bool deep = true) const; virtual status_t Archive(BMessage* into,
bool deep = true) const;
virtual orientation Orientation() const;
void SetOrientation(enum orientation orientation);
virtual int32 MaxChannelCount() const;
virtual bool SupportsIndividualLimits() const;
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void AllAttached(); virtual void AllAttached();
@@ -56,7 +43,7 @@ public:
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual void Draw(BRect area); virtual void Draw(BRect updateRect);
virtual void MouseDown(BPoint where); virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where); virtual void MouseUp(BPoint where);
virtual void MouseMoved(BPoint where, uint32 transit, virtual void MouseMoved(BPoint where, uint32 transit,
@@ -70,26 +57,29 @@ public:
uint32 mask = B_FONT_ALL); uint32 mask = B_FONT_ALL);
virtual void MakeFocus(bool focusState = true); virtual void MakeFocus(bool focusState = true);
virtual void SetEnabled(bool on);
virtual void GetPreferredSize(float* _width, float* _height); virtual void GetPreferredSize(float* _width, float* _height);
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, virtual BHandler* ResolveSpecifier(BMessage* message,
BMessage* specifier, int32 form, int32 index, BMessage* specifier,
const char* p); int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data); virtual status_t GetSupportedSuites(BMessage* data);
// Perform rendering for an entire slider channel. virtual void SetEnabled(bool on);
virtual void DrawChannel(BView* into, int32 channel, BRect area,
bool pressed);
// Draw groove that appears behind a channel's thumb. virtual orientation Orientation() const;
virtual void DrawGroove(BView* into, int32 channel, BPoint lt, void SetOrientation(enum orientation orientation);
BPoint br);
// Draw the thumb for a single channel. virtual int32 MaxChannelCount() const;
virtual void DrawThumb(BView* into, int32 channel, BPoint where, virtual bool SupportsIndividualLimits() const;
bool pressed);
virtual void DrawChannel(BView* into, int32 channel,
BRect area, bool pressed);
virtual void DrawGroove(BView* into, int32 channel,
BPoint leftTop, BPoint rightBottom);
virtual void DrawThumb(BView* into, int32 channel,
BPoint where, bool pressed);
virtual const BBitmap* ThumbFor(int32 channel, bool pressed); virtual const BBitmap* ThumbFor(int32 channel, bool pressed);
virtual BRect ThumbFrameFor(int32 channel); virtual BRect ThumbFrameFor(int32 channel);
@@ -97,6 +87,7 @@ virtual float ThumbDeltaFor(int32 channel);
virtual float ThumbRangeFor(int32 channel); virtual float ThumbRangeFor(int32 channel);
private: private:
// FBC padding
BChannelSlider(const BChannelSlider&); BChannelSlider(const BChannelSlider&);
BChannelSlider& operator=(const BChannelSlider&); BChannelSlider& operator=(const BChannelSlider&);
@@ -110,6 +101,16 @@ virtual void _Reserved_BChannelSlider_5(void* , ...);
virtual void _Reserved_BChannelSlider_6(void*, ...); virtual void _Reserved_BChannelSlider_6(void*, ...);
virtual void _Reserved_BChannelSlider_7(void*, ...); virtual void _Reserved_BChannelSlider_7(void*, ...);
private:
void _InitData();
void _FinishChange(bool update = false);
void _UpdateFontDimens();
void _DrawThumbs();
void _DrawGrooveFrame(BView* where,
const BRect& area);
void _MouseMovedCommon(BPoint point, BPoint point2);
private:
float fBaseLine; float fBaseLine;
float fLineFeed; float fLineFeed;
BBitmap* fLeftKnob; BBitmap* fLeftKnob;
@@ -117,27 +118,18 @@ virtual void _Reserved_BChannelSlider_7(void* , ...);
BBitmap* fRightKnob; BBitmap* fRightKnob;
BBitmap* fBacking; BBitmap* fBacking;
BView* fBackingView; BView* fBackingView;
bool fVertical; bool fIsVertical;
bool fPadding[3]; bool _padding_[3];
BPoint fClickDelta; BPoint fClickDelta;
int32 fCurrentChannel; int32 fCurrentChannel;
bool fAllChannels; bool fAllChannels;
int32* fInitialValues; int32* fInitialValues;
float fMinpoint; float fMinPoint;
int32 fFocusChannel; int32 fFocusChannel;
uint32 _reserved_[12]; uint32 _reserved_[12];
void _InitData();
void _FinishChange(bool update = false);
void _UpdateFontDimens();
void _DrawThumbs();
void _DrawGrooveFrame(BView* where, const BRect& area);
bool _Vertical() const;
void _Redraw();
void _MouseMovedCommon(BPoint point, BPoint point2);
}; };
#endif /* _CHANNEL_SLIDER_H */ #endif // _CHANNEL_SLIDER_H
+130 -115
View File
@@ -1,11 +1,16 @@
/* /*
* Copyright 2005 - 2008, Haiku Inc. All Rights Reserved. * Copyright 2005-2009, Haiku Inc. All Rights Reserved.
* Author: Stefano Ceccherini ([email protected])
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini ([email protected])
* Stephan Aßmus <[email protected]>
*/ */
#include <ChannelSlider.h> #include <ChannelSlider.h>
#include <new>
#include <Bitmap.h> #include <Bitmap.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Debug.h> #include <Debug.h>
@@ -14,9 +19,6 @@
#include <Window.h> #include <Window.h>
#include <new>
const static unsigned char const static unsigned char
kVerticalKnobData[] = { kVerticalKnobData[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -144,38 +146,6 @@ BChannelSlider::Archive(BMessage *into, bool deep) const
} }
orientation
BChannelSlider::Orientation() const
{
return _Vertical() ? B_VERTICAL : B_HORIZONTAL;
}
void
BChannelSlider::SetOrientation(enum orientation orientation)
{
bool isVertical = orientation == B_VERTICAL;
if (isVertical != _Vertical()) {
fVertical = isVertical;
Invalidate(Bounds());
}
}
int32
BChannelSlider::MaxChannelCount() const
{
return 32;
}
bool
BChannelSlider::SupportsIndividualLimits() const
{
return false;
}
void void
BChannelSlider::AttachedToWindow() BChannelSlider::AttachedToWindow()
{ {
@@ -224,7 +194,8 @@ BChannelSlider::MessageReceived(BMessage *message)
&what, &property); &what, &property);
BPropertyInfo propInfo(sPropertyInfo); BPropertyInfo propInfo(sPropertyInfo);
if (status == B_OK if (status == B_OK
&& propInfo.FindMatch(message, index, &specifier, what, property) >= 0) { && propInfo.FindMatch(message, index, &specifier, what,
property) >= 0) {
handled = true; handled = true;
if (message->what == B_SET_PROPERTY) { if (message->what == B_SET_PROPERTY) {
orientation orient; orientation orient;
@@ -267,27 +238,32 @@ BChannelSlider::Draw(BRect updateRect)
} }
if (MinLimitLabel()) { if (MinLimitLabel()) {
if (_Vertical()) { if (fIsVertical) {
if (MinLimitLabel()) { if (MinLimitLabel()) {
float x = (bounds.Width() - StringWidth(MinLimitLabel())) / 2.0; float x = (bounds.Width() - StringWidth(MinLimitLabel()))
DrawString(MinLimitLabel(), BPoint(x, bounds.bottom - kPadding)); / 2.0;
DrawString(MinLimitLabel(), BPoint(x, bounds.bottom
- kPadding));
} }
} else { } else {
if (MinLimitLabel()) if (MinLimitLabel()) {
DrawString(MinLimitLabel(), BPoint(kPadding, bounds.bottom - kPadding)); DrawString(MinLimitLabel(), BPoint(kPadding, bounds.bottom
- kPadding));
}
} }
} }
if (MaxLimitLabel()) { if (MaxLimitLabel()) {
if (_Vertical()) { if (fIsVertical) {
if (MaxLimitLabel()) { if (MaxLimitLabel()) {
float x = (bounds.Width() - StringWidth(MaxLimitLabel())) / 2.0; float x = (bounds.Width() - StringWidth(MaxLimitLabel()))
/ 2.0;
DrawString(MaxLimitLabel(), BPoint(x, 2 * fLineFeed)); DrawString(MaxLimitLabel(), BPoint(x, 2 * fLineFeed));
} }
} else { } else {
if (MaxLimitLabel()) { if (MaxLimitLabel()) {
DrawString(MaxLimitLabel(), BPoint(bounds.right - kPadding - DrawString(MaxLimitLabel(), BPoint(bounds.right - kPadding
StringWidth(MaxLimitLabel()), bounds.bottom - kPadding)); - StringWidth(MaxLimitLabel()), bounds.bottom - kPadding));
} }
} }
} }
@@ -301,7 +277,7 @@ BChannelSlider::MouseDown(BPoint where)
BControl::MouseDown(where); BControl::MouseDown(where);
else { else {
fCurrentChannel = -1; fCurrentChannel = -1;
fMinpoint = 0; fMinPoint = 0;
// Search the channel on which the mouse was over // Search the channel on which the mouse was over
int32 numChannels = CountChannels(); int32 numChannels = CountChannels();
@@ -310,13 +286,13 @@ BChannelSlider::MouseDown(BPoint where)
frame.OffsetBy(fClickDelta); frame.OffsetBy(fClickDelta);
float range = ThumbRangeFor(channel); float range = ThumbRangeFor(channel);
if (_Vertical()) { if (fIsVertical) {
fMinpoint = frame.top + frame.Height() / 2; fMinPoint = frame.top + frame.Height() / 2;
frame.bottom += range; frame.bottom += range;
} else { } else {
// TODO: Fix this, the clickzone isn't perfect // TODO: Fix this, the clickzone isn't perfect
frame.right += range; frame.right += range;
fMinpoint = frame.Width(); fMinPoint = frame.Width();
} }
// Click was on a slider. // Click was on a slider.
@@ -387,7 +363,7 @@ BChannelSlider::MouseUp(BPoint where)
SetTracking(false); SetTracking(false);
fAllChannels = false; fAllChannels = false;
fCurrentChannel = -1; fCurrentChannel = -1;
fMinpoint = 0; fMinPoint = 0;
} else { } else {
BChannelControl::MouseUp(where); BChannelControl::MouseUp(where);
} }
@@ -453,19 +429,12 @@ BChannelSlider::MakeFocus(bool focusState)
} }
void
BChannelSlider::SetEnabled(bool on)
{
BChannelControl::SetEnabled(on);
}
void void
BChannelSlider::GetPreferredSize(float* width, float* height) BChannelSlider::GetPreferredSize(float* width, float* height)
{ {
_UpdateFontDimens(); _UpdateFontDimens();
if (_Vertical()) { if (fIsVertical) {
*width = 11.0 * CountChannels(); *width = 11.0 * CountChannels();
*width = max_c(*width, ceilf(StringWidth(Label()))); *width = max_c(*width, ceilf(StringWidth(Label())));
*width = max_c(*width, ceilf(StringWidth(MinLimitLabel()))); *width = max_c(*width, ceilf(StringWidth(MinLimitLabel())));
@@ -475,24 +444,26 @@ BChannelSlider::GetPreferredSize(float *width, float *height)
*height = (fLineFeed * 3.0) + (kPadding * 2.0) + 147.0; *height = (fLineFeed * 3.0) + (kPadding * 2.0) + 147.0;
} else { } else {
*width = max_c(64.0, ceilf(StringWidth(Label()))); *width = max_c(64.0, ceilf(StringWidth(Label())));
*width = max_c(*width, ceilf(StringWidth(MinLimitLabel())) + *width = max_c(*width, ceilf(StringWidth(MinLimitLabel()))
ceilf(StringWidth(MaxLimitLabel())) + 10.0); + ceilf(StringWidth(MaxLimitLabel())) + 10.0);
*width += kPadding * 2.0; *width += kPadding * 2.0;
*height = 11.0 * CountChannels() + (fLineFeed * 2.0) + (kPadding * 2.0); *height = 11.0 * CountChannels() + (fLineFeed * 2.0)
+ (kPadding * 2.0);
} }
} }
BHandler* BHandler*
BChannelSlider::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, BChannelSlider::ResolveSpecifier(BMessage* message, int32 index,
int32 form, const char *property) BMessage* specifier, int32 form, const char* property)
{ {
BHandler* target = this; BHandler* target = this;
BPropertyInfo propertyInfo(sPropertyInfo); BPropertyInfo propertyInfo(sPropertyInfo);
if (propertyInfo.FindMatch(msg, index, specifier, form, property) < B_OK) { if (propertyInfo.FindMatch(message, index, specifier, form,
target = BChannelControl::ResolveSpecifier(msg, index, specifier, form, property) != B_OK) {
property); target = BChannelControl::ResolveSpecifier(message, index, specifier,
form, property);
} }
return target; return target;
} }
@@ -517,14 +488,55 @@ BChannelSlider::GetSupportedSuites(BMessage *data)
void void
BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed) BChannelSlider::SetEnabled(bool on)
{
BChannelControl::SetEnabled(on);
}
orientation
BChannelSlider::Orientation() const
{
return fIsVertical ? B_VERTICAL : B_HORIZONTAL;
}
void
BChannelSlider::SetOrientation(enum orientation orientation)
{
bool isVertical = orientation == B_VERTICAL;
if (isVertical != fIsVertical) {
fIsVertical = isVertical;
InvalidateLayout();
Invalidate(Bounds());
}
}
int32
BChannelSlider::MaxChannelCount() const
{
return 32;
}
bool
BChannelSlider::SupportsIndividualLimits() const
{
return false;
}
void
BChannelSlider::DrawChannel(BView* into, int32 channel, BRect area,
bool pressed)
{ {
float hCenter = area.Width() / 2; float hCenter = area.Width() / 2;
float vCenter = area.Height() / 2; float vCenter = area.Height() / 2;
BPoint leftTop; BPoint leftTop;
BPoint bottomRight; BPoint bottomRight;
if (_Vertical()) { if (fIsVertical) {
leftTop.Set(area.left + hCenter, area.top + vCenter); leftTop.Set(area.left + hCenter, area.top + vCenter);
bottomRight.Set(leftTop.x, leftTop.y + ThumbRangeFor(channel)); bottomRight.Set(leftTop.x, leftTop.y + ThumbRangeFor(channel));
} else { } else {
@@ -535,7 +547,7 @@ BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed
DrawGroove(into, channel, leftTop, bottomRight); DrawGroove(into, channel, leftTop, bottomRight);
BPoint thumbLocation = leftTop; BPoint thumbLocation = leftTop;
if (_Vertical()) if (fIsVertical)
thumbLocation.y += ThumbDeltaFor(channel); thumbLocation.y += ThumbDeltaFor(channel);
else else
thumbLocation.x += ThumbDeltaFor(channel); thumbLocation.x += ThumbDeltaFor(channel);
@@ -573,7 +585,8 @@ BChannelSlider::DrawGroove(BView *into, int32 channel, BPoint leftTop,
void void
BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where, bool pressed) BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where,
bool pressed)
{ {
ASSERT(into != NULL); ASSERT(into != NULL);
@@ -627,16 +640,18 @@ BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where, bool pressed
const BBitmap* const BBitmap*
BChannelSlider::ThumbFor(int32 channel, bool pressed) BChannelSlider::ThumbFor(int32 channel, bool pressed)
{ {
// TODO: Finish me // TODO: Finish me (check allocations... etc)
if (fLeftKnob == NULL) { if (fLeftKnob == NULL) {
if (_Vertical()) { if (fIsVertical) {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 11, 14), B_CMAP8); fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 11, 14),
B_CMAP8);
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData), 0, fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData), 0,
B_CMAP8); B_CMAP8);
} else { } else {
fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 14, 11), B_CMAP8); fLeftKnob = new (std::nothrow) BBitmap(BRect(0, 0, 14, 11),
fLeftKnob->SetBits(kHorizontalKnobData, sizeof(kHorizontalKnobData), B_CMAP8);
0, B_CMAP8); fLeftKnob->SetBits(kHorizontalKnobData,
sizeof(kHorizontalKnobData), 0, B_CMAP8);
} }
} }
@@ -653,11 +668,12 @@ BChannelSlider::ThumbFrameFor(int32 channel)
const BBitmap* thumb = ThumbFor(channel, false); const BBitmap* thumb = ThumbFor(channel, false);
if (thumb != NULL) { if (thumb != NULL) {
frame = thumb->Bounds(); frame = thumb->Bounds();
if (_Vertical()) { if (fIsVertical) {
frame.OffsetBy(channel * frame.Width(), (frame.Height() / 2.0) - frame.OffsetBy(channel * frame.Width(), (frame.Height() / 2.0) -
(kPadding * 2.0) - 1.0); (kPadding * 2.0) - 1.0);
} else { } else {
frame.OffsetBy(frame.Width() / 2.0, channel * frame.Height() + 1.0); frame.OffsetBy(frame.Width() / 2.0, channel * frame.Height()
+ 1.0);
} }
} }
return frame; return frame;
@@ -671,9 +687,10 @@ BChannelSlider::ThumbDeltaFor(int32 channel)
if (channel >= 0 && channel < MaxChannelCount()) { if (channel >= 0 && channel < MaxChannelCount()) {
float range = ThumbRangeFor(channel); float range = ThumbRangeFor(channel);
int32 limitRange = MaxLimitList()[channel] - MinLimitList()[channel]; int32 limitRange = MaxLimitList()[channel] - MinLimitList()[channel];
delta = (ValueList()[channel] - MinLimitList()[channel]) * range / limitRange; delta = (ValueList()[channel] - MinLimitList()[channel]) * range
/ limitRange;
if (_Vertical()) if (fIsVertical)
delta = range - delta; delta = range - delta;
} }
@@ -689,7 +706,7 @@ BChannelSlider::ThumbRangeFor(int32 channel)
float range = 0; float range = 0;
BRect bounds = Bounds(); BRect bounds = Bounds();
BRect frame = ThumbFrameFor(channel); BRect frame = ThumbFrameFor(channel);
if (_Vertical()) { if (fIsVertical) {
// *height = (fLineFeed * 3.0) + (kPadding * 2.0) + 100.0; // *height = (fLineFeed * 3.0) + (kPadding * 2.0) + 100.0;
range = bounds.Height() - frame.Height() - (fLineFeed * 3.0) - range = bounds.Height() - frame.Height() - (fLineFeed * 3.0) -
(kPadding * 2.0); (kPadding * 2.0);
@@ -701,6 +718,9 @@ BChannelSlider::ThumbRangeFor(int32 channel)
} }
// #pragma mark -
void void
BChannelSlider::_InitData() BChannelSlider::_InitData()
{ {
@@ -711,13 +731,13 @@ BChannelSlider::_InitData()
fRightKnob = NULL; fRightKnob = NULL;
fBacking = NULL; fBacking = NULL;
fBackingView = NULL; fBackingView = NULL;
fVertical = Bounds().Width() / Bounds().Height() < 1; fIsVertical = Bounds().Width() / Bounds().Height() < 1;
fClickDelta = B_ORIGIN; fClickDelta = B_ORIGIN;
fCurrentChannel = -1; fCurrentChannel = -1;
fAllChannels = false; fAllChannels = false;
fInitialValues = NULL; fInitialValues = NULL;
fMinpoint = 0; fMinPoint = 0;
fFocusChannel = -1; fFocusChannel = -1;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -738,12 +758,13 @@ BChannelSlider::_FinishChange(bool update)
inMask[fCurrentChannel] = true; inMask[fCurrentChannel] = true;
} }
} }
InvokeChannel(update ? ModificationMessage() : NULL, 0, numChannels, inMask); InvokeChannel(update ? ModificationMessage() : NULL, 0, numChannels,
inMask);
} }
if (!update) { if (!update) {
SetTracking(false); SetTracking(false);
_Redraw(); Invalidate();
} }
} }
@@ -768,7 +789,7 @@ BChannelSlider::_DrawThumbs()
BRect last = ThumbFrameFor(CountChannels() - 1); BRect last = ThumbFrameFor(CountChannels() - 1);
BRect rect(first.LeftTop(), last.RightBottom()); BRect rect(first.LeftTop(), last.RightBottom());
if (_Vertical()) if (fIsVertical)
rect.top -= ThumbRangeFor(0); rect.top -= ThumbRangeFor(0);
else else
rect.right += ThumbRangeFor(0); rect.right += ThumbRangeFor(0);
@@ -781,8 +802,10 @@ BChannelSlider::_DrawThumbs()
if (fBacking->Lock()) { if (fBacking->Lock()) {
fBacking->AddChild(fBackingView); fBacking->AddChild(fBackingView);
fBackingView->SetFontSize(10.0); fBackingView->SetFontSize(10.0);
fBackingView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fBackingView->SetLowColor(
fBackingView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); ui_color(B_PANEL_BACKGROUND_COLOR));
fBackingView->SetViewColor(
ui_color(B_PANEL_BACKGROUND_COLOR));
fBacking->Unlock(); fBacking->Unlock();
} }
} else { } else {
@@ -812,7 +835,7 @@ BChannelSlider::_DrawThumbs()
} }
// draw some kind of current value tool tip // draw some kind of current value tool tip
if (fCurrentChannel != -1 && fMinpoint != 0) { if (fCurrentChannel != -1 && fMinPoint != 0) {
char valueString[32]; char valueString[32];
snprintf(valueString, 32, "%ld", ValueFor(fCurrentChannel)); snprintf(valueString, 32, "%ld", ValueFor(fCurrentChannel));
float stringWidth = fBackingView->StringWidth(valueString); float stringWidth = fBackingView->StringWidth(valueString);
@@ -822,24 +845,28 @@ BChannelSlider::_DrawThumbs()
BRect thumbFrame(ThumbFrameFor(fCurrentChannel)); BRect thumbFrame(ThumbFrameFor(fCurrentChannel));
float thumbDelta(ThumbDeltaFor(fCurrentChannel)); float thumbDelta(ThumbDeltaFor(fCurrentChannel));
if (_Vertical()) { if (fIsVertical) {
valueRect.OffsetTo((thumbFrame.Width() - width) / 2.0 + valueRect.OffsetTo((thumbFrame.Width() - width) / 2.0 +
fCurrentChannel * thumbFrame.Width(), fCurrentChannel * thumbFrame.Width(),
thumbDelta + thumbFrame.Height() + 2.0); thumbDelta + thumbFrame.Height() + 2.0);
if (valueRect.bottom > fBackingView->Frame().bottom) if (valueRect.bottom > fBackingView->Frame().bottom)
valueRect.OffsetBy(0.0, -(thumbFrame.Height() + 12.0)); valueRect.OffsetBy(0.0, -(thumbFrame.Height() + 12.0));
} else { } else {
valueRect.OffsetTo((thumbDelta - (width + 2.0)), thumbFrame.top); valueRect.OffsetTo((thumbDelta - (width + 2.0)),
if (valueRect.left < fBackingView->Frame().left) thumbFrame.top);
valueRect.OffsetBy(thumbFrame.Width() + width + 2.0, 0.0); if (valueRect.left < fBackingView->Frame().left) {
valueRect.OffsetBy(thumbFrame.Width() + width + 2.0,
0.0);
}
} }
rgb_color oldColor = fBackingView->HighColor(); rgb_color oldColor = fBackingView->HighColor();
fBackingView->SetHighColor(255, 255, 172); fBackingView->SetHighColor(255, 255, 172);
fBackingView->FillRect(valueRect); fBackingView->FillRect(valueRect);
fBackingView->SetHighColor(0, 0, 0); fBackingView->SetHighColor(0, 0, 0);
fBackingView->DrawString(valueString, BPoint(valueRect.left + fBackingView->DrawString(valueString, BPoint(valueRect.left
(valueRect.Width() - stringWidth) / 2.0, valueRect.bottom -1.0)); + (valueRect.Width() - stringWidth) / 2.0, valueRect.bottom
- 1.0));
fBackingView->StrokeRect(valueRect.InsetByCopy(-0.5, -0.5)); fBackingView->StrokeRect(valueRect.InsetByCopy(-0.5, -0.5));
fBackingView->SetHighColor(oldColor); fBackingView->SetHighColor(oldColor);
} }
@@ -879,21 +906,6 @@ BChannelSlider::_DrawGrooveFrame(BView *into, const BRect &area)
} }
bool
BChannelSlider::_Vertical() const
{
return fVertical;
}
void
BChannelSlider::_Redraw()
{
Invalidate(Bounds());
Flush();
}
void void
BChannelSlider::_MouseMovedCommon(BPoint point, BPoint point2) BChannelSlider::_MouseMovedCommon(BPoint point, BPoint point2)
{ {
@@ -901,10 +913,10 @@ BChannelSlider::_MouseMovedCommon(BPoint point, BPoint point2)
int32 limitRange = MaxLimitList()[fCurrentChannel] - int32 limitRange = MaxLimitList()[fCurrentChannel] -
MinLimitList()[fCurrentChannel]; MinLimitList()[fCurrentChannel];
float range = ThumbRangeFor(fCurrentChannel); float range = ThumbRangeFor(fCurrentChannel);
if (_Vertical()) if (fIsVertical)
floatValue = range - (point.y - fMinpoint); floatValue = range - (point.y - fMinPoint);
else else
floatValue = range + (point.x - fMinpoint); floatValue = range + (point.x - fMinPoint);
int32 value = (int32)(floatValue / range * limitRange) + int32 value = (int32)(floatValue / range * limitRange) +
MinLimitList()[fCurrentChannel]; MinLimitList()[fCurrentChannel];
@@ -920,6 +932,9 @@ BChannelSlider::_MouseMovedCommon(BPoint point, BPoint point2)
} }
// #pragma mark - FBC padding
void BChannelSlider::_Reserved_BChannelSlider_0(void*, ...) {} void BChannelSlider::_Reserved_BChannelSlider_0(void*, ...) {}
void BChannelSlider::_Reserved_BChannelSlider_1(void*, ...) {} void BChannelSlider::_Reserved_BChannelSlider_1(void*, ...) {}
void BChannelSlider::_Reserved_BChannelSlider_2(void*, ...) {} void BChannelSlider::_Reserved_BChannelSlider_2(void*, ...) {}