From 648b674d3f65b4f281da71b516d5702f4c1ffc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 15 Jul 2009 09:16:12 +0000 Subject: [PATCH] * 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 --- src/bin/desklink/MediaReplicant.cpp | 27 +++++++++++++++------------ src/bin/desklink/MixerControl.h | 2 +- src/bin/desklink/VolumeControl.cpp | 8 +++++--- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/bin/desklink/MediaReplicant.cpp b/src/bin/desklink/MediaReplicant.cpp index 1ef6124b88..03420a4b73 100644 --- a/src/bin/desklink/MediaReplicant.cpp +++ b/src/bin/desklink/MediaReplicant.cpp @@ -47,7 +47,7 @@ static const char* kSettingsFile = "x-vnd.Haiku-desklink"; class MediaReplicant : public BView { public: MediaReplicant(BRect frame, const char* name, - uint32 resizeMask = B_FOLLOW_ALL, + uint32 resizeMask = B_FOLLOW_ALL, uint32 flags = B_WILL_DRAW | B_NAVIGABLE); MediaReplicant(BMessage* archive); @@ -84,7 +84,8 @@ private: MediaReplicant::MediaReplicant(BRect frame, const char* name, uint32 resizeMask, uint32 flags) - : BView(frame, name, resizeMask, flags), + : + BView(frame, name, resizeMask, flags), fVolumeSlider(NULL) { _Init(); @@ -92,7 +93,8 @@ MediaReplicant::MediaReplicant(BRect frame, const char* name, MediaReplicant::MediaReplicant(BMessage* message) - : BView(message), + : + BView(message), fVolumeSlider(NULL) { _Init(); @@ -116,7 +118,7 @@ MediaReplicant::Instantiate(BMessage* data) } -status_t +status_t MediaReplicant::Archive(BMessage* data, bool deep) const { status_t status = BView::Archive(data, deep); @@ -130,7 +132,7 @@ MediaReplicant::Archive(BMessage* data, bool deep) const void MediaReplicant::AttachedToWindow() { - BView *parent = Parent(); + BView* parent = Parent(); if (parent) SetViewColor(parent->ViewColor()); @@ -138,11 +140,11 @@ MediaReplicant::AttachedToWindow() } -void +void MediaReplicant::Draw(BRect rect) { BView::Draw(rect); - + SetDrawingMode(B_OP_OVER); DrawBitmap(fIcon); } @@ -193,7 +195,7 @@ MediaReplicant::MouseDown(BPoint point) menu->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))); } else { // Show VolumeWindow @@ -205,7 +207,7 @@ MediaReplicant::MouseDown(BPoint point) void -MediaReplicant::MessageReceived(BMessage *message) +MediaReplicant::MessageReceived(BMessage* message) { switch (message->what) { case B_ABOUT_REQUESTED: @@ -258,7 +260,8 @@ MediaReplicant::MessageReceived(BMessage *message) float deltaY; if (message->FindFloat("be:wheel_delta_y", &deltaY) == B_OK && deltaY != 0.0) { - MixerControl mixerControl(fVolumeWhich); + MixerControl mixerControl; + mixerControl.Connect(fVolumeWhich); mixerControl.ChangeVolumeBy(deltaY < 0 ? 6 : -6); } break; @@ -266,7 +269,7 @@ MediaReplicant::MessageReceived(BMessage *message) default: BView::MessageReceived(message); - break; + break; } } @@ -379,7 +382,7 @@ MediaReplicant::_SaveSettings() } -void +void MediaReplicant::_Init() { fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1), diff --git a/src/bin/desklink/MixerControl.h b/src/bin/desklink/MixerControl.h index 1766585e92..59b27e09a9 100644 --- a/src/bin/desklink/MixerControl.h +++ b/src/bin/desklink/MixerControl.h @@ -23,7 +23,7 @@ class BContinuousParameter; class MixerControl { public: - MixerControl(int32 volumeWhich); + MixerControl(int32 volumeWhich = VOLUME_USE_MIXER); ~MixerControl(); bool Connect(int32 volumeWhich, float* _value = NULL, diff --git a/src/bin/desklink/VolumeControl.cpp b/src/bin/desklink/VolumeControl.cpp index 99062cdfad..df3807f484 100644 --- a/src/bin/desklink/VolumeControl.cpp +++ b/src/bin/desklink/VolumeControl.cpp @@ -36,7 +36,8 @@ static const uint32 kMsgReconnectVolume = 'rcms'; 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)), fBeep(beep), fSnapping(false), @@ -56,7 +57,8 @@ VolumeControl::VolumeControl(int32 volumeWhich, bool beep, BMessage* message) VolumeControl::VolumeControl(BMessage* archive) - : BSlider(archive), + : + BSlider(archive), fMixerControl(NULL), fSnapping(false), fConnectRetries(0) @@ -245,7 +247,7 @@ VolumeControl::MessageReceived(BMessage* msg) switch (msg->what) { case B_MOUSE_WHEEL_CHANGED: { - if (Value() == -1) + if (!fMixerControl->Connected()) return; // Even though the volume bar is horizontal, we use the more common