* Added a volume tool tip to Deskbar's volume replicant, thus closing ticket
#3118. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32250 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src bin desklink ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders app ;
|
UsePrivateHeaders app interface shared ;
|
||||||
|
|
||||||
BinCommand desklink :
|
BinCommand desklink :
|
||||||
desklink.cpp
|
desklink.cpp
|
||||||
|
|||||||
@@ -10,8 +10,10 @@
|
|||||||
* Axel Dörfler, [email protected].
|
* Axel Dörfler, [email protected].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//! Volume control, and media shortcuts in Deskbar
|
//! Volume control, and media shortcuts in Deskbar
|
||||||
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -25,6 +27,10 @@
|
|||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
|
||||||
|
#include <ToolTip.h>
|
||||||
|
#include <ToolTipManager.h>
|
||||||
|
|
||||||
#include "desklink.h"
|
#include "desklink.h"
|
||||||
#include "iconfile.h"
|
#include "iconfile.h"
|
||||||
@@ -44,6 +50,56 @@ static const char* kReplicantName = "MediaReplicant";
|
|||||||
static const char* kSettingsFile = "x-vnd.Haiku-desklink";
|
static const char* kSettingsFile = "x-vnd.Haiku-desklink";
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeToolTip : public BToolTip {
|
||||||
|
public:
|
||||||
|
VolumeToolTip(int32 which = VOLUME_USE_MIXER)
|
||||||
|
:
|
||||||
|
fWhich(which)
|
||||||
|
{
|
||||||
|
fView = new BStringView("", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~VolumeToolTip()
|
||||||
|
{
|
||||||
|
delete fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual BView* View() const
|
||||||
|
{
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void AttachedToWindow()
|
||||||
|
{
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetWhich(int32 which)
|
||||||
|
{
|
||||||
|
fWhich = which;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (!Lock())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MixerControl control;
|
||||||
|
control.Connect(fWhich);
|
||||||
|
|
||||||
|
char text[256];
|
||||||
|
snprintf(text, sizeof(text), "%g dB", control.Volume());
|
||||||
|
fView->SetText(text);
|
||||||
|
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BStringView* fView;
|
||||||
|
int32 fWhich;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class MediaReplicant : public BView {
|
class MediaReplicant : public BView {
|
||||||
public:
|
public:
|
||||||
MediaReplicant(BRect frame, const char* name,
|
MediaReplicant(BRect frame, const char* name,
|
||||||
@@ -263,6 +319,12 @@ MediaReplicant::MessageReceived(BMessage* message)
|
|||||||
MixerControl mixerControl;
|
MixerControl mixerControl;
|
||||||
mixerControl.Connect(fVolumeWhich);
|
mixerControl.Connect(fVolumeWhich);
|
||||||
mixerControl.ChangeVolumeBy(deltaY < 0 ? 6 : -6);
|
mixerControl.ChangeVolumeBy(deltaY < 0 ? 6 : -6);
|
||||||
|
|
||||||
|
VolumeToolTip* tip = dynamic_cast<VolumeToolTip*>(ToolTip());
|
||||||
|
if (tip != NULL) {
|
||||||
|
tip->Update();
|
||||||
|
ShowToolTip(tip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -387,7 +449,9 @@ MediaReplicant::_Init()
|
|||||||
{
|
{
|
||||||
fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1),
|
fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1),
|
||||||
B_CMAP8);
|
B_CMAP8);
|
||||||
fIcon->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, B_CMAP8);
|
fIcon->SetBits(kSpeakerBits, kSpeakerWidth * kSpeakerHeight, 0, B_CMAP8);
|
||||||
|
|
||||||
|
SetToolTip(new VolumeToolTip());
|
||||||
|
|
||||||
_LoadSettings();
|
_LoadSettings();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user