Old Media Stuff - will still be used - the slider looks nice ;)

Just putting this code aside for the meantime.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2789 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Phil Greenway 2003-02-22 05:04:59 +00:00
parent 4fcc31827d
commit e0c1abb912
8 changed files with 150 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#include "MediaPrefsApp.h"
MediaPrefsApp::MediaPrefsApp()
: BApplication( "application/x-vnd.OBeOS.Media" )
{
BRect r;
r.Set( 100, 100, 200, 300 );
window = new MediaPrefsWindow( r );
window->Show();
}
int
main( int argc, char **argv )
{
MediaPrefsApp app;
app.Run();
return 0;
}

View File

@ -0,0 +1,12 @@
#include <Application.h>
#include "MediaPrefsWindow.h"
class MediaPrefsApp : public BApplication {
public:
MediaPrefsApp();
private:
MediaPrefsWindow *window;
};

View File

@ -0,0 +1,9 @@
#include "MediaPrefsSlider.h"
//#include "VolumeControl.h"
MediaPrefsSlider::MediaPrefsSlider( BRect r, const char *name, const char *label, BMessage *model,
int32 channels, uint32 resize, uint32 flags )
: BChannelSlider( r, name, label, model, B_VERTICAL, channels, resize, flags )
{
}

View File

@ -0,0 +1,10 @@
#include <ChannelSlider.h>
#define vI2F (float)(9.999 / 100)
class MediaPrefsSlider : public BChannelSlider {
public:
MediaPrefsSlider( BRect r, const char *name, const char *label, BMessage *model,
int32 channels, uint32 resize, uint32 flags );
};

View File

@ -0,0 +1,7 @@
#include "MediaPrefsView.h"
MediaPrefsView::MediaPrefsView( BRect r, char *name )
: BView( r, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW )
{
}

View File

@ -0,0 +1,8 @@
#include <View.h>
class MediaPrefsView : public BView {
public:
MediaPrefsView( BRect r, char *name );
};

View File

@ -0,0 +1,65 @@
#include "MediaPrefsApp.h"
//#include "VolumeControl.h"
MediaPrefsWindow::MediaPrefsWindow( BRect wRect )
: BWindow( wRect, "Media", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS )
{
float fLeft, fRight;
int32 iLeft, iRight;
wRect.OffsetTo( B_ORIGIN );
view = new MediaPrefsView( wRect, "MainView" );
view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
this->AddChild( view );
slider = new MediaPrefsSlider( wRect, "MasterVol", "Master",
new BMessage( 'mVol' ), 2,
B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW );
slider->SetLimits( 0, 100 );
slider->SetLimitLabels( "0", "100" );
view->AddChild( slider );
// use private API
// if ( MediaKitPrivate::GetMasterVolume( &fLeft, &fRight ) == B_OK ) {
// // left,right range is 0..9.999
// iLeft = (int32)( fLeft / vI2F );
// iRight = (int32)( fRight / vI2F );
// } else {
iLeft = 0;
iRight = 0;
// }
slider->SetValueFor( 0, iLeft );
slider->SetValueFor( 1, iRight );
}
bool MediaPrefsWindow::QuitRequested()
{
be_app->PostMessage( B_QUIT_REQUESTED );
return true;
}
void MediaPrefsWindow::MessageReceived( BMessage *msg )
{
switch ( msg->what ) {
case 'mVol':
{
int32 iLeft = slider->ValueFor( 0 );
int32 iRight = slider->ValueFor( 1 );
float fLeft = float( iLeft ) * vI2F;
float fRight = float( iRight ) * vI2F;
// MediaKitPrivate::SetMasterVolume( fLeft, fRight );
}
break;
default:
BWindow::MessageReceived( msg );
}
}

View File

@ -0,0 +1,17 @@
#include <Window.h>
#include "MediaPrefsView.h"
#include "MediaPrefsSlider.h"
class MediaPrefsWindow : public BWindow {
public:
MediaPrefsWindow( BRect wRect );
virtual bool QuitRequested();
virtual void MessageReceived( BMessage *msg );
private:
MediaPrefsView *view;
MediaPrefsSlider *slider;
};