* Removed a superfluous SetMouseEventMask() in the Slider constructor (at least
it was good enough to fix SetMouseEventMask() to no longer drop into the debugger). * Minor cleanup, renamed member variables to comply with our style guide. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15832 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+132
-125
@@ -1,19 +1,12 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// Program: desklink
|
||||
// Author: Jérôme DUVAL
|
||||
// Description: VolumeControl and link items in Deskbar
|
||||
// Created : October 20, 2003
|
||||
// Modified by: Jérome Duval
|
||||
// Modified by: François Revol, 10/31/2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright (c) 2003-2005, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval
|
||||
* François Revol
|
||||
*/
|
||||
|
||||
|
||||
#include <MediaRoster.h>
|
||||
#include <MediaTheme.h>
|
||||
@@ -30,15 +23,19 @@
|
||||
#define VOLUME_CHANGED 'vlcg'
|
||||
#define VOLUME_UPDATED 'vlud'
|
||||
|
||||
#define REDZONESTART 151
|
||||
|
||||
|
||||
VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
: BWindow(frame, "VolumeSlider", B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK, 0),
|
||||
aOutNode(NULL),
|
||||
paramWeb(NULL),
|
||||
mixerParam(NULL)
|
||||
: BWindow(frame, "VolumeSlider", B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_WILL_ACCEPT_FIRST_CLICK, 0),
|
||||
fAudioMixerNode(NULL),
|
||||
fParamWeb(NULL),
|
||||
fMixerParam(NULL)
|
||||
{
|
||||
//Make sure it's not outside the screen.
|
||||
// Make sure it's not outside the screen.
|
||||
const int32 kMargin = 3;
|
||||
BRect windowRect=ConvertToScreen(Bounds());
|
||||
BRect windowRect = ConvertToScreen(Bounds());
|
||||
BRect screenFrame(BScreen(B_MAIN_SCREEN_ID).Frame());
|
||||
if (screenFrame.right < windowRect.right + kMargin)
|
||||
MoveBy(- kMargin - windowRect.right + screenFrame.right, 0);
|
||||
@@ -51,9 +48,9 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
|
||||
float value = 0.0;
|
||||
bool retrying = false;
|
||||
this->dontBeep = dontBeep;
|
||||
|
||||
aOutNode = new media_node();
|
||||
fDontBeep = dontBeep;
|
||||
|
||||
fAudioMixerNode = new media_node();
|
||||
|
||||
status_t err = B_OK; /* BMediaRoster::Roster() doesn't set it if all is ok */
|
||||
const char *errString = NULL;
|
||||
@@ -76,24 +73,23 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
roster = BMediaRoster::Roster(&err);
|
||||
}
|
||||
|
||||
if (roster && (err==B_OK)) {
|
||||
if (roster && err == B_OK) {
|
||||
switch (volumeWhich) {
|
||||
case VOLUME_USE_MIXER:
|
||||
err = roster->GetAudioMixer(aOutNode);
|
||||
break;
|
||||
case VOLUME_USE_PHYS_OUTPUT:
|
||||
err = roster->GetAudioOutput(aOutNode);
|
||||
break;
|
||||
case VOLUME_USE_MIXER:
|
||||
err = roster->GetAudioMixer(fAudioMixerNode);
|
||||
break;
|
||||
case VOLUME_USE_PHYS_OUTPUT:
|
||||
err = roster->GetAudioOutput(fAudioMixerNode);
|
||||
break;
|
||||
}
|
||||
if(err == B_OK) {
|
||||
if((err = roster->GetParameterWebFor(*aOutNode, ¶mWeb)) == B_OK) {
|
||||
|
||||
//Finding the Mixer slider in the audio output ParameterWeb
|
||||
int32 numParams = paramWeb->CountParameters();
|
||||
if (err == B_OK) {
|
||||
if ((err = roster->GetParameterWebFor(*fAudioMixerNode, &fParamWeb)) == B_OK) {
|
||||
// Finding the Mixer slider in the audio output ParameterWeb
|
||||
int32 numParams = fParamWeb->CountParameters();
|
||||
BParameter* p = NULL;
|
||||
bool foundMixerLabel = false;
|
||||
for (int i = 0; i < numParams; i++) {
|
||||
p = paramWeb->ParameterAt(i);
|
||||
p = fParamWeb->ParameterAt(i);
|
||||
PRINT(("BParameter[%i]: %s\n", i, p->Name()));
|
||||
if (volumeWhich == VOLUME_USE_MIXER) {
|
||||
if (!strcmp(p->Kind(), B_MASTER_GAIN))
|
||||
@@ -105,13 +101,13 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
if (!strcmp(p->Kind(), B_MASTER_GAIN))
|
||||
break;
|
||||
PRINT(("not MASTER_GAIN \n"));
|
||||
|
||||
|
||||
/* some audio card
|
||||
*/
|
||||
if (!strcmp(p->Name(), "Master"))
|
||||
break;
|
||||
PRINT(("not 'Master' \n"));
|
||||
|
||||
|
||||
/* some Ensonic card have all controls names 'Volume', so
|
||||
* need to fint the one that has the 'Mixer' text label
|
||||
*/
|
||||
@@ -125,7 +121,7 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
//if (!strcmp(p->Name(), "Master")) {
|
||||
if (!strcmp(p->Kind(), B_MASTER_GAIN)) {
|
||||
for (; i < numParams; i++) {
|
||||
p = paramWeb->ParameterAt(i);
|
||||
p = fParamWeb->ParameterAt(i);
|
||||
if (strcmp(p->Kind(), B_MASTER_GAIN)) p=NULL;
|
||||
else break;
|
||||
}
|
||||
@@ -134,24 +130,25 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
#endif
|
||||
p = NULL;
|
||||
}
|
||||
if (p==NULL) {
|
||||
errString = volumeWhich?"Could not find the soundcard":"Could not find the mixer";
|
||||
} else if(p->Type()!=BParameter::B_CONTINUOUS_PARAMETER) {
|
||||
errString = volumeWhich?"Soundcard control unknown":"Mixer control unknown";
|
||||
if (p == NULL) {
|
||||
errString = volumeWhich
|
||||
? "Could not find the soundcard":"Could not find the mixer";
|
||||
} else if (p->Type() != BParameter::B_CONTINUOUS_PARAMETER) {
|
||||
errString = volumeWhich
|
||||
? "Soundcard control unknown":"Mixer control unknown";
|
||||
} else {
|
||||
|
||||
mixerParam = dynamic_cast<BContinuousParameter*>(p);
|
||||
min = mixerParam->MinValue();
|
||||
max = mixerParam->MaxValue();
|
||||
step = mixerParam->ValueStep();
|
||||
|
||||
fMixerParam = dynamic_cast<BContinuousParameter*>(p);
|
||||
fMin = fMixerParam->MinValue();
|
||||
fMax = fMixerParam->MaxValue();
|
||||
fStep = fMixerParam->ValueStep();
|
||||
|
||||
float chanData[2];
|
||||
bigtime_t lastChange;
|
||||
size_t size = sizeof(chanData);
|
||||
|
||||
mixerParam->GetValue( &chanData, &size, &lastChange );
|
||||
|
||||
value = (chanData[0]-min)*100/((max-min)?(max-min):1);
|
||||
|
||||
fMixerParam->GetValue(&chanData, &size, &lastChange);
|
||||
|
||||
value = (chanData[0] - fMin) * 100 / ((fMax - fMin) ? (fMax - fMin) : 1);
|
||||
}
|
||||
} else {
|
||||
errString = "No parameter web";
|
||||
@@ -161,7 +158,7 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
retrying = true;
|
||||
goto retry;
|
||||
}
|
||||
errString = volumeWhich?"No Audio output":"No Mixer";
|
||||
errString = volumeWhich ? "No Audio output" : "No Mixer";
|
||||
}
|
||||
} else {
|
||||
if (!retrying) {
|
||||
@@ -170,36 +167,37 @@ VolumeSlider::VolumeSlider(BRect frame, bool dontBeep, int32 volumeWhich)
|
||||
}
|
||||
errString = "No Media Roster";
|
||||
}
|
||||
|
||||
if(err!=B_OK) {
|
||||
delete aOutNode;
|
||||
aOutNode = NULL;
|
||||
|
||||
if (err != B_OK) {
|
||||
delete fAudioMixerNode;
|
||||
fAudioMixerNode = NULL;
|
||||
}
|
||||
if (errString)
|
||||
fprintf(stderr, "VolumeSlider: %s.\n", errString);
|
||||
|
||||
BBox *box = new BBox(Bounds(), "sliderbox", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
|
||||
|
||||
BBox *box = new BBox(Bounds(), "sliderbox", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
|
||||
AddChild(box);
|
||||
|
||||
hasChanged = false; /* make sure we don't beep if we don't change anything */
|
||||
if (mixerParam == NULL)
|
||||
fHasChanged = false; /* make sure we don't beep if we don't change anything */
|
||||
if (fMixerParam == NULL)
|
||||
value = -1;
|
||||
slider = new SliderView(box->Bounds().InsetByCopy(1, 1), new BMessage(VOLUME_CHANGED),
|
||||
(errString==NULL) ? "Volume" : errString, B_FOLLOW_LEFT | B_FOLLOW_TOP, value);
|
||||
box->AddChild(slider);
|
||||
|
||||
slider->SetTarget(this);
|
||||
|
||||
fSlider = new SliderView(box->Bounds().InsetByCopy(1, 1), new BMessage(VOLUME_CHANGED),
|
||||
errString == NULL ? "Volume" : errString, B_FOLLOW_LEFT | B_FOLLOW_TOP, value);
|
||||
box->AddChild(fSlider);
|
||||
|
||||
fSlider->SetTarget(this);
|
||||
|
||||
SetPulseRate(100);
|
||||
}
|
||||
|
||||
|
||||
VolumeSlider::~VolumeSlider()
|
||||
{
|
||||
delete paramWeb;
|
||||
delete fParamWeb;
|
||||
BMediaRoster* roster = BMediaRoster::CurrentRoster();
|
||||
if(roster && aOutNode)
|
||||
roster->ReleaseNode(*aOutNode);
|
||||
if (roster && fAudioMixerNode)
|
||||
roster->ReleaseNode(*fAudioMixerNode);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,70 +207,77 @@ VolumeSlider::WindowActivated(bool active)
|
||||
/* don't Quit() ! thanks for FFM users */
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
void
|
||||
VolumeSlider::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case VOLUME_UPDATED:
|
||||
PRINT(("VOLUME_UPDATED\n"));
|
||||
UpdateVolume(mixerParam);
|
||||
hasChanged = true;
|
||||
break;
|
||||
case VOLUME_CHANGED:
|
||||
if (hasChanged) {
|
||||
PRINT(("VOLUME_CHANGED\n"));
|
||||
UpdateVolume(mixerParam);
|
||||
if (!dontBeep)
|
||||
beep();
|
||||
}
|
||||
Quit();
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(msg); // not a slider message, not our problem
|
||||
case VOLUME_UPDATED:
|
||||
PRINT(("VOLUME_UPDATED\n"));
|
||||
UpdateVolume(fMixerParam);
|
||||
fHasChanged = true;
|
||||
break;
|
||||
|
||||
case VOLUME_CHANGED:
|
||||
if (fHasChanged) {
|
||||
PRINT(("VOLUME_CHANGED\n"));
|
||||
UpdateVolume(fMixerParam);
|
||||
if (!fDontBeep)
|
||||
beep();
|
||||
}
|
||||
Quit();
|
||||
break;
|
||||
|
||||
default:
|
||||
BWindow::MessageReceived(msg); // not a slider message, not our problem
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeSlider::UpdateVolume(BContinuousParameter* param)
|
||||
|
||||
void
|
||||
VolumeSlider::UpdateVolume(BContinuousParameter* param)
|
||||
{
|
||||
if (!param)
|
||||
return;
|
||||
|
||||
float chanData[2];
|
||||
bigtime_t lastChange;
|
||||
size_t size = sizeof(chanData);
|
||||
|
||||
mixerParam->GetValue( &chanData, &size, &lastChange );
|
||||
fMixerParam->GetValue( &chanData, &size, &lastChange );
|
||||
|
||||
for( int i=0; i<2; i++) {
|
||||
chanData[i] = (slider->Value() * (max - min) / 100) / step * step + min;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
chanData[i] = (fSlider->Value() * (fMax - fMin) / 100) / fStep * fStep + fMin;
|
||||
}
|
||||
|
||||
PRINT(("Min value: %f Max Value: %f\nData: %f %f\n", mixerParam->MinValue(), mixerParam->MaxValue(), chanData[0], chanData[1]));
|
||||
mixerParam->SetValue(&chanData, sizeof(chanData), system_time()+1000);
|
||||
PRINT(("Min value: %f Max Value: %f\nData: %f %f\n",
|
||||
fMixerParam->MinValue(), fMixerParam->MaxValue(), chanData[0], chanData[1]));
|
||||
fMixerParam->SetValue(&chanData, sizeof(chanData), system_time()+1000);
|
||||
}
|
||||
|
||||
#define REDZONESTART 151
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
SliderView::SliderView(BRect rect, BMessage *msg, const char *title, uint32 resizeFlags, int32 value)
|
||||
SliderView::SliderView(BRect rect, BMessage *msg, const char *title,
|
||||
uint32 resizeFlags, int32 value)
|
||||
: BControl(rect, "slider", NULL, msg, resizeFlags, B_WILL_DRAW | B_PULSE_NEEDED),
|
||||
leftBitmap(BRect(0, 0, kLeftWidth - 1, kLeftHeight - 1), B_CMAP8),
|
||||
rightBitmap(BRect(0, 0, kRightWidth - 1, kRightHeight - 1), B_CMAP8),
|
||||
buttonBitmap(BRect(0, 0, kButtonWidth - 1, kButtonHeight - 1), B_CMAP8),
|
||||
fLeftBitmap(BRect(0, 0, kLeftWidth - 1, kLeftHeight - 1), B_CMAP8),
|
||||
fRightBitmap(BRect(0, 0, kRightWidth - 1, kRightHeight - 1), B_CMAP8),
|
||||
fButtonBitmap(BRect(0, 0, kButtonWidth - 1, kButtonHeight - 1), B_CMAP8),
|
||||
fTitle(title)
|
||||
{
|
||||
leftBitmap.SetBits(kLeftBits, kLeftWidth * kLeftHeight, 0, B_CMAP8);
|
||||
rightBitmap.SetBits(kRightBits, kRightWidth * kRightHeight, 0, B_CMAP8);
|
||||
buttonBitmap.SetBits(kButtonBits, kButtonWidth * kButtonHeight, 0, B_CMAP8);
|
||||
|
||||
fLeftBitmap.SetBits(kLeftBits, kLeftWidth * kLeftHeight, 0, B_CMAP8);
|
||||
fRightBitmap.SetBits(kRightBits, kRightWidth * kRightHeight, 0, B_CMAP8);
|
||||
fButtonBitmap.SetBits(kButtonBits, kButtonWidth * kButtonHeight, 0, B_CMAP8);
|
||||
|
||||
SetTracking(true);
|
||||
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||
SetValue(value);
|
||||
}
|
||||
|
||||
|
||||
SliderView::~SliderView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +288,7 @@ SliderView::Pulse()
|
||||
BPoint where;
|
||||
GetMouse(&where, &mouseButtons, true);
|
||||
// button not pressed, exit
|
||||
if (! (mouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
|
||||
if (!(mouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
|
||||
SetTracking(false);
|
||||
Invoke();
|
||||
}
|
||||
@@ -301,21 +306,21 @@ SliderView::Draw(BRect updateRect)
|
||||
StrokeLine(BPoint(11,14), BPoint(192,14));
|
||||
SetHighColor(231,227,231);
|
||||
StrokeLine(BPoint(11,15), BPoint(192,15));
|
||||
|
||||
|
||||
SetLowColor(ViewColor());
|
||||
|
||||
SetDrawingMode(B_OP_OVER);
|
||||
|
||||
DrawBitmapAsync(&leftBitmap, BPoint(5,1));
|
||||
DrawBitmapAsync(&rightBitmap, BPoint(193,1));
|
||||
DrawBitmapAsync(&fLeftBitmap, BPoint(5,1));
|
||||
DrawBitmapAsync(&fRightBitmap, BPoint(193,1));
|
||||
|
||||
float position = 11 + (192-11) * ((Value()==-1)?0:Value()) / 100;
|
||||
float position = 11 + (192-11) * ((Value() == -1) ? 0 : Value()) / 100;
|
||||
float right = (position < REDZONESTART) ? position : REDZONESTART;
|
||||
SetHighColor(99,151,99);
|
||||
FillRect(BRect(11,3,right,4));
|
||||
SetHighColor(156,203,156);
|
||||
FillRect(BRect(11,5,right,13));
|
||||
if(right == REDZONESTART) {
|
||||
if (right == REDZONESTART) {
|
||||
SetHighColor(156,101,99);
|
||||
FillRect(BRect(REDZONESTART,3,position,4));
|
||||
SetHighColor(255,154,156);
|
||||
@@ -323,17 +328,17 @@ SliderView::Draw(BRect updateRect)
|
||||
}
|
||||
SetHighColor(156,154,156);
|
||||
FillRect(BRect(position,3,192,13));
|
||||
|
||||
|
||||
BFont font;
|
||||
float width = font.StringWidth(fTitle);
|
||||
|
||||
|
||||
SetHighColor(49,154,49);
|
||||
DrawString(fTitle, BPoint(11 + (192-11-width)/2, 12));
|
||||
|
||||
DrawBitmapAsync(&buttonBitmap, BPoint(position-5,3));
|
||||
|
||||
|
||||
DrawBitmapAsync(&fButtonBitmap, BPoint(position-5,3));
|
||||
|
||||
Sync();
|
||||
|
||||
|
||||
SetDrawingMode(B_OP_COPY);
|
||||
}
|
||||
|
||||
@@ -343,18 +348,18 @@ SliderView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
||||
{
|
||||
if (!IsTracking())
|
||||
return;
|
||||
|
||||
|
||||
uint32 mouseButtons;
|
||||
BPoint where;
|
||||
GetMouse(&where, &mouseButtons, true);
|
||||
|
||||
|
||||
// button not pressed, exit
|
||||
if (! (mouseButtons & B_PRIMARY_MOUSE_BUTTON)) {
|
||||
Invoke();
|
||||
SetTracking(false);
|
||||
}
|
||||
|
||||
if ((Value() == -1) || !Bounds().InsetBySelf(2,2).Contains(point))
|
||||
|
||||
if (Value() == -1 || !Bounds().InsetBySelf(2, 2).Contains(point))
|
||||
return;
|
||||
|
||||
float v = MIN(MAX(point.x, 11), 192);
|
||||
@@ -363,6 +368,7 @@ SliderView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
||||
SetValue(v);
|
||||
Draw(Bounds());
|
||||
Flush();
|
||||
|
||||
if (Window())
|
||||
Window()->PostMessage(VOLUME_UPDATED);
|
||||
}
|
||||
@@ -373,13 +379,14 @@ SliderView::MouseUp(BPoint point)
|
||||
{
|
||||
if (!IsTracking())
|
||||
return;
|
||||
if ((Value() != -1) && Bounds().InsetBySelf(2,2).Contains(point)) {
|
||||
|
||||
if (Value() != -1 && Bounds().InsetBySelf(2, 2).Contains(point)) {
|
||||
float v = MIN(MAX(point.x, 11), 192);
|
||||
v = (v - 11) / (192-11) * 100;
|
||||
v = MAX(MIN(v,100), 0);
|
||||
SetValue(v);
|
||||
}
|
||||
|
||||
|
||||
Invoke();
|
||||
SetTracking(false);
|
||||
Draw(Bounds());
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
//
|
||||
// Copyright (c) 2003, OpenBeOS
|
||||
//
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//
|
||||
//
|
||||
// Program: desklink
|
||||
// Author: Jérôme DUVAL
|
||||
// Description: VolumeControl and link items in Deskbar
|
||||
// Created : October 20, 2003
|
||||
// Modified by: Jérome Duval
|
||||
// Modified by: François Revol, 10/31/2003
|
||||
//
|
||||
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||
/*
|
||||
* Copyright (c) 2003-2005, Haiku, Inc.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval
|
||||
* François Revol
|
||||
*/
|
||||
#ifndef VOLUMESLIDER_H
|
||||
#define VOLUMESLIDER_H
|
||||
|
||||
@@ -25,37 +17,41 @@
|
||||
#define VOLUME_USE_MIXER 0 /* default */
|
||||
#define VOLUME_USE_PHYS_OUTPUT 1
|
||||
|
||||
class SliderView : public BControl
|
||||
{
|
||||
public:
|
||||
SliderView(BRect rect, BMessage *msg, const char* title, uint32 resizeFlags, int32 value);
|
||||
~SliderView();
|
||||
virtual void Draw(BRect);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void Pulse();
|
||||
private:
|
||||
BBitmap leftBitmap, rightBitmap, buttonBitmap;
|
||||
const char* fTitle;
|
||||
|
||||
class SliderView : public BControl {
|
||||
public:
|
||||
SliderView(BRect rect, BMessage *msg, const char* title, uint32 resizeFlags,
|
||||
int32 value);
|
||||
~SliderView();
|
||||
|
||||
virtual void Draw(BRect);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void Pulse();
|
||||
|
||||
private:
|
||||
BBitmap fLeftBitmap, fRightBitmap, fButtonBitmap;
|
||||
const char* fTitle;
|
||||
};
|
||||
|
||||
class VolumeSlider : public BWindow
|
||||
{
|
||||
public:
|
||||
VolumeSlider(BRect frame, bool dontBeep=false, int32 volumeWhich=0);
|
||||
~VolumeSlider();
|
||||
class VolumeSlider : public BWindow {
|
||||
public:
|
||||
VolumeSlider(BRect frame, bool dontBeep=false, int32 volumeWhich=0);
|
||||
~VolumeSlider();
|
||||
|
||||
void MessageReceived(BMessage*);
|
||||
void WindowActivated(bool active);
|
||||
private:
|
||||
void UpdateVolume(BContinuousParameter* param);
|
||||
media_node *aOutNode;
|
||||
BParameterWeb* paramWeb;
|
||||
BContinuousParameter* mixerParam;
|
||||
float min, max, step;
|
||||
bool hasChanged;
|
||||
bool dontBeep;
|
||||
SliderView *slider;
|
||||
void MessageReceived(BMessage*);
|
||||
void WindowActivated(bool active);
|
||||
|
||||
private:
|
||||
void UpdateVolume(BContinuousParameter* param);
|
||||
|
||||
media_node *fAudioMixerNode;
|
||||
BParameterWeb* fParamWeb;
|
||||
BContinuousParameter* fMixerParam;
|
||||
float fMin, fMax, fStep;
|
||||
bool fHasChanged;
|
||||
bool fDontBeep;
|
||||
SliderView *fSlider;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // VOLUMESLIDER_H
|
||||
|
||||
Reference in New Issue
Block a user