* fix small mem leak
* whitespace cleanup, etc * some renaming to fit Haiku style git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28856 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,34 +10,27 @@
|
|||||||
/
|
/
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#if !defined(_CHANNEL_SLIDER_H)
|
#ifndef _CHANNEL_SLIDER_H
|
||||||
#define _CHANNEL_SLIDER_H
|
#define _CHANNEL_SLIDER_H
|
||||||
|
|
||||||
|
|
||||||
#include <ChannelControl.h>
|
#include <ChannelControl.h>
|
||||||
|
|
||||||
class BChannelSlider :
|
|
||||||
public BChannelControl
|
class BChannelSlider : public BChannelControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BChannelSlider(
|
BChannelSlider(BRect area, const char* name,
|
||||||
BRect area,
|
const char* label, BMessage* message,
|
||||||
const char * name,
|
|
||||||
const char * label,
|
|
||||||
BMessage * model,
|
|
||||||
int32 channels = 1,
|
int32 channels = 1,
|
||||||
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
BChannelSlider(
|
BChannelSlider(BRect area, const char* name,
|
||||||
BRect area,
|
const char* label, BMessage* message,
|
||||||
const char * name,
|
orientation o, int32 channels = 1,
|
||||||
const char * label,
|
|
||||||
BMessage * model,
|
|
||||||
orientation o,
|
|
||||||
int32 channels = 1,
|
|
||||||
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
uint32 flags = B_WILL_DRAW);
|
uint32 flags = B_WILL_DRAW);
|
||||||
BChannelSlider(
|
BChannelSlider(BMessage* archive);
|
||||||
BMessage * from);
|
|
||||||
virtual ~BChannelSlider();
|
virtual ~BChannelSlider();
|
||||||
|
|
||||||
static BArchivable* Instantiate(BMessage* from);
|
static BArchivable* Instantiate(BMessage* from);
|
||||||
@@ -59,8 +52,7 @@ virtual void MessageReceived(BMessage *msg);
|
|||||||
virtual void Draw(BRect area);
|
virtual void Draw(BRect area);
|
||||||
virtual void MouseDown(BPoint where);
|
virtual void MouseDown(BPoint where);
|
||||||
virtual void MouseUp(BPoint pt);
|
virtual void MouseUp(BPoint pt);
|
||||||
virtual void MouseMoved( BPoint pt,
|
virtual void MouseMoved(BPoint pt,uint32 code,
|
||||||
uint32 code,
|
|
||||||
const BMessage* message);
|
const BMessage* message);
|
||||||
virtual void WindowActivated(bool state);
|
virtual void WindowActivated(bool state);
|
||||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
@@ -74,29 +66,20 @@ virtual void SetEnabled(bool on);
|
|||||||
|
|
||||||
virtual void GetPreferredSize(float* width, float* height);
|
virtual void GetPreferredSize(float* width, float* height);
|
||||||
|
|
||||||
virtual BHandler *ResolveSpecifier(BMessage *msg,
|
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
|
||||||
int32 index,
|
BMessage* specifier, int32 form, const char* p);
|
||||||
BMessage *specifier,
|
|
||||||
int32 form,
|
|
||||||
const char *property);
|
|
||||||
virtual status_t GetSupportedSuites(BMessage* data);
|
virtual status_t GetSupportedSuites(BMessage* data);
|
||||||
|
|
||||||
// Perform rendering for an entire slider channel.
|
// Perform rendering for an entire slider channel.
|
||||||
virtual void DrawChannel(BView* into,
|
virtual void DrawChannel(BView* into, int32 channel, BRect area,
|
||||||
int32 channel,
|
|
||||||
BRect area,
|
|
||||||
bool pressed);
|
bool pressed);
|
||||||
|
|
||||||
// Draw the groove that appears behind a channel's thumb.
|
// Draw groove that appears behind a channel's thumb.
|
||||||
virtual void DrawGroove( BView* into,
|
virtual void DrawGroove(BView* into, int32 channel, BPoint lt,
|
||||||
int32 channel,
|
|
||||||
BPoint tl,
|
|
||||||
BPoint br);
|
BPoint br);
|
||||||
|
|
||||||
// Draw the thumb for a single channel.
|
// Draw the thumb for a single channel.
|
||||||
virtual void DrawThumb( BView* into,
|
virtual void DrawThumb(BView* into, int32 channel, BPoint where,
|
||||||
int32 channel,
|
|
||||||
BPoint where,
|
|
||||||
bool pressed);
|
bool pressed);
|
||||||
|
|
||||||
virtual const BBitmap* ThumbFor(int32 channel, bool pressed);
|
virtual const BBitmap* ThumbFor(int32 channel, bool pressed);
|
||||||
@@ -105,12 +88,8 @@ virtual float ThumbDeltaFor(int32 channel);
|
|||||||
virtual float ThumbRangeFor(int32 channel);
|
virtual float ThumbRangeFor(int32 channel);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef BChannelControl inherited;
|
BChannelSlider(const BChannelSlider &);
|
||||||
|
BChannelSlider& operator=(const BChannelSlider &);
|
||||||
BChannelSlider( /* unimplemented */
|
|
||||||
const BChannelSlider &);
|
|
||||||
BChannelSlider& operator=( /* unimplemented */
|
|
||||||
const BChannelSlider &);
|
|
||||||
|
|
||||||
|
|
||||||
virtual void _Reserved_BChannelSlider_0(void* , ...);
|
virtual void _Reserved_BChannelSlider_0(void* , ...);
|
||||||
@@ -141,17 +120,14 @@ virtual void _Reserved_BChannelSlider_7(void *, ...);
|
|||||||
|
|
||||||
uint32 _reserved_[12];
|
uint32 _reserved_[12];
|
||||||
|
|
||||||
void InitData();
|
void _InitData();
|
||||||
|
void _FinishChange();
|
||||||
void FinishChange();
|
void _UpdateFontDimens();
|
||||||
void UpdateFontDimens();
|
void _DrawThumbs();
|
||||||
void DrawThumbs();
|
void _DrawGrooveFrame(BView* where, const BRect& area);
|
||||||
void DrawThumbFrame(
|
bool _Vertical() const;
|
||||||
BView * where,
|
void _Redraw();
|
||||||
const BRect & area);
|
void _MouseMovedCommon(BPoint point, BPoint point2);
|
||||||
bool Vertical() const;
|
|
||||||
void Redraw();
|
|
||||||
void MouseMovedCommon(BPoint , BPoint );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005, Haiku Inc. All Rights Reserved.
|
* Copyright 2005 - 2008, Haiku Inc. All Rights Reserved.
|
||||||
* Author: Stefano Ceccherini ([email protected])
|
* Author: Stefano Ceccherini ([email protected])
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -34,18 +34,22 @@ kVerticalKnobData[] = {
|
|||||||
|
|
||||||
const static unsigned char
|
const static unsigned char
|
||||||
kHorizontalKnobData[] = {
|
kHorizontalKnobData[] = {
|
||||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
|
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
|
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
||||||
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f,
|
||||||
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x12, 0xff,
|
0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
|
||||||
0xff, 0xff, 0xff, 0xff, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0xff, 0xff,
|
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f,
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
|
||||||
|
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x0c, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0x12, 0x12, 0x12, 0x12,
|
||||||
|
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -62,11 +66,12 @@ sPropertyInfo[] = {
|
|||||||
|
|
||||||
const static float kPadding = 10.0;
|
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)
|
||||||
{
|
{
|
||||||
InitData();
|
_InitData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -75,7 +80,7 @@ BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
|
|||||||
: BChannelControl(area, name, label, model, channels, resizeMode, flags)
|
: BChannelControl(area, name, label, model, channels, resizeMode, flags)
|
||||||
|
|
||||||
{
|
{
|
||||||
InitData();
|
_InitData();
|
||||||
SetOrientation(o);
|
SetOrientation(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +88,7 @@ BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
|
|||||||
BChannelSlider::BChannelSlider(BMessage *archive)
|
BChannelSlider::BChannelSlider(BMessage *archive)
|
||||||
: BChannelControl(archive)
|
: BChannelControl(archive)
|
||||||
{
|
{
|
||||||
InitData();
|
_InitData();
|
||||||
|
|
||||||
orientation orient;
|
orientation orient;
|
||||||
if (archive->FindInt32("_orient", (int32 *)&orient) == B_OK)
|
if (archive->FindInt32("_orient", (int32 *)&orient) == B_OK)
|
||||||
@@ -93,6 +98,7 @@ BChannelSlider::BChannelSlider(BMessage *archive)
|
|||||||
|
|
||||||
BChannelSlider::~BChannelSlider()
|
BChannelSlider::~BChannelSlider()
|
||||||
{
|
{
|
||||||
|
delete fBacking;
|
||||||
delete fLeftKnob;
|
delete fLeftKnob;
|
||||||
delete fMidKnob;
|
delete fMidKnob;
|
||||||
delete fRightKnob;
|
delete fRightKnob;
|
||||||
@@ -124,7 +130,7 @@ BChannelSlider::Archive(BMessage *into, bool deep) const
|
|||||||
orientation
|
orientation
|
||||||
BChannelSlider::Orientation() const
|
BChannelSlider::Orientation() const
|
||||||
{
|
{
|
||||||
return Vertical() ? B_VERTICAL : B_HORIZONTAL;
|
return _Vertical() ? B_VERTICAL : B_HORIZONTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -132,7 +138,7 @@ void
|
|||||||
BChannelSlider::SetOrientation(orientation _orientation)
|
BChannelSlider::SetOrientation(orientation _orientation)
|
||||||
{
|
{
|
||||||
bool isVertical = _orientation == B_VERTICAL;
|
bool isVertical = _orientation == B_VERTICAL;
|
||||||
if (isVertical != Vertical()) {
|
if (isVertical != _Vertical()) {
|
||||||
fVertical = isVertical;
|
fVertical = isVertical;
|
||||||
Invalidate(Bounds());
|
Invalidate(Bounds());
|
||||||
}
|
}
|
||||||
@@ -160,28 +166,28 @@ BChannelSlider::AttachedToWindow()
|
|||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
SetViewColor(parent->ViewColor());
|
SetViewColor(parent->ViewColor());
|
||||||
|
|
||||||
inherited::AttachedToWindow();
|
BChannelControl::AttachedToWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::AllAttached()
|
BChannelSlider::AllAttached()
|
||||||
{
|
{
|
||||||
BControl::AllAttached();
|
BChannelControl::AllAttached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::DetachedFromWindow()
|
BChannelSlider::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
inherited::DetachedFromWindow();
|
BChannelControl::DetachedFromWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::AllDetached()
|
BChannelSlider::AllDetached()
|
||||||
{
|
{
|
||||||
BControl::AllDetached();
|
BChannelControl::AllDetached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,16 +195,16 @@ void
|
|||||||
BChannelSlider::MessageReceived(BMessage *message)
|
BChannelSlider::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case B_SET_PROPERTY:
|
case B_SET_PROPERTY: {
|
||||||
case B_GET_PROPERTY:
|
case B_GET_PROPERTY:
|
||||||
{
|
|
||||||
BMessage reply(B_REPLY);
|
BMessage reply(B_REPLY);
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
BMessage specifier;
|
BMessage specifier;
|
||||||
int32 what = 0;
|
int32 what = 0;
|
||||||
const char *property = NULL;
|
const char *property = NULL;
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
status_t status = message->GetCurrentSpecifier(&index, &specifier, &what, &property);
|
status_t status = message->GetCurrentSpecifier(&index, &specifier,
|
||||||
|
&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) {
|
||||||
@@ -218,12 +224,13 @@ BChannelSlider::MessageReceived(BMessage *message)
|
|||||||
if (handled) {
|
if (handled) {
|
||||||
reply.AddInt32("error", status);
|
reply.AddInt32("error", status);
|
||||||
message->SendReply(&reply);
|
message->SendReply(&reply);
|
||||||
} else
|
} else {
|
||||||
inherited::MessageReceived(message);
|
BChannelControl::MessageReceived(message);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
inherited::MessageReceived(message);
|
BChannelControl::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,8 +239,8 @@ BChannelSlider::MessageReceived(BMessage *message)
|
|||||||
void
|
void
|
||||||
BChannelSlider::Draw(BRect updateRect)
|
BChannelSlider::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
UpdateFontDimens();
|
_UpdateFontDimens();
|
||||||
DrawThumbs();
|
_DrawThumbs();
|
||||||
|
|
||||||
if (Label()) {
|
if (Label()) {
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
@@ -260,7 +267,7 @@ BChannelSlider::MouseDown(BPoint where)
|
|||||||
frame.OffsetBy(fClickDelta);
|
frame.OffsetBy(fClickDelta);
|
||||||
|
|
||||||
float range = ThumbRangeFor(channel);
|
float range = ThumbRangeFor(channel);
|
||||||
if (Vertical()) {
|
if (_Vertical()) {
|
||||||
fMinpoint = frame.top + frame.Height() / 2;
|
fMinpoint = frame.top + frame.Height() / 2;
|
||||||
frame.bottom += range;
|
frame.bottom += range;
|
||||||
} else {
|
} else {
|
||||||
@@ -305,19 +312,20 @@ BChannelSlider::MouseDown(BPoint where)
|
|||||||
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
|
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
|
||||||
if (!IsTracking()) {
|
if (!IsTracking()) {
|
||||||
SetTracking(true);
|
SetTracking(true);
|
||||||
DrawThumbs();
|
_DrawThumbs();
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseMovedCommon(where, B_ORIGIN);
|
_MouseMovedCommon(where, B_ORIGIN);
|
||||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
|
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS |
|
||||||
|
B_NO_POINTER_HISTORY);
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
snooze(30000);
|
snooze(30000);
|
||||||
GetMouse(&where, &buttons);
|
GetMouse(&where, &buttons);
|
||||||
MouseMovedCommon(where, B_ORIGIN);
|
_MouseMovedCommon(where, B_ORIGIN);
|
||||||
} while (buttons != 0);
|
} while (buttons != 0);
|
||||||
FinishChange();
|
_FinishChange();
|
||||||
fCurrentChannel = -1;
|
fCurrentChannel = -1;
|
||||||
fAllChannels = false;
|
fAllChannels = false;
|
||||||
}
|
}
|
||||||
@@ -329,13 +337,13 @@ void
|
|||||||
BChannelSlider::MouseUp(BPoint where)
|
BChannelSlider::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
if (IsEnabled() && IsTracking()) {
|
if (IsEnabled() && IsTracking()) {
|
||||||
FinishChange();
|
_FinishChange();
|
||||||
SetTracking(false);
|
SetTracking(false);
|
||||||
fAllChannels = false;
|
fAllChannels = false;
|
||||||
fCurrentChannel = -1;
|
fCurrentChannel = -1;
|
||||||
fMinpoint = 0;
|
fMinpoint = 0;
|
||||||
} else
|
} else
|
||||||
BControl::MouseUp(where);
|
BChannelControl::MouseUp(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -343,16 +351,16 @@ void
|
|||||||
BChannelSlider::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
BChannelSlider::MouseMoved(BPoint where, uint32 code, const BMessage *message)
|
||||||
{
|
{
|
||||||
if (IsEnabled() && IsTracking())
|
if (IsEnabled() && IsTracking())
|
||||||
MouseMovedCommon(where, B_ORIGIN);
|
_MouseMovedCommon(where, B_ORIGIN);
|
||||||
else
|
else
|
||||||
BControl::MouseMoved(where, code, message);
|
BChannelControl::MouseMoved(where, code, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::WindowActivated(bool state)
|
BChannelSlider::WindowActivated(bool state)
|
||||||
{
|
{
|
||||||
BControl::WindowActivated(state);
|
BChannelControl::WindowActivated(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -373,7 +381,7 @@ BChannelSlider::KeyUp(const char *bytes, int32 numBytes)
|
|||||||
void
|
void
|
||||||
BChannelSlider::FrameResized(float newWidth, float newHeight)
|
BChannelSlider::FrameResized(float newWidth, float newHeight)
|
||||||
{
|
{
|
||||||
inherited::FrameResized(newWidth, newHeight);
|
BChannelControl::FrameResized(newWidth, newHeight);
|
||||||
Invalidate(Bounds());
|
Invalidate(Bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +389,7 @@ BChannelSlider::FrameResized(float newWidth, float newHeight)
|
|||||||
void
|
void
|
||||||
BChannelSlider::SetFont(const BFont *font, uint32 mask)
|
BChannelSlider::SetFont(const BFont *font, uint32 mask)
|
||||||
{
|
{
|
||||||
inherited::SetFont(font, mask);
|
BChannelControl::SetFont(font, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -390,14 +398,14 @@ BChannelSlider::MakeFocus(bool focusState)
|
|||||||
{
|
{
|
||||||
if (focusState && !IsFocus())
|
if (focusState && !IsFocus())
|
||||||
fFocusChannel = -1;
|
fFocusChannel = -1;
|
||||||
BControl::MakeFocus(focusState);
|
BChannelControl::MakeFocus(focusState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::SetEnabled(bool on)
|
BChannelSlider::SetEnabled(bool on)
|
||||||
{
|
{
|
||||||
BControl::SetEnabled(on);
|
BChannelControl::SetEnabled(on);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -406,14 +414,14 @@ BChannelSlider::GetPreferredSize(float *width, float *height)
|
|||||||
{
|
{
|
||||||
if (width) {
|
if (width) {
|
||||||
float _width = (float)ceil(StringWidth(Label()));
|
float _width = (float)ceil(StringWidth(Label()));
|
||||||
if (Vertical()) {
|
if (_Vertical()) {
|
||||||
*width = max_c(_width, 2 + 12 * CountChannels());
|
*width = max_c(_width, 2 + 12 * CountChannels());
|
||||||
} else {
|
} else {
|
||||||
*width = max_c(_width, 64);
|
*width = max_c(_width, 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (height) {
|
if (height) {
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
*height = 195;
|
*height = 195;
|
||||||
else
|
else
|
||||||
*height = 71;
|
*height = 71;
|
||||||
@@ -427,9 +435,10 @@ BChannelSlider::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier
|
|||||||
{
|
{
|
||||||
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(msg, index, specifier, form, property) < B_OK) {
|
||||||
target = BChannelControl::ResolveSpecifier(msg, index, specifier, form, property);
|
target = BChannelControl::ResolveSpecifier(msg, index, specifier, form,
|
||||||
|
property);
|
||||||
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,7 +469,7 @@ BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed
|
|||||||
|
|
||||||
BPoint leftTop;
|
BPoint leftTop;
|
||||||
BPoint bottomRight;
|
BPoint bottomRight;
|
||||||
if (Vertical()) {
|
if (_Vertical()) {
|
||||||
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 {
|
||||||
@@ -471,7 +480,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 (_Vertical())
|
||||||
thumbLocation.y += ThumbDeltaFor(channel);
|
thumbLocation.y += ThumbDeltaFor(channel);
|
||||||
else
|
else
|
||||||
thumbLocation.x += ThumbDeltaFor(channel);
|
thumbLocation.x += ThumbDeltaFor(channel);
|
||||||
@@ -481,12 +490,13 @@ BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::DrawGroove(BView *into, int32 channel, BPoint topLeft, BPoint bottomRight)
|
BChannelSlider::DrawGroove(BView *into, int32 channel, BPoint leftTop,
|
||||||
|
BPoint bottomRight)
|
||||||
{
|
{
|
||||||
ASSERT(into != NULL);
|
ASSERT(into != NULL);
|
||||||
BRect rect(topLeft, bottomRight);
|
BRect rect(leftTop, bottomRight);
|
||||||
|
|
||||||
DrawThumbFrame(fBackingView, rect.InsetByCopy(-2.5, -2.5));
|
_DrawGrooveFrame(fBackingView, rect.InsetByCopy(-2.5, -2.5));
|
||||||
|
|
||||||
rect.InsetBy(-0.5, -0.5);
|
rect.InsetBy(-0.5, -0.5);
|
||||||
into->FillRect(rect, B_SOLID_HIGH);
|
into->FillRect(rect, B_SOLID_HIGH);
|
||||||
@@ -534,12 +544,14 @@ BChannelSlider::ThumbFor(int32 channel, bool pressed)
|
|||||||
{
|
{
|
||||||
// TODO: Finish me
|
// TODO: Finish me
|
||||||
if (fLeftKnob == NULL) {
|
if (fLeftKnob == NULL) {
|
||||||
if (Vertical()) {
|
if (_Vertical()) {
|
||||||
fLeftKnob = new BBitmap(BRect(0, 0, 11, 14), B_CMAP8);
|
fLeftKnob = new BBitmap(BRect(0, 0, 11, 14), B_CMAP8);
|
||||||
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData), 0, B_CMAP8);
|
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData),
|
||||||
|
0, B_CMAP8);
|
||||||
} else {
|
} else {
|
||||||
fLeftKnob = new BBitmap(BRect(0, 0, 14, 11), B_CMAP8);
|
fLeftKnob = new BBitmap(BRect(0, 0, 14, 11), B_CMAP8);
|
||||||
fLeftKnob->SetBits(kHorizontalKnobData, sizeof(kHorizontalKnobData), 0, B_CMAP8);
|
fLeftKnob->SetBits(kHorizontalKnobData, sizeof(kHorizontalKnobData),
|
||||||
|
0, B_CMAP8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,13 +562,13 @@ BChannelSlider::ThumbFor(int32 channel, bool pressed)
|
|||||||
BRect
|
BRect
|
||||||
BChannelSlider::ThumbFrameFor(int32 channel)
|
BChannelSlider::ThumbFrameFor(int32 channel)
|
||||||
{
|
{
|
||||||
UpdateFontDimens();
|
_UpdateFontDimens();
|
||||||
|
|
||||||
BRect frame(0, 0, 0, 0);
|
BRect frame(0, 0, 0, 0);
|
||||||
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 (_Vertical())
|
||||||
frame.OffsetBy(channel * frame.Width(), fLineFeed + kPadding);
|
frame.OffsetBy(channel * frame.Width(), fLineFeed + kPadding);
|
||||||
else
|
else
|
||||||
frame.OffsetBy(kPadding, fLineFeed + channel * frame.Height());
|
frame.OffsetBy(kPadding, fLineFeed + channel * frame.Height());
|
||||||
@@ -575,7 +587,7 @@ BChannelSlider::ThumbDeltaFor(int32 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 (_Vertical())
|
||||||
delta = range - delta;
|
delta = range - delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,12 +598,12 @@ BChannelSlider::ThumbDeltaFor(int32 channel)
|
|||||||
float
|
float
|
||||||
BChannelSlider::ThumbRangeFor(int32 channel)
|
BChannelSlider::ThumbRangeFor(int32 channel)
|
||||||
{
|
{
|
||||||
UpdateFontDimens();
|
_UpdateFontDimens();
|
||||||
|
|
||||||
float range = 0;
|
float range = 0;
|
||||||
BRect bounds = Bounds();
|
BRect bounds = Bounds();
|
||||||
BRect frame = ThumbFrameFor(channel);
|
BRect frame = ThumbFrameFor(channel);
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
range = bounds.Height() - frame.Height() - (kPadding + fLineFeed) * 2;
|
range = bounds.Height() - frame.Height() - (kPadding + fLineFeed) * 2;
|
||||||
else
|
else
|
||||||
range = bounds.Width() - frame.Width() - kPadding * 2;
|
range = bounds.Width() - frame.Width() - kPadding * 2;
|
||||||
@@ -601,9 +613,9 @@ BChannelSlider::ThumbRangeFor(int32 channel)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::InitData()
|
BChannelSlider::_InitData()
|
||||||
{
|
{
|
||||||
UpdateFontDimens();
|
_UpdateFontDimens();
|
||||||
|
|
||||||
fLeftKnob = NULL;
|
fLeftKnob = NULL;
|
||||||
fMidKnob = NULL;
|
fMidKnob = NULL;
|
||||||
@@ -624,7 +636,7 @@ BChannelSlider::InitData()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::FinishChange()
|
BChannelSlider::_FinishChange()
|
||||||
{
|
{
|
||||||
if (fInitialValues != NULL) {
|
if (fInitialValues != NULL) {
|
||||||
bool *inMask = NULL;
|
bool *inMask = NULL;
|
||||||
@@ -639,12 +651,12 @@ BChannelSlider::FinishChange()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetTracking(false);
|
SetTracking(false);
|
||||||
Redraw();
|
_Redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::UpdateFontDimens()
|
BChannelSlider::_UpdateFontDimens()
|
||||||
{
|
{
|
||||||
font_height height;
|
font_height height;
|
||||||
GetFontHeight(&height);
|
GetFontHeight(&height);
|
||||||
@@ -654,7 +666,7 @@ BChannelSlider::UpdateFontDimens()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::DrawThumbs()
|
BChannelSlider::_DrawThumbs()
|
||||||
{
|
{
|
||||||
if (fBacking == NULL) {
|
if (fBacking == NULL) {
|
||||||
// This is the idea: we build a bitmap by taking the coordinates
|
// This is the idea: we build a bitmap by taking the coordinates
|
||||||
@@ -663,20 +675,15 @@ BChannelSlider::DrawThumbs()
|
|||||||
BRect last = ThumbFrameFor(CountChannels() - 1);
|
BRect last = ThumbFrameFor(CountChannels() - 1);
|
||||||
BRect bitmapFrame(first.LeftTop(), last.RightBottom());
|
BRect bitmapFrame(first.LeftTop(), last.RightBottom());
|
||||||
|
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
bitmapFrame.top -= ThumbRangeFor(0);
|
bitmapFrame.top -= ThumbRangeFor(0);
|
||||||
else
|
else
|
||||||
bitmapFrame.right += ThumbRangeFor(0);
|
bitmapFrame.right += ThumbRangeFor(0);
|
||||||
|
|
||||||
fBacking = new BBitmap(bitmapFrame.OffsetToCopy(B_ORIGIN),
|
bitmapFrame.OffsetTo(B_ORIGIN);
|
||||||
#ifdef __HAIKU__
|
fBacking = new BBitmap(bitmapFrame, B_RGBA32, true, false);
|
||||||
BScreen(Window()).ColorSpace(),
|
|
||||||
#else
|
|
||||||
B_RGB32,
|
|
||||||
#endif
|
|
||||||
true, false);
|
|
||||||
if (fBacking->Lock()) {
|
if (fBacking->Lock()) {
|
||||||
fBackingView = new BView(bitmapFrame.OffsetToCopy(B_ORIGIN), "backing view", B_FOLLOW_NONE, B_WILL_DRAW);
|
fBackingView = new BView(bitmapFrame, "", 0, B_WILL_DRAW);
|
||||||
fBacking->AddChild(fBackingView);
|
fBacking->AddChild(fBackingView);
|
||||||
fBackingView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fBackingView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
fBackingView->SetLowColor(fBackingView->ViewColor());
|
fBackingView->SetLowColor(fBackingView->ViewColor());
|
||||||
@@ -700,7 +707,7 @@ BChannelSlider::DrawThumbs()
|
|||||||
// 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
|
||||||
// bitmap. Still this doesn't make much sense:
|
// bitmap. Still this doesn't make much sense:
|
||||||
// could be that I'm simply missing something.
|
// could be that I'm simply missing something.
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
channelArea.OffsetBy(0, -channelArea.top);
|
channelArea.OffsetBy(0, -channelArea.top);
|
||||||
else
|
else
|
||||||
channelArea.OffsetBy(0, -channelArea.Height());
|
channelArea.OffsetBy(0, -channelArea.Height());
|
||||||
@@ -718,7 +725,7 @@ BChannelSlider::DrawThumbs()
|
|||||||
float width = fBackingView->StringWidth(valueString);
|
float width = fBackingView->StringWidth(valueString);
|
||||||
BRect valueRect(0, 0, width, 10);
|
BRect valueRect(0, 0, width, 10);
|
||||||
rgb_color oldColor = fBackingView->HighColor();
|
rgb_color oldColor = fBackingView->HighColor();
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
valueRect.OffsetTo((ThumbFrameFor(fCurrentChannel).Width() - width) / 2 + fCurrentChannel * ThumbFrameFor(fCurrentChannel).Width(),
|
valueRect.OffsetTo((ThumbFrameFor(fCurrentChannel).Width() - width) / 2 + fCurrentChannel * ThumbFrameFor(fCurrentChannel).Width(),
|
||||||
ThumbDeltaFor(fCurrentChannel));
|
ThumbDeltaFor(fCurrentChannel));
|
||||||
else
|
else
|
||||||
@@ -763,7 +770,7 @@ BChannelSlider::DrawThumbs()
|
|||||||
fClickDelta = drawHere;
|
fClickDelta = drawHere;
|
||||||
|
|
||||||
// TODO: See above
|
// TODO: See above
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
fClickDelta.y -= ThumbFrameFor(0).top;
|
fClickDelta.y -= ThumbFrameFor(0).top;
|
||||||
else
|
else
|
||||||
fClickDelta.y -= ThumbFrameFor(0).Height();
|
fClickDelta.y -= ThumbFrameFor(0).Height();
|
||||||
@@ -771,7 +778,7 @@ BChannelSlider::DrawThumbs()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::DrawThumbFrame(BView *into, const BRect &area)
|
BChannelSlider::_DrawGrooveFrame(BView *into, const BRect &area)
|
||||||
{
|
{
|
||||||
rgb_color oldColor = into->HighColor();
|
rgb_color oldColor = into->HighColor();
|
||||||
|
|
||||||
@@ -789,14 +796,14 @@ BChannelSlider::DrawThumbFrame(BView *into, const BRect &area)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BChannelSlider::Vertical() const
|
BChannelSlider::_Vertical() const
|
||||||
{
|
{
|
||||||
return fVertical;
|
return fVertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::Redraw()
|
BChannelSlider::_Redraw()
|
||||||
{
|
{
|
||||||
Invalidate(Bounds());
|
Invalidate(Bounds());
|
||||||
Flush();
|
Flush();
|
||||||
@@ -804,23 +811,25 @@ BChannelSlider::Redraw()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BChannelSlider::MouseMovedCommon(BPoint point, BPoint point2)
|
BChannelSlider::_MouseMovedCommon(BPoint point, BPoint point2)
|
||||||
{
|
{
|
||||||
float floatValue = 0;
|
float floatValue = 0;
|
||||||
int32 limitRange = MaxLimitList()[fCurrentChannel] - MinLimitList()[fCurrentChannel];
|
int32 limitRange = MaxLimitList()[fCurrentChannel] -
|
||||||
|
MinLimitList()[fCurrentChannel];
|
||||||
float range = ThumbRangeFor(fCurrentChannel);
|
float range = ThumbRangeFor(fCurrentChannel);
|
||||||
if (Vertical())
|
if (_Vertical())
|
||||||
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) + MinLimitList()[fCurrentChannel];
|
int32 value = (int32)(floatValue / range * limitRange) +
|
||||||
|
MinLimitList()[fCurrentChannel];
|
||||||
if (fAllChannels)
|
if (fAllChannels)
|
||||||
SetAllValue(value);
|
SetAllValue(value);
|
||||||
else
|
else
|
||||||
SetValueFor(fCurrentChannel, value);
|
SetValueFor(fCurrentChannel, value);
|
||||||
|
|
||||||
DrawThumbs();
|
_DrawThumbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user