* Fixed volume change via mouse wheel over the replicant icon regression.

See #2323.
* Also fixed the mouse wheel not working once the volume value equaled -1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31582 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-07-15 09:16:12 +00:00
parent 2cff698572
commit 648b674d3f
3 changed files with 21 additions and 16 deletions
+15 -12
View File
@@ -47,7 +47,7 @@ static const char* kSettingsFile = "x-vnd.Haiku-desklink";
class MediaReplicant : public BView { class MediaReplicant : public BView {
public: public:
MediaReplicant(BRect frame, const char* name, MediaReplicant(BRect frame, const char* name,
uint32 resizeMask = B_FOLLOW_ALL, uint32 resizeMask = B_FOLLOW_ALL,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE); uint32 flags = B_WILL_DRAW | B_NAVIGABLE);
MediaReplicant(BMessage* archive); MediaReplicant(BMessage* archive);
@@ -84,7 +84,8 @@ private:
MediaReplicant::MediaReplicant(BRect frame, const char* name, MediaReplicant::MediaReplicant(BRect frame, const char* name,
uint32 resizeMask, uint32 flags) uint32 resizeMask, uint32 flags)
: BView(frame, name, resizeMask, flags), :
BView(frame, name, resizeMask, flags),
fVolumeSlider(NULL) fVolumeSlider(NULL)
{ {
_Init(); _Init();
@@ -92,7 +93,8 @@ MediaReplicant::MediaReplicant(BRect frame, const char* name,
MediaReplicant::MediaReplicant(BMessage* message) MediaReplicant::MediaReplicant(BMessage* message)
: BView(message), :
BView(message),
fVolumeSlider(NULL) fVolumeSlider(NULL)
{ {
_Init(); _Init();
@@ -116,7 +118,7 @@ MediaReplicant::Instantiate(BMessage* data)
} }
status_t status_t
MediaReplicant::Archive(BMessage* data, bool deep) const MediaReplicant::Archive(BMessage* data, bool deep) const
{ {
status_t status = BView::Archive(data, deep); status_t status = BView::Archive(data, deep);
@@ -130,7 +132,7 @@ MediaReplicant::Archive(BMessage* data, bool deep) const
void void
MediaReplicant::AttachedToWindow() MediaReplicant::AttachedToWindow()
{ {
BView *parent = Parent(); BView* parent = Parent();
if (parent) if (parent)
SetViewColor(parent->ViewColor()); SetViewColor(parent->ViewColor());
@@ -138,11 +140,11 @@ MediaReplicant::AttachedToWindow()
} }
void void
MediaReplicant::Draw(BRect rect) MediaReplicant::Draw(BRect rect)
{ {
BView::Draw(rect); BView::Draw(rect);
SetDrawingMode(B_OP_OVER); SetDrawingMode(B_OP_OVER);
DrawBitmap(fIcon); DrawBitmap(fIcon);
} }
@@ -193,7 +195,7 @@ MediaReplicant::MouseDown(BPoint point)
menu->SetTargetForItems(this); menu->SetTargetForItems(this);
subMenu->SetTargetForItems(this); subMenu->SetTargetForItems(this);
menu->Go(where, true, true, BRect(where - BPoint(4, 4), menu->Go(where, true, true, BRect(where - BPoint(4, 4),
where + BPoint(4, 4))); where + BPoint(4, 4)));
} else { } else {
// Show VolumeWindow // Show VolumeWindow
@@ -205,7 +207,7 @@ MediaReplicant::MouseDown(BPoint point)
void void
MediaReplicant::MessageReceived(BMessage *message) MediaReplicant::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
@@ -258,7 +260,8 @@ MediaReplicant::MessageReceived(BMessage *message)
float deltaY; float deltaY;
if (message->FindFloat("be:wheel_delta_y", &deltaY) == B_OK if (message->FindFloat("be:wheel_delta_y", &deltaY) == B_OK
&& deltaY != 0.0) { && deltaY != 0.0) {
MixerControl mixerControl(fVolumeWhich); MixerControl mixerControl;
mixerControl.Connect(fVolumeWhich);
mixerControl.ChangeVolumeBy(deltaY < 0 ? 6 : -6); mixerControl.ChangeVolumeBy(deltaY < 0 ? 6 : -6);
} }
break; break;
@@ -266,7 +269,7 @@ MediaReplicant::MessageReceived(BMessage *message)
default: default:
BView::MessageReceived(message); BView::MessageReceived(message);
break; break;
} }
} }
@@ -379,7 +382,7 @@ MediaReplicant::_SaveSettings()
} }
void void
MediaReplicant::_Init() MediaReplicant::_Init()
{ {
fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1), fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1),
+1 -1
View File
@@ -23,7 +23,7 @@ class BContinuousParameter;
class MixerControl { class MixerControl {
public: public:
MixerControl(int32 volumeWhich); MixerControl(int32 volumeWhich = VOLUME_USE_MIXER);
~MixerControl(); ~MixerControl();
bool Connect(int32 volumeWhich, float* _value = NULL, bool Connect(int32 volumeWhich, float* _value = NULL,
+5 -3
View File
@@ -36,7 +36,8 @@ static const uint32 kMsgReconnectVolume = 'rcms';
VolumeControl::VolumeControl(int32 volumeWhich, bool beep, BMessage* message) VolumeControl::VolumeControl(int32 volumeWhich, bool beep, BMessage* message)
: BSlider("VolumeControl", "Volume", message, 0, 1, B_HORIZONTAL), :
BSlider("VolumeControl", "Volume", message, 0, 1, B_HORIZONTAL),
fMixerControl(new MixerControl(volumeWhich)), fMixerControl(new MixerControl(volumeWhich)),
fBeep(beep), fBeep(beep),
fSnapping(false), fSnapping(false),
@@ -56,7 +57,8 @@ VolumeControl::VolumeControl(int32 volumeWhich, bool beep, BMessage* message)
VolumeControl::VolumeControl(BMessage* archive) VolumeControl::VolumeControl(BMessage* archive)
: BSlider(archive), :
BSlider(archive),
fMixerControl(NULL), fMixerControl(NULL),
fSnapping(false), fSnapping(false),
fConnectRetries(0) fConnectRetries(0)
@@ -245,7 +247,7 @@ VolumeControl::MessageReceived(BMessage* msg)
switch (msg->what) { switch (msg->what) {
case B_MOUSE_WHEEL_CHANGED: case B_MOUSE_WHEEL_CHANGED:
{ {
if (Value() == -1) if (!fMixerControl->Connected())
return; return;
// Even though the volume bar is horizontal, we use the more common // Even though the volume bar is horizontal, we use the more common