* 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 {
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),
+1 -1
View File
@@ -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,
+5 -3
View File
@@ -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