2 * Copyright 2005-2015, Haiku Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Stefano Ceccherini (stefano.ceccherini@gmail.com)
7 * Stephan Aßmus <superstippi@gmx.de>
10 #include <ChannelSlider.h>
15 #include <ControlLook.h>
17 #include <PropertyInfo.h>
22 const static unsigned char
23 kVerticalKnobData
[] = {
24 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
25 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
26 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff,
27 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff,
28 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
29 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
30 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
31 0xff, 0x00, 0x3f, 0x3f, 0xcb, 0xcb, 0xcb, 0xcb, 0x3f, 0x3f, 0x00, 0x12,
32 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
33 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
34 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
35 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
36 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12,
37 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x12,
38 0xff, 0xff, 0xff, 0xff, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0xff
42 const static unsigned char
43 kHorizontalKnobData
[] = {
44 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
46 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f,
47 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
48 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f,
49 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb,
50 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f,
51 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
52 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f,
53 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
54 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f,
55 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
56 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x0c, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0x12, 0x12, 0x12, 0x12,
58 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
59 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
66 { B_GET_PROPERTY
, B_SET_PROPERTY
, 0 },
67 { B_DIRECT_SPECIFIER
, 0 }, NULL
, 0, { B_INT32_TYPE
}
74 const static float kPadding
= 3.0;
77 BChannelSlider::BChannelSlider(BRect area
, const char* name
, const char* label
,
78 BMessage
* model
, int32 channels
, uint32 resizeMode
, uint32 flags
)
79 : BChannelControl(area
, name
, label
, model
, channels
, resizeMode
, flags
)
85 BChannelSlider::BChannelSlider(BRect area
, const char* name
, const char* label
,
86 BMessage
* model
, orientation orientation
, int32 channels
,
87 uint32 resizeMode
, uint32 flags
)
88 : BChannelControl(area
, name
, label
, model
, channels
, resizeMode
, flags
)
92 SetOrientation(orientation
);
96 BChannelSlider::BChannelSlider(const char* name
, const char* label
,
97 BMessage
* model
, orientation orientation
, int32 channels
,
99 : BChannelControl(name
, label
, model
, channels
, flags
)
103 SetOrientation(orientation
);
107 BChannelSlider::BChannelSlider(BMessage
* archive
)
108 : BChannelControl(archive
)
113 if (archive
->FindInt32("_orient", (int32
*)&orient
) == B_OK
)
114 SetOrientation(orient
);
118 BChannelSlider::~BChannelSlider()
124 delete[] fInitialValues
;
129 BChannelSlider::Instantiate(BMessage
* archive
)
131 if (validate_instantiation(archive
, "BChannelSlider"))
132 return new (std::nothrow
) BChannelSlider(archive
);
139 BChannelSlider::Archive(BMessage
* into
, bool deep
) const
141 status_t status
= BChannelControl::Archive(into
, deep
);
143 status
= into
->AddInt32("_orient", (int32
)Orientation());
150 BChannelSlider::AttachedToWindow()
152 BView
* parent
= Parent();
154 SetViewColor(parent
->ViewColor());
156 BChannelControl::AttachedToWindow();
161 BChannelSlider::AllAttached()
163 BChannelControl::AllAttached();
168 BChannelSlider::DetachedFromWindow()
170 BChannelControl::DetachedFromWindow();
175 BChannelSlider::AllDetached()
177 BChannelControl::AllDetached();
182 BChannelSlider::MessageReceived(BMessage
* message
)
184 switch (message
->what
) {
185 case B_SET_PROPERTY
: {
187 BMessage
reply(B_REPLY
);
191 const char* property
= NULL
;
192 bool handled
= false;
193 status_t status
= message
->GetCurrentSpecifier(&index
, &specifier
,
195 BPropertyInfo
propInfo(sPropertyInfo
);
197 && propInfo
.FindMatch(message
, index
, &specifier
, what
,
200 if (message
->what
== B_SET_PROPERTY
) {
202 if (specifier
.FindInt32("data", (int32
*)&orient
) == B_OK
) {
203 SetOrientation(orient
);
204 Invalidate(Bounds());
206 } else if (message
->what
== B_GET_PROPERTY
)
207 reply
.AddInt32("result", (int32
)Orientation());
209 status
= B_BAD_SCRIPT_SYNTAX
;
213 reply
.AddInt32("error", status
);
214 message
->SendReply(&reply
);
216 BChannelControl::MessageReceived(message
);
221 BChannelControl::MessageReceived(message
);
228 BChannelSlider::Draw(BRect updateRect
)
233 BRect
bounds(Bounds());
235 float labelWidth
= StringWidth(Label());
236 DrawString(Label(), BPoint((bounds
.Width() - labelWidth
) / 2.0,
240 if (MinLimitLabel()) {
242 if (MinLimitLabel()) {
243 float x
= (bounds
.Width() - StringWidth(MinLimitLabel()))
245 DrawString(MinLimitLabel(), BPoint(x
, bounds
.bottom
249 if (MinLimitLabel()) {
250 DrawString(MinLimitLabel(), BPoint(kPadding
, bounds
.bottom
256 if (MaxLimitLabel()) {
258 if (MaxLimitLabel()) {
259 float x
= (bounds
.Width() - StringWidth(MaxLimitLabel()))
261 DrawString(MaxLimitLabel(), BPoint(x
, 2 * fLineFeed
));
264 if (MaxLimitLabel()) {
265 DrawString(MaxLimitLabel(), BPoint(bounds
.right
- kPadding
266 - StringWidth(MaxLimitLabel()), bounds
.bottom
- kPadding
));
274 BChannelSlider::MouseDown(BPoint where
)
277 BControl::MouseDown(where
);
279 fCurrentChannel
= -1;
282 // Search the channel on which the mouse was over
283 int32 numChannels
= CountChannels();
284 for (int32 channel
= 0; channel
< numChannels
; channel
++) {
285 BRect frame
= ThumbFrameFor(channel
);
286 frame
.OffsetBy(fClickDelta
);
288 float range
= ThumbRangeFor(channel
);
290 fMinPoint
= frame
.top
+ frame
.Height() / 2;
291 frame
.bottom
+= range
;
293 // TODO: Fix this, the clickzone isn't perfect
294 frame
.right
+= range
;
295 fMinPoint
= frame
.Width();
298 // Click was on a slider.
299 if (frame
.Contains(where
)) {
300 fCurrentChannel
= channel
;
301 SetCurrentChannel(channel
);
306 // Click wasn't on a slider. Bail out.
307 if (fCurrentChannel
== -1)
311 BMessage
* currentMessage
= Window()->CurrentMessage();
312 if (currentMessage
!= NULL
)
313 currentMessage
->FindInt32("buttons", (int32
*)&buttons
);
315 fAllChannels
= (buttons
& B_SECONDARY_MOUSE_BUTTON
) == 0;
317 if (fInitialValues
!= NULL
&& fAllChannels
) {
318 delete[] fInitialValues
;
319 fInitialValues
= NULL
;
322 if (fInitialValues
== NULL
)
323 fInitialValues
= new (std::nothrow
) int32
[numChannels
];
325 if (fInitialValues
) {
327 for (int32 i
= 0; i
< numChannels
; i
++)
328 fInitialValues
[i
] = ValueFor(i
);
330 fInitialValues
[fCurrentChannel
] = ValueFor(fCurrentChannel
);
334 if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS
) {
341 _MouseMovedCommon(where
, B_ORIGIN
);
342 SetMouseEventMask(B_POINTER_EVENTS
, B_LOCK_WINDOW_FOCUS
|
343 B_NO_POINTER_HISTORY
);
347 GetMouse(&where
, &buttons
);
348 _MouseMovedCommon(where
, B_ORIGIN
);
349 } while (buttons
!= 0);
351 fCurrentChannel
= -1;
352 fAllChannels
= false;
359 BChannelSlider::MouseUp(BPoint where
)
361 if (IsEnabled() && IsTracking()) {
364 fAllChannels
= false;
365 fCurrentChannel
= -1;
368 BChannelControl::MouseUp(where
);
374 BChannelSlider::MouseMoved(BPoint where
, uint32 code
, const BMessage
* message
)
376 if (IsEnabled() && IsTracking())
377 _MouseMovedCommon(where
, B_ORIGIN
);
379 BChannelControl::MouseMoved(where
, code
, message
);
384 BChannelSlider::WindowActivated(bool state
)
386 BChannelControl::WindowActivated(state
);
391 BChannelSlider::KeyDown(const char* bytes
, int32 numBytes
)
393 BControl::KeyDown(bytes
, numBytes
);
398 BChannelSlider::KeyUp(const char* bytes
, int32 numBytes
)
400 BView::KeyUp(bytes
, numBytes
);
405 BChannelSlider::FrameResized(float newWidth
, float newHeight
)
407 BChannelControl::FrameResized(newWidth
, newHeight
);
412 Invalidate(Bounds());
417 BChannelSlider::SetFont(const BFont
* font
, uint32 mask
)
419 BChannelControl::SetFont(font
, mask
);
424 BChannelSlider::MakeFocus(bool focusState
)
426 if (focusState
&& !IsFocus())
428 BChannelControl::MakeFocus(focusState
);
433 BChannelSlider::GetPreferredSize(float* width
, float* height
)
438 *width
= 11.0 * CountChannels();
439 *width
= max_c(*width
, ceilf(StringWidth(Label())));
440 *width
= max_c(*width
, ceilf(StringWidth(MinLimitLabel())));
441 *width
= max_c(*width
, ceilf(StringWidth(MaxLimitLabel())));
442 *width
+= kPadding
* 2.0;
444 *height
= (fLineFeed
* 3.0) + (kPadding
* 2.0) + 147.0;
446 *width
= max_c(64.0, ceilf(StringWidth(Label())));
447 *width
= max_c(*width
, ceilf(StringWidth(MinLimitLabel()))
448 + ceilf(StringWidth(MaxLimitLabel())) + 10.0);
449 *width
+= kPadding
* 2.0;
451 *height
= 11.0 * CountChannels() + (fLineFeed
* 2.0)
458 BChannelSlider::ResolveSpecifier(BMessage
* message
, int32 index
,
459 BMessage
* specifier
, int32 form
, const char* property
)
461 BHandler
* target
= this;
462 BPropertyInfo
propertyInfo(sPropertyInfo
);
463 if (propertyInfo
.FindMatch(message
, index
, specifier
, form
,
465 target
= BChannelControl::ResolveSpecifier(message
, index
, specifier
,
473 BChannelSlider::GetSupportedSuites(BMessage
* data
)
478 status_t err
= data
->AddString("suites", "suite/vnd.Be-channel-slider");
480 BPropertyInfo
propInfo(sPropertyInfo
);
482 err
= data
->AddFlat("messages", &propInfo
);
485 return BChannelControl::GetSupportedSuites(data
);
491 BChannelSlider::SetEnabled(bool on
)
493 BChannelControl::SetEnabled(on
);
498 BChannelSlider::Orientation() const
500 return fIsVertical
? B_VERTICAL
: B_HORIZONTAL
;
505 BChannelSlider::SetOrientation(orientation orientation
)
507 bool isVertical
= orientation
== B_VERTICAL
;
508 if (isVertical
!= fIsVertical
) {
509 fIsVertical
= isVertical
;
511 Invalidate(Bounds());
517 BChannelSlider::MaxChannelCount() const
524 BChannelSlider::SupportsIndividualLimits() const
531 BChannelSlider::DrawChannel(BView
* into
, int32 channel
, BRect area
,
534 float hCenter
= area
.Width() / 2;
535 float vCenter
= area
.Height() / 2;
540 leftTop
.Set(area
.left
+ hCenter
, area
.top
+ vCenter
);
541 bottomRight
.Set(leftTop
.x
, leftTop
.y
+ ThumbRangeFor(channel
));
543 leftTop
.Set(area
.left
, area
.top
+ vCenter
);
544 bottomRight
.Set(area
.left
+ ThumbRangeFor(channel
), leftTop
.y
);
547 DrawGroove(into
, channel
, leftTop
, bottomRight
);
549 BPoint thumbLocation
= leftTop
;
551 thumbLocation
.y
+= ThumbDeltaFor(channel
);
553 thumbLocation
.x
+= ThumbDeltaFor(channel
);
555 DrawThumb(into
, channel
, thumbLocation
, pressed
);
560 BChannelSlider::DrawGroove(BView
* into
, int32 channel
, BPoint leftTop
,
563 ASSERT(into
!= NULL
);
564 BRect
rect(leftTop
, bottomRight
);
566 rect
.InsetBy(-2.5, -2.5);
567 rect
.left
= floorf(rect
.left
);
568 rect
.top
= floorf(rect
.top
);
569 rect
.right
= floorf(rect
.right
);
570 rect
.bottom
= floorf(rect
.bottom
);
571 rgb_color base
= ui_color(B_PANEL_BACKGROUND_COLOR
);
572 rgb_color barColor
= be_control_look
->SliderBarColor(base
);
574 be_control_look
->DrawSliderBar(into
, rect
, rect
, base
,
575 barColor
, flags
, Orientation());
580 BChannelSlider::DrawThumb(BView
* into
, int32 channel
, BPoint where
,
583 ASSERT(into
!= NULL
);
585 const BBitmap
* thumb
= ThumbFor(channel
, pressed
);
589 BRect
bitmapBounds(thumb
->Bounds());
590 where
.x
-= bitmapBounds
.right
/ 2.0;
591 where
.y
-= bitmapBounds
.bottom
/ 2.0;
593 BRect
rect(bitmapBounds
.OffsetToCopy(where
));
595 rect
.left
= floorf(rect
.left
);
596 rect
.top
= floorf(rect
.top
);
597 rect
.right
= ceilf(rect
.right
+ 0.5);
598 rect
.bottom
= ceilf(rect
.bottom
+ 0.5);
599 rgb_color base
= ui_color(B_PANEL_BACKGROUND_COLOR
);
601 be_control_look
->DrawSliderThumb(into
, rect
, rect
, base
,
602 flags
, Orientation());
607 BChannelSlider::ThumbFor(int32 channel
, bool pressed
)
609 if (fLeftKnob
!= NULL
)
613 fLeftKnob
= new (std::nothrow
) BBitmap(BRect(0, 0, 11, 14),
615 if (fLeftKnob
!= NULL
) {
616 fLeftKnob
->SetBits(kVerticalKnobData
,
617 sizeof(kVerticalKnobData
), 0, B_CMAP8
);
620 fLeftKnob
= new (std::nothrow
) BBitmap(BRect(0, 0, 14, 11),
622 if (fLeftKnob
!= NULL
) {
623 fLeftKnob
->SetBits(kHorizontalKnobData
,
624 sizeof(kHorizontalKnobData
), 0, B_CMAP8
);
633 BChannelSlider::ThumbFrameFor(int32 channel
)
637 BRect
frame(0.0, 0.0, 0.0, 0.0);
638 const BBitmap
* thumb
= ThumbFor(channel
, false);
640 frame
= thumb
->Bounds();
642 frame
.OffsetBy(channel
* frame
.Width(), (frame
.Height() / 2.0) -
643 (kPadding
* 2.0) - 1.0);
645 frame
.OffsetBy(frame
.Width() / 2.0, channel
* frame
.Height()
654 BChannelSlider::ThumbDeltaFor(int32 channel
)
657 if (channel
>= 0 && channel
< MaxChannelCount()) {
658 float range
= ThumbRangeFor(channel
);
659 int32 limitRange
= MaxLimitList()[channel
] - MinLimitList()[channel
];
660 delta
= (ValueList()[channel
] - MinLimitList()[channel
]) * range
664 delta
= range
- delta
;
672 BChannelSlider::ThumbRangeFor(int32 channel
)
677 BRect bounds
= Bounds();
678 BRect frame
= ThumbFrameFor(channel
);
680 // *height = (fLineFeed * 3.0) + (kPadding * 2.0) + 100.0;
681 range
= bounds
.Height() - frame
.Height() - (fLineFeed
* 3.0) -
684 // *width = some width + kPadding * 2.0;
685 range
= bounds
.Width() - frame
.Width() - (kPadding
* 2.0);
695 BChannelSlider::_InitData()
704 fIsVertical
= Bounds().Width() / Bounds().Height() < 1;
705 fClickDelta
= B_ORIGIN
;
707 fCurrentChannel
= -1;
708 fAllChannels
= false;
709 fInitialValues
= NULL
;
713 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR
));
718 BChannelSlider::_FinishChange(bool update
)
720 if (fInitialValues
!= NULL
) {
722 int32 numChannels
= CountChannels();
724 inMask
= new (std::nothrow
) bool[CountChannels()];
726 for (int i
= 0; i
< numChannels
; i
++)
728 inMask
[fCurrentChannel
] = true;
731 InvokeChannel(update
? ModificationMessage() : NULL
, 0, numChannels
,
745 BChannelSlider::_UpdateFontDimens()
748 GetFontHeight(&height
);
749 fBaseLine
= height
.ascent
+ height
.leading
;
750 fLineFeed
= fBaseLine
+ height
.descent
;
755 BChannelSlider::_DrawThumbs()
757 if (fBacking
== NULL
) {
758 // This is the idea: we build a bitmap by taking the coordinates
759 // of the first and last thumb frames (top/left and bottom/right)
760 BRect first
= ThumbFrameFor(0);
761 BRect last
= ThumbFrameFor(CountChannels() - 1);
762 BRect
rect(first
.LeftTop(), last
.RightBottom());
765 rect
.top
-= ThumbRangeFor(0);
767 rect
.right
+= ThumbRangeFor(0);
769 rect
.OffsetTo(B_ORIGIN
);
770 fBacking
= new (std::nothrow
) BBitmap(rect
, B_RGB32
, true);
772 fBackingView
= new (std::nothrow
) BView(rect
, "", 0, B_WILL_DRAW
);
774 if (fBacking
->Lock()) {
775 fBacking
->AddChild(fBackingView
);
776 fBackingView
->SetFontSize(10.0);
777 fBackingView
->SetLowColor(
778 ui_color(B_PANEL_BACKGROUND_COLOR
));
779 fBackingView
->SetViewColor(
780 ui_color(B_PANEL_BACKGROUND_COLOR
));
790 if (fBacking
&& fBackingView
) {
793 BRect
bounds(fBacking
->Bounds());
794 drawHere
.x
= (Bounds().Width() - bounds
.Width()) / 2.0;
795 drawHere
.y
= (Bounds().Height() - bounds
.Height()) - kPadding
798 if (fBacking
->Lock()) {
799 // Clear the view's background
800 fBackingView
->FillRect(fBackingView
->Bounds(), B_SOLID_LOW
);
803 // draw the entire control
804 for (int32 channel
= 0; channel
< CountChannels(); channel
++) {
805 channelArea
= ThumbFrameFor(channel
);
806 bool pressed
= IsTracking()
807 && (channel
== fCurrentChannel
|| fAllChannels
);
808 DrawChannel(fBackingView
, channel
, channelArea
, pressed
);
811 // draw some kind of current value tool tip
812 if (fCurrentChannel
!= -1 && fMinPoint
!= 0) {
813 char valueString
[32];
814 snprintf(valueString
, 32, "%" B_PRId32
,
815 ValueFor(fCurrentChannel
));
816 float stringWidth
= fBackingView
->StringWidth(valueString
);
817 float width
= max_c(10.0, stringWidth
);
818 BRect
valueRect(0.0, 0.0, width
, 10.0);
820 BRect
thumbFrame(ThumbFrameFor(fCurrentChannel
));
821 float thumbDelta(ThumbDeltaFor(fCurrentChannel
));
824 valueRect
.OffsetTo((thumbFrame
.Width() - width
) / 2.0
825 + fCurrentChannel
* thumbFrame
.Width(),
826 thumbDelta
+ thumbFrame
.Height() + 2.0);
827 if (valueRect
.bottom
> fBackingView
->Frame().bottom
)
828 valueRect
.OffsetBy(0.0, -(thumbFrame
.Height() + 12.0));
830 valueRect
.OffsetTo((thumbDelta
- (width
+ 2.0)),
832 if (valueRect
.left
< fBackingView
->Frame().left
) {
833 valueRect
.OffsetBy(thumbFrame
.Width() + width
+ 2.0,
838 rgb_color oldColor
= fBackingView
->HighColor();
839 fBackingView
->SetHighColor(255, 255, 172);
840 fBackingView
->FillRect(valueRect
);
841 fBackingView
->SetHighColor(0, 0, 0);
842 fBackingView
->DrawString(valueString
, BPoint(valueRect
.left
843 + (valueRect
.Width() - stringWidth
) / 2.0, valueRect
.bottom
845 fBackingView
->StrokeRect(valueRect
.InsetByCopy(-0.5, -0.5));
846 fBackingView
->SetHighColor(oldColor
);
849 fBackingView
->Sync();
853 DrawBitmapAsync(fBacking
, drawHere
);
855 // fClickDelta is used in MouseMoved()
856 fClickDelta
= drawHere
;
862 BChannelSlider::_DrawGrooveFrame(BView
* into
, const BRect
& area
)
865 rgb_color oldColor
= into
->HighColor();
867 into
->SetHighColor(255, 255, 255);
868 into
->StrokeRect(area
);
869 into
->SetHighColor(tint_color(into
->ViewColor(), B_DARKEN_1_TINT
));
870 into
->StrokeLine(area
.LeftTop(), BPoint(area
.right
, area
.top
));
871 into
->StrokeLine(area
.LeftTop(), BPoint(area
.left
, area
.bottom
- 1));
872 into
->SetHighColor(tint_color(into
->ViewColor(), B_DARKEN_2_TINT
));
873 into
->StrokeLine(BPoint(area
.left
+ 1, area
.top
+ 1),
874 BPoint(area
.right
- 1, area
.top
+ 1));
875 into
->StrokeLine(BPoint(area
.left
+ 1, area
.top
+ 1),
876 BPoint(area
.left
+ 1, area
.bottom
- 2));
878 into
->SetHighColor(oldColor
);
884 BChannelSlider::_MouseMovedCommon(BPoint point
, BPoint point2
)
886 float floatValue
= 0;
887 int32 limitRange
= MaxLimitList()[fCurrentChannel
] -
888 MinLimitList()[fCurrentChannel
];
889 float range
= ThumbRangeFor(fCurrentChannel
);
891 floatValue
= range
- (point
.y
- fMinPoint
);
893 floatValue
= range
+ (point
.x
- fMinPoint
);
895 int32 value
= (int32
)(floatValue
/ range
* limitRange
) +
896 MinLimitList()[fCurrentChannel
];
900 SetValueFor(fCurrentChannel
, value
);
902 if (ModificationMessage())
909 // #pragma mark - FBC padding
912 void BChannelSlider::_Reserved_BChannelSlider_0(void*, ...) {}
913 void BChannelSlider::_Reserved_BChannelSlider_1(void*, ...) {}
914 void BChannelSlider::_Reserved_BChannelSlider_2(void*, ...) {}
915 void BChannelSlider::_Reserved_BChannelSlider_3(void*, ...) {}
916 void BChannelSlider::_Reserved_BChannelSlider_4(void*, ...) {}
917 void BChannelSlider::_Reserved_BChannelSlider_5(void*, ...) {}
918 void BChannelSlider::_Reserved_BChannelSlider_6(void*, ...) {}
919 void BChannelSlider::_Reserved_BChannelSlider_7(void*, ...) {}