* 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 ;
|
||||
|
||||
UsePrivateHeaders app ;
|
||||
UsePrivateHeaders app interface shared ;
|
||||
|
||||
BinCommand desklink :
|
||||
desklink.cpp
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
* Axel Dörfler, [email protected].
|
||||
*/
|
||||
|
||||
|
||||
//! Volume control, and media shortcuts in Deskbar
|
||||
|
||||
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -25,6 +27,10 @@
|
||||
#include <PopUpMenu.h>
|
||||
#include <Roster.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include <ToolTip.h>
|
||||
#include <ToolTipManager.h>
|
||||
|
||||
#include "desklink.h"
|
||||
#include "iconfile.h"
|
||||
@@ -44,6 +50,56 @@ static const char* kReplicantName = "MediaReplicant";
|
||||
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 {
|
||||
public:
|
||||
MediaReplicant(BRect frame, const char* name,
|
||||
@@ -263,6 +319,12 @@ MediaReplicant::MessageReceived(BMessage* message)
|
||||
MixerControl mixerControl;
|
||||
mixerControl.Connect(fVolumeWhich);
|
||||
mixerControl.ChangeVolumeBy(deltaY < 0 ? 6 : -6);
|
||||
|
||||
VolumeToolTip* tip = dynamic_cast<VolumeToolTip*>(ToolTip());
|
||||
if (tip != NULL) {
|
||||
tip->Update();
|
||||
ShowToolTip(tip);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -387,7 +449,9 @@ MediaReplicant::_Init()
|
||||
{
|
||||
fIcon = new BBitmap(BRect(0, 0, kSpeakerWidth - 1, kSpeakerHeight - 1),
|
||||
B_CMAP8);
|
||||
fIcon->SetBits(kSpeakerBits, kSpeakerWidth*kSpeakerHeight, 0, B_CMAP8);
|
||||
fIcon->SetBits(kSpeakerBits, kSpeakerWidth * kSpeakerHeight, 0, B_CMAP8);
|
||||
|
||||
SetToolTip(new VolumeToolTip());
|
||||
|
||||
_LoadSettings();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user