* Added the implementation behind the "Use overlays if available" and "Scale
videos smoothly in non-overlay mode" options. * Disabled the other controls in the SettingsWindow which are not yet implemented. * Enable and disable Revert button according to settings state. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27157 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -101,6 +101,7 @@ Controller::Controller()
|
|||||||
, fDuration(0)
|
, fDuration(0)
|
||||||
, fVideoFrameRate(25.0)
|
, fVideoFrameRate(25.0)
|
||||||
, fSeekFrame(-1)
|
, fSeekFrame(-1)
|
||||||
|
, fLastSeekEventTime(LONGLONG_MIN)
|
||||||
|
|
||||||
, fAutoplay(true)
|
, fAutoplay(true)
|
||||||
, fPauseAtEndOfStream(false)
|
, fPauseAtEndOfStream(false)
|
||||||
@@ -269,6 +270,8 @@ Controller::SetTo(const entry_ref &ref)
|
|||||||
fVideoView->DisableOverlay();
|
fVideoView->DisableOverlay();
|
||||||
|
|
||||||
// get video properties (if there is video at all)
|
// get video properties (if there is video at all)
|
||||||
|
bool useOverlays = fVideoView ? fVideoView->UseOverlays() : true;
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
GetSize(&width, &height);
|
GetSize(&width, &height);
|
||||||
@@ -288,10 +291,11 @@ Controller::SetTo(const entry_ref &ref)
|
|||||||
|
|
||||||
if (InitCheck() != B_OK) {
|
if (InitCheck() != B_OK) {
|
||||||
Init(BRect(0, 0, width - 1, height - 1), fVideoFrameRate,
|
Init(BRect(0, 0, width - 1, height - 1), fVideoFrameRate,
|
||||||
preferredVideoFormat, LOOPING_ALL, false, 1.0, enabledNodes);
|
preferredVideoFormat, LOOPING_ALL, false, 1.0, enabledNodes,
|
||||||
|
useOverlays);
|
||||||
} else {
|
} else {
|
||||||
FormatChanged(BRect(0, 0, width - 1, height - 1), fVideoFrameRate,
|
FormatChanged(BRect(0, 0, width - 1, height - 1), fVideoFrameRate,
|
||||||
preferredVideoFormat, enabledNodes);
|
preferredVideoFormat, enabledNodes, useOverlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
_NotifyFileChanged();
|
_NotifyFileChanged();
|
||||||
@@ -578,9 +582,10 @@ Controller::SetPosition(float value)
|
|||||||
|
|
||||||
fSeekFrame = (int32)(Duration() * value);
|
fSeekFrame = (int32)(Duration() * value);
|
||||||
int32 currentFrame = CurrentFrame();
|
int32 currentFrame = CurrentFrame();
|
||||||
if (fSeekFrame != currentFrame)
|
if (fSeekFrame != currentFrame) {
|
||||||
SetCurrentFrame(fSeekFrame);
|
SetCurrentFrame(fSeekFrame);
|
||||||
else
|
fLastSeekEventTime = system_time();
|
||||||
|
} else
|
||||||
fSeekFrame = -1;
|
fSeekFrame = -1;
|
||||||
|
|
||||||
// TODO: What was this used for in the old framework?
|
// TODO: What was this used for in the old framework?
|
||||||
@@ -916,8 +921,10 @@ Controller::NotifyCurrentFrameChanged(int32 frame) const
|
|||||||
{
|
{
|
||||||
// check if we are still waiting to reach the seekframe,
|
// check if we are still waiting to reach the seekframe,
|
||||||
// don't pass the event on to the listeners in that case
|
// don't pass the event on to the listeners in that case
|
||||||
if (fSeekFrame >= 0 && frame != fSeekFrame)
|
if ((system_time() - fLastSeekEventTime) < 1000000
|
||||||
|
&& fSeekFrame >= 0 && frame != fSeekFrame) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
fSeekFrame = -1;
|
fSeekFrame = -1;
|
||||||
|
|
||||||
float position = 0.0;
|
float position = 0.0;
|
||||||
|
|||||||
@@ -175,6 +175,7 @@ private:
|
|||||||
bigtime_t fDuration;
|
bigtime_t fDuration;
|
||||||
float fVideoFrameRate;
|
float fVideoFrameRate;
|
||||||
mutable int32 fSeekFrame;
|
mutable int32 fSeekFrame;
|
||||||
|
bigtime_t fLastSeekEventTime;
|
||||||
|
|
||||||
bool fAutoplay;
|
bool fAutoplay;
|
||||||
volatile bool fPauseAtEndOfStream;
|
volatile bool fPauseAtEndOfStream;
|
||||||
|
|||||||
@@ -8,10 +8,13 @@
|
|||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
|
|
||||||
VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
|
VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
|
||||||
: BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
: BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
|
||||||
fOverlayMode(false)
|
fOverlayMode(false),
|
||||||
|
fGlobalSettingsListener(this)
|
||||||
{
|
{
|
||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
// might be reset to overlay key color if overlays are used
|
// might be reset to overlay key color if overlays are used
|
||||||
@@ -22,11 +25,15 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
|
|||||||
fOverlayRestrictions.max_width_scale = 8.0;
|
fOverlayRestrictions.max_width_scale = 8.0;
|
||||||
fOverlayRestrictions.min_height_scale = 0.25;
|
fOverlayRestrictions.min_height_scale = 0.25;
|
||||||
fOverlayRestrictions.max_height_scale = 8.0;
|
fOverlayRestrictions.max_height_scale = 8.0;
|
||||||
|
|
||||||
|
Settings::Default()->AddListener(&fGlobalSettingsListener);
|
||||||
|
_AdoptGlobalSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VideoView::~VideoView()
|
VideoView::~VideoView()
|
||||||
{
|
{
|
||||||
|
Settings::Default()->RemoveListener(&fGlobalSettingsListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -36,11 +43,10 @@ VideoView::Draw(BRect updateRect)
|
|||||||
bool fillBlack = true;
|
bool fillBlack = true;
|
||||||
|
|
||||||
if (LockBitmap()) {
|
if (LockBitmap()) {
|
||||||
BRect r(Bounds());
|
|
||||||
if (const BBitmap* bitmap = GetBitmap()) {
|
if (const BBitmap* bitmap = GetBitmap()) {
|
||||||
fillBlack = false;
|
fillBlack = false;
|
||||||
if (!fOverlayMode)
|
if (!fOverlayMode)
|
||||||
DrawBitmap(bitmap, bitmap->Bounds(), r);
|
_DrawBitmap(bitmap);
|
||||||
}
|
}
|
||||||
UnlockBitmap();
|
UnlockBitmap();
|
||||||
}
|
}
|
||||||
@@ -50,6 +56,21 @@ VideoView::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
VideoView::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case MSG_OBJECT_CHANGED:
|
||||||
|
// TODO: find out which object, if we ever watch more than
|
||||||
|
// the global settings instance...
|
||||||
|
_AdoptGlobalSettings();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VideoView::SetBitmap(const BBitmap* bitmap)
|
VideoView::SetBitmap(const BBitmap* bitmap)
|
||||||
{
|
{
|
||||||
@@ -60,8 +81,7 @@ VideoView::SetBitmap(const BBitmap* bitmap)
|
|||||||
// -> Window).
|
// -> Window).
|
||||||
if (bitmap && LockLooperWithTimeout(10000) == B_OK) {
|
if (bitmap && LockLooperWithTimeout(10000) == B_OK) {
|
||||||
if (LockBitmap()) {
|
if (LockBitmap()) {
|
||||||
// if (fOverlayMode || bitmap->Flags() & B_BITMAP_WILL_OVERLAY) {
|
if (fOverlayMode || (bitmap->Flags() & B_BITMAP_WILL_OVERLAY)) {
|
||||||
if (fOverlayMode || bitmap->ColorSpace() == B_YCbCr422) {
|
|
||||||
if (!fOverlayMode) {
|
if (!fOverlayMode) {
|
||||||
// init overlay
|
// init overlay
|
||||||
rgb_color key;
|
rgb_color key;
|
||||||
@@ -104,7 +124,7 @@ VideoView::SetBitmap(const BBitmap* bitmap)
|
|||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
}
|
}
|
||||||
if (!fOverlayMode)
|
if (!fOverlayMode)
|
||||||
DrawBitmap(bitmap, bitmap->Bounds(), Bounds());
|
_DrawBitmap(bitmap);
|
||||||
|
|
||||||
UnlockBitmap();
|
UnlockBitmap();
|
||||||
}
|
}
|
||||||
@@ -140,6 +160,13 @@ VideoView::OverlayScreenshotCleanup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
VideoView::UseOverlays() const
|
||||||
|
{
|
||||||
|
return fUseOverlays;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VideoView::IsOverlayActive()
|
VideoView::IsOverlayActive()
|
||||||
{
|
{
|
||||||
@@ -167,3 +194,28 @@ VideoView::DisableOverlay()
|
|||||||
fOverlayMode = false;
|
fOverlayMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
VideoView::_DrawBitmap(const BBitmap* bitmap)
|
||||||
|
{
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0;
|
||||||
|
DrawBitmap(bitmap, bitmap->Bounds(), Bounds(), options);
|
||||||
|
#else
|
||||||
|
DrawBitmap(bitmap, bitmap->Bounds(), Bounds());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
VideoView::_AdoptGlobalSettings()
|
||||||
|
{
|
||||||
|
mpSettings settings = Settings::CurrentSettings();
|
||||||
|
|
||||||
|
fUseOverlays = settings.useOverlays;
|
||||||
|
fUseBilinearScaling = settings.scaleBilinear;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
#include "ListenerAdapter.h"
|
||||||
#include "VideoTarget.h"
|
#include "VideoTarget.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ public:
|
|||||||
|
|
||||||
// BView interface
|
// BView interface
|
||||||
virtual void Draw(BRect updateRect);
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
// VideoTarget interface
|
// VideoTarget interface
|
||||||
virtual void SetBitmap(const BBitmap* bitmap);
|
virtual void SetBitmap(const BBitmap* bitmap);
|
||||||
@@ -30,13 +32,21 @@ public:
|
|||||||
void OverlayScreenshotPrepare();
|
void OverlayScreenshotPrepare();
|
||||||
void OverlayScreenshotCleanup();
|
void OverlayScreenshotCleanup();
|
||||||
|
|
||||||
|
bool UseOverlays() const;
|
||||||
bool IsOverlayActive();
|
bool IsOverlayActive();
|
||||||
void DisableOverlay();
|
void DisableOverlay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _DrawBitmap(const BBitmap* bitmap);
|
||||||
|
void _AdoptGlobalSettings();
|
||||||
|
|
||||||
bool fOverlayMode;
|
bool fOverlayMode;
|
||||||
overlay_restrictions fOverlayRestrictions;
|
overlay_restrictions fOverlayRestrictions;
|
||||||
rgb_color fOverlayKeyColor;
|
rgb_color fOverlayKeyColor;
|
||||||
|
|
||||||
|
ListenerAdapter fGlobalSettingsListener;
|
||||||
|
bool fUseOverlays;
|
||||||
|
bool fUseBilinearScaling;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEO_VIEW_H
|
#endif // VIDEO_VIEW_H
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ NodeManager::~NodeManager()
|
|||||||
status_t
|
status_t
|
||||||
NodeManager::Init(BRect videoBounds, float videoFrameRate,
|
NodeManager::Init(BRect videoBounds, float videoFrameRate,
|
||||||
color_space preferredVideoFormat, int32 loopingMode,
|
color_space preferredVideoFormat, int32 loopingMode,
|
||||||
bool loopingEnabled, float speed, uint32 enabledNodes)
|
bool loopingEnabled, float speed, uint32 enabledNodes, bool useOverlays)
|
||||||
{
|
{
|
||||||
// init base class
|
// init base class
|
||||||
PlaybackManager::Init(videoFrameRate, loopingMode, loopingEnabled, speed);
|
PlaybackManager::Init(videoFrameRate, loopingMode, loopingEnabled, speed);
|
||||||
@@ -83,7 +83,7 @@ NodeManager::Init(BRect videoBounds, float videoFrameRate,
|
|||||||
fAudioSupplier = CreateAudioSupplier();
|
fAudioSupplier = CreateAudioSupplier();
|
||||||
|
|
||||||
return FormatChanged(videoBounds, videoFrameRate, preferredVideoFormat,
|
return FormatChanged(videoBounds, videoFrameRate, preferredVideoFormat,
|
||||||
enabledNodes, true);
|
enabledNodes, useOverlays, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitCheck
|
// InitCheck
|
||||||
@@ -118,7 +118,8 @@ NodeManager::CleanupNodes()
|
|||||||
// FormatChanged
|
// FormatChanged
|
||||||
status_t
|
status_t
|
||||||
NodeManager::FormatChanged(BRect videoBounds, float videoFrameRate,
|
NodeManager::FormatChanged(BRect videoBounds, float videoFrameRate,
|
||||||
color_space preferredVideoFormat, uint32 enabledNodes, bool force)
|
color_space preferredVideoFormat, uint32 enabledNodes, bool useOverlays,
|
||||||
|
bool force)
|
||||||
{
|
{
|
||||||
TRACE("NodeManager::FormatChanged()\n");
|
TRACE("NodeManager::FormatChanged()\n");
|
||||||
|
|
||||||
@@ -142,7 +143,8 @@ NodeManager::FormatChanged(BRect videoBounds, float videoFrameRate,
|
|||||||
|
|
||||||
SetVideoBounds(videoBounds);
|
SetVideoBounds(videoBounds);
|
||||||
|
|
||||||
status_t ret = _SetUpNodes(preferredVideoFormat, enabledNodes);
|
status_t ret = _SetUpNodes(preferredVideoFormat, enabledNodes,
|
||||||
|
useOverlays);
|
||||||
if (ret == B_OK)
|
if (ret == B_OK)
|
||||||
_StartNodes();
|
_StartNodes();
|
||||||
else
|
else
|
||||||
@@ -250,7 +252,8 @@ NodeManager::SetPeakListener(BHandler* handler)
|
|||||||
|
|
||||||
// _SetUpNodes
|
// _SetUpNodes
|
||||||
status_t
|
status_t
|
||||||
NodeManager::_SetUpNodes(color_space preferredVideoFormat, uint32 enabledNodes)
|
NodeManager::_SetUpNodes(color_space preferredVideoFormat, uint32 enabledNodes,
|
||||||
|
bool useOverlays)
|
||||||
{
|
{
|
||||||
TRACE("NodeManager::_SetUpNodes()\n");
|
TRACE("NodeManager::_SetUpNodes()\n");
|
||||||
|
|
||||||
@@ -275,7 +278,7 @@ NodeManager::_SetUpNodes(color_space preferredVideoFormat, uint32 enabledNodes)
|
|||||||
|
|
||||||
// setup the video nodes
|
// setup the video nodes
|
||||||
if (enabledNodes != AUDIO_ONLY) {
|
if (enabledNodes != AUDIO_ONLY) {
|
||||||
fStatus = _SetUpVideoNodes(preferredVideoFormat);
|
fStatus = _SetUpVideoNodes(preferredVideoFormat, useOverlays);
|
||||||
if (fStatus != B_OK) {
|
if (fStatus != B_OK) {
|
||||||
print_error("Error setting up video nodes", fStatus);
|
print_error("Error setting up video nodes", fStatus);
|
||||||
fMediaRoster->Unlock();
|
fMediaRoster->Unlock();
|
||||||
@@ -307,7 +310,8 @@ fNoAudio = true;
|
|||||||
|
|
||||||
// _SetUpVideoNodes
|
// _SetUpVideoNodes
|
||||||
status_t
|
status_t
|
||||||
NodeManager::_SetUpVideoNodes(color_space preferredVideoFormat)
|
NodeManager::_SetUpVideoNodes(color_space preferredVideoFormat,
|
||||||
|
bool useOverlays)
|
||||||
{
|
{
|
||||||
// create the video producer node
|
// create the video producer node
|
||||||
fVideoProducer = new VideoProducer(NULL, "MediaPlayer Video Out", 0,
|
fVideoProducer = new VideoProducer(NULL, "MediaPlayer Video Out", 0,
|
||||||
@@ -381,7 +385,7 @@ NodeManager::_SetUpVideoNodes(color_space preferredVideoFormat)
|
|||||||
format.u.raw_video = videoFormat;
|
format.u.raw_video = videoFormat;
|
||||||
|
|
||||||
// connect video producer to consumer (hopefully using overlays)
|
// connect video producer to consumer (hopefully using overlays)
|
||||||
fVideoConsumer->SetTryOverlay(true);
|
fVideoConsumer->SetTryOverlay(useOverlays);
|
||||||
fStatus = fMediaRoster->Connect(videoOutput.source, videoInput.destination,
|
fStatus = fMediaRoster->Connect(videoOutput.source, videoInput.destination,
|
||||||
&format, &videoOutput, &videoInput);
|
&format, &videoOutput, &videoInput);
|
||||||
|
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ class NodeManager : public PlaybackManager {
|
|||||||
|
|
||||||
status_t Init(BRect videoBounds, float videoFrameRate,
|
status_t Init(BRect videoBounds, float videoFrameRate,
|
||||||
color_space preferredVideoFormat,
|
color_space preferredVideoFormat,
|
||||||
int32 loopingMode = LOOPING_ALL,
|
int32 loopingMode,
|
||||||
bool loopingEnabled = true,
|
bool loopingEnabled,
|
||||||
float speed = 1.0,
|
float speed,
|
||||||
uint32 enabledNodes = AUDIO_AND_VIDEO);
|
uint32 enabledNodes,
|
||||||
|
bool useOverlays);
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
// only call this if the
|
// only call this if the
|
||||||
// media_server has died!
|
// media_server has died!
|
||||||
@@ -52,7 +53,8 @@ class NodeManager : public PlaybackManager {
|
|||||||
status_t FormatChanged(BRect videoBounds,
|
status_t FormatChanged(BRect videoBounds,
|
||||||
float videoFrameRate,
|
float videoFrameRate,
|
||||||
color_space preferredVideoFormat,
|
color_space preferredVideoFormat,
|
||||||
uint32 enabledNodes = AUDIO_AND_VIDEO,
|
uint32 enabledNodes,
|
||||||
|
bool useOverlays,
|
||||||
bool force = false);
|
bool force = false);
|
||||||
virtual void SetPlayMode(int32 mode,
|
virtual void SetPlayMode(int32 mode,
|
||||||
bool continuePlaying = true);
|
bool continuePlaying = true);
|
||||||
@@ -74,9 +76,10 @@ class NodeManager : public PlaybackManager {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _SetUpNodes(color_space preferredVideoFormat,
|
status_t _SetUpNodes(color_space preferredVideoFormat,
|
||||||
uint32 enabledNodes);
|
uint32 enabledNodes, bool useOverlays);
|
||||||
status_t _SetUpVideoNodes(
|
status_t _SetUpVideoNodes(
|
||||||
color_space preferredVideoFormat);
|
color_space preferredVideoFormat,
|
||||||
|
bool useOverlays);
|
||||||
status_t _SetUpAudioNodes();
|
status_t _SetUpAudioNodes();
|
||||||
status_t _TearDownNodes(bool disconnect = true);
|
status_t _TearDownNodes(bool disconnect = true);
|
||||||
status_t _StartNodes();
|
status_t _StartNodes();
|
||||||
|
|||||||
@@ -11,6 +11,20 @@
|
|||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
mpSettings::operator!=(const mpSettings& other) const
|
||||||
|
{
|
||||||
|
return autostart != other.autostart
|
||||||
|
|| closeWhenDonePlayingMovie != other.closeWhenDonePlayingMovie
|
||||||
|
|| closeWhenDonePlayingSound != other.closeWhenDonePlayingSound
|
||||||
|
|| loopMovie != other.loopMovie
|
||||||
|
|| loopSound != other.loopSound
|
||||||
|
|| useOverlays != other.useOverlays
|
||||||
|
|| scaleBilinear != other.scaleBilinear
|
||||||
|
|| backgroundMovieVolumeMode != other.backgroundMovieVolumeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Settings::Settings(const char* filename)
|
Settings::Settings(const char* filename)
|
||||||
: BLocker("settings lock"),
|
: BLocker("settings lock"),
|
||||||
fSettingsMessage(B_USER_CONFIG_DIRECTORY, filename)
|
fSettingsMessage(B_USER_CONFIG_DIRECTORY, filename)
|
||||||
@@ -36,7 +50,7 @@ Settings::LoadSettings(mpSettings& settings) const
|
|||||||
|
|
||||||
settings.backgroundMovieVolumeMode
|
settings.backgroundMovieVolumeMode
|
||||||
= fSettingsMessage.GetValue("bgMovieVolumeMode",
|
= fSettingsMessage.GetValue("bgMovieVolumeMode",
|
||||||
(uint32)mpSettings::BG_MOVIES_MUTED);
|
(uint32)mpSettings::BG_MOVIES_FULL_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -63,6 +77,8 @@ Settings::SaveSettings(const mpSettings& settings)
|
|||||||
// this will make sure the settings are saved even when the player
|
// this will make sure the settings are saved even when the player
|
||||||
// crashes.
|
// crashes.
|
||||||
fSettingsMessage.Save();
|
fSettingsMessage.Save();
|
||||||
|
|
||||||
|
Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
|
|
||||||
|
#include "Notifier.h"
|
||||||
#include "SettingsMessage.h"
|
#include "SettingsMessage.h"
|
||||||
|
|
||||||
struct mpSettings {
|
struct mpSettings {
|
||||||
@@ -27,11 +28,13 @@ struct mpSettings {
|
|||||||
BG_MOVIES_MUTED = 2
|
BG_MOVIES_MUTED = 2
|
||||||
};
|
};
|
||||||
uint32 backgroundMovieVolumeMode;
|
uint32 backgroundMovieVolumeMode;
|
||||||
|
|
||||||
|
bool operator!=(const mpSettings& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SETTINGS_FILENAME "MediaPlayerSettings"
|
#define SETTINGS_FILENAME "MediaPlayerSettings"
|
||||||
|
|
||||||
class Settings : public BLocker {
|
class Settings : public BLocker, public Notifier {
|
||||||
public:
|
public:
|
||||||
Settings(
|
Settings(
|
||||||
const char* filename = SETTINGS_FILENAME);
|
const char* filename = SETTINGS_FILENAME);
|
||||||
@@ -44,6 +47,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsMessage fSettingsMessage;
|
SettingsMessage fSettingsMessage;
|
||||||
|
BList fListeners;
|
||||||
|
|
||||||
static Settings sGlobalInstance;
|
static Settings sGlobalInstance;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ SettingsWindow::SettingsWindow(BRect frame)
|
|||||||
fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
|
fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
|
||||||
"Muted", new BMessage(M_START_MUTE_VOLUME));
|
"Muted", new BMessage(M_START_MUTE_VOLUME));
|
||||||
|
|
||||||
BButton* revertButton = new BButton("revert", "Revert",
|
fRevertB = new BButton("revert", "Revert",
|
||||||
new BMessage(M_SETTINGS_REVERT));
|
new BMessage(M_SETTINGS_REVERT));
|
||||||
|
|
||||||
BButton* cancelButton = new BButton("cancel", "Cancel",
|
BButton* cancelButton = new BButton("cancel", "Cancel",
|
||||||
@@ -167,7 +167,7 @@ SettingsWindow::SettingsWindow(BRect frame)
|
|||||||
.SetInsets(5, 5, 15, 5)
|
.SetInsets(5, 5, 15, 5)
|
||||||
)
|
)
|
||||||
.Add(BGroupLayoutBuilder(buttonLayout)
|
.Add(BGroupLayoutBuilder(buttonLayout)
|
||||||
.Add(revertButton)
|
.Add(fRevertB)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(cancelButton)
|
.Add(cancelButton)
|
||||||
.Add(okButton)
|
.Add(okButton)
|
||||||
@@ -175,9 +175,8 @@ SettingsWindow::SettingsWindow(BRect frame)
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
frame = Bounds();
|
frame = Bounds();
|
||||||
BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
||||||
view->SetViewColor(216, 216, 216);
|
view->SetViewColor(216, 216, 216);
|
||||||
@@ -251,8 +250,16 @@ SettingsWindow::SettingsWindow(BRect frame)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// disable currently unsupported features
|
// disable currently unsupported features
|
||||||
|
fAutostartCB->SetEnabled(false);
|
||||||
|
fCloseWindowMoviesCB->SetEnabled(false);
|
||||||
|
fCloseWindowSoundsCB->SetEnabled(false);
|
||||||
|
|
||||||
fLoopMoviesCB->SetEnabled(false);
|
fLoopMoviesCB->SetEnabled(false);
|
||||||
fLoopSoundsCB->SetEnabled(false);
|
fLoopSoundsCB->SetEnabled(false);
|
||||||
|
|
||||||
|
fFullVolumeBGMoviesRB->SetEnabled(false);
|
||||||
|
fHalfVolumeBGMoviesRB->SetEnabled(false);
|
||||||
|
fMutedVolumeBGMoviesRB->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -339,6 +346,8 @@ SettingsWindow::AdoptSettings()
|
|||||||
== mpSettings::BG_MOVIES_HALF_VLUME);
|
== mpSettings::BG_MOVIES_HALF_VLUME);
|
||||||
fMutedVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
|
fMutedVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
|
||||||
== mpSettings::BG_MOVIES_MUTED);
|
== mpSettings::BG_MOVIES_MUTED);
|
||||||
|
|
||||||
|
fRevertB->SetEnabled(IsRevertable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -368,6 +377,8 @@ SettingsWindow::ApplySettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Settings::Default()->SaveSettings(fSettings);
|
Settings::Default()->SaveSettings(fSettings);
|
||||||
|
|
||||||
|
fRevertB->SetEnabled(IsRevertable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -379,3 +390,10 @@ SettingsWindow::Revert()
|
|||||||
Settings::Default()->SaveSettings(fSettings);
|
Settings::Default()->SaveSettings(fSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SettingsWindow::IsRevertable() const
|
||||||
|
{
|
||||||
|
return fSettings != fLastSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
void AdoptSettings();
|
void AdoptSettings();
|
||||||
void ApplySettings();
|
void ApplySettings();
|
||||||
void Revert();
|
void Revert();
|
||||||
bool IsRevertable();
|
bool IsRevertable() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mpSettings fSettings;
|
mpSettings fSettings;
|
||||||
@@ -45,6 +45,8 @@ private:
|
|||||||
BRadioButton* fFullVolumeBGMoviesRB;
|
BRadioButton* fFullVolumeBGMoviesRB;
|
||||||
BRadioButton* fHalfVolumeBGMoviesRB;
|
BRadioButton* fHalfVolumeBGMoviesRB;
|
||||||
BRadioButton* fMutedVolumeBGMoviesRB;
|
BRadioButton* fMutedVolumeBGMoviesRB;
|
||||||
|
|
||||||
|
BButton* fRevertB;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user