* Give some options for subtitle placement and size.

* Optimize subtitle drawing when subtitles are to be
   displayed at screen bottom versus video bottom, and
   the subtitle frame does not intersect the video. In
   that case we only need to draw it when it changes
   (or is to be removed). Fixed the dead-lock problem
   in a nicer way.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38841 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-09-28 21:43:39 +00:00
parent 12d6d539c9
commit e65a6eb2e0
9 changed files with 257 additions and 83 deletions
+9 -4
View File
@@ -932,6 +932,7 @@ MainWin::MessageReceived(BMessage* msg)
float offset; float offset;
if (msg->FindFloat("offset", &offset) == B_OK) { if (msg->FindFloat("offset", &offset) == B_OK) {
fControls->MoveBy(0, offset); fControls->MoveBy(0, offset);
fVideoView->SetSubTitleMaxBottom(fControls->Frame().top - 1);
UpdateIfNeeded(); UpdateIfNeeded();
snooze(15000); snooze(15000);
} }
@@ -943,9 +944,12 @@ MainWin::MessageReceived(BMessage* msg)
bool show; bool show;
if (msg->FindFloat("offset", &offset) == B_OK if (msg->FindFloat("offset", &offset) == B_OK
&& msg->FindBool("show", &show) == B_OK) { && msg->FindBool("show", &show) == B_OK) {
if (show) if (show) {
fControls->MoveTo(fControls->Frame().left, offset); fControls->MoveTo(fControls->Frame().left, offset);
else { fVideoView->SetSubTitleMaxBottom(offset - 1);
} else {
fVideoView->SetSubTitleMaxBottom(
fVideoView->Bounds().bottom);
fControls->RemoveSelf(); fControls->RemoveSelf();
fControls->MoveTo(fVideoView->Frame().left, fControls->MoveTo(fVideoView->Frame().left,
fVideoView->Frame().bottom + 1); fVideoView->Frame().bottom + 1);
@@ -1850,6 +1854,7 @@ MainWin::_ResizeVideoView(int x, int y, int width, int height)
xOffset + renderWidth - 1, yOffset + renderHeight - 1); xOffset + renderWidth - 1, yOffset + renderHeight - 1);
fVideoView->SetVideoFrame(videoFrame); fVideoView->SetVideoFrame(videoFrame);
fVideoView->SetSubTitleMaxBottom(height - 1);
} }
@@ -1990,8 +1995,8 @@ MainWin::_ShowContextMenu(const BPoint& screenPoint)
menu->AddItem(item = new BMenuItem(aspectSubMenu)); menu->AddItem(item = new BMenuItem(aspectSubMenu));
item->SetEnabled(fHasVideo); item->SetEnabled(fHasVideo);
menu->AddItem(item = new BMenuItem("No interface", menu->AddItem(item = new BMenuItem("Hide interface",
new BMessage(M_TOGGLE_NO_INTERFACE), 'B')); new BMessage(M_TOGGLE_NO_INTERFACE), 'H'));
item->SetMarked(fNoInterface); item->SetMarked(fNoInterface);
item->SetEnabled(fHasVideo); item->SetEnabled(fHasVideo);
+124 -20
View File
@@ -18,6 +18,11 @@
#include "SubtitleBitmap.h" #include "SubtitleBitmap.h"
enum {
MSG_INVALIDATE = 'ivdt'
};
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
@@ -27,9 +32,14 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
fIsPlaying(false), fIsPlaying(false),
fIsFullscreen(false), fIsFullscreen(false),
fLastMouseMove(system_time()), fLastMouseMove(system_time()),
fGlobalSettingsListener(this),
fSubtitleBitmap(new SubtitleBitmap), fSubtitleBitmap(new SubtitleBitmap),
fHasSubtitle(false) fSubtitleFrame(),
fSubtitleMaxButtom(Bounds().bottom),
fHasSubtitle(false),
fSubtitleChanged(false),
fGlobalSettingsListener(this)
{ {
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
SetHighColor(0, 0, 0); SetHighColor(0, 0, 0);
@@ -44,7 +54,7 @@ VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
Settings::Default()->AddListener(&fGlobalSettingsListener); Settings::Default()->AddListener(&fGlobalSettingsListener);
_AdoptGlobalSettings(); _AdoptGlobalSettings();
//SetSubtitle("<b><i>This</i></b> is a <font color=\"#00ff00\">test</font>!" //SetSubTitle("<b><i>This</i></b> is a <font color=\"#00ff00\">test</font>!"
// "\nWith a <i>short</i> line and a <b>long</b> line."); // "\nWith a <i>short</i> line and a <b>long</b> line.");
} }
@@ -74,6 +84,9 @@ VideoView::Draw(BRect updateRect)
if (outSideVideoRegion.CountRects() > 0) if (outSideVideoRegion.CountRects() > 0)
FillRegion(&outSideVideoRegion); FillRegion(&outSideVideoRegion);
if (fHasSubtitle)
_DrawSubtitle();
} }
@@ -87,6 +100,13 @@ VideoView::MessageReceived(BMessage* message)
// the global settings instance... // the global settings instance...
_AdoptGlobalSettings(); _AdoptGlobalSettings();
break; break;
case MSG_INVALIDATE:
{
BRect dirty;
if (message->FindRect("dirty", &dirty) == B_OK)
Invalidate(dirty);
break;
}
default: default:
BView::MessageReceived(message); BView::MessageReceived(message);
} }
@@ -185,9 +205,13 @@ VideoView::SetBitmap(const BBitmap* bitmap)
SetViewColor(B_TRANSPARENT_COLOR); SetViewColor(B_TRANSPARENT_COLOR);
} }
if (!fOverlayMode) { if (!fOverlayMode) {
if (fHasSubtitle) if (fSubtitleChanged) {
_LayoutSubtitle();
Invalidate(fVideoFrame | fSubtitleFrame);
} else if (fHasSubtitle
&& fVideoFrame.Intersects(fSubtitleFrame)) {
Invalidate(fVideoFrame); Invalidate(fVideoFrame);
else } else
_DrawBitmap(bitmap); _DrawBitmap(bitmap);
} }
@@ -286,27 +310,55 @@ VideoView::SetVideoFrame(const BRect& frame)
fVideoFrame = frame; fVideoFrame = frame;
fSubtitleBitmap->SetVideoBounds(fVideoFrame.OffsetToCopy(B_ORIGIN)); fSubtitleBitmap->SetVideoBounds(fVideoFrame.OffsetToCopy(B_ORIGIN));
_LayoutSubtitle();
} }
void void
VideoView::SetSubTitle(const char* text) VideoView::SetSubTitle(const char* text)
{ {
BRect oldSubtitleFrame = fSubtitleFrame;
if (text == NULL || text[0] == '\0') { if (text == NULL || text[0] == '\0') {
fHasSubtitle = false; fHasSubtitle = false;
fSubtitleChanged = true;
} else { } else {
fHasSubtitle = true; fHasSubtitle = true;
fSubtitleBitmap->SetText(text); // If the subtitle frame still needs to be invalidated during
// normal playback, make sure we don't unset the fSubtitleChanged
// flag. It will be reset after drawing the subtitle once.
fSubtitleChanged = fSubtitleBitmap->SetText(text) || fSubtitleChanged;
if (fSubtitleChanged)
_LayoutSubtitle();
} }
// TODO: Make smarter and invalidate only previous subtitle bitmap
// region. Fix locking, too... if (!fIsPlaying && Window() != NULL) {
if (!fIsPlaying && LockLooperWithTimeout(1000) == B_OK) { // If we are playing, the new subtitle will be displayed,
Invalidate(); // or the old one removed from screen, as soon as the next
UnlockLooper(); // frame is shown. Otherwise we need to invalidate manually.
// But we are not in the window thread and we shall not lock
// it or we may dead-locks.
BMessage message(MSG_INVALIDATE);
message.AddRect("dirty", oldSubtitleFrame | fSubtitleFrame);
Window()->PostMessage(&message);
} }
} }
void
VideoView::SetSubTitleMaxBottom(float bottom)
{
if (bottom == fSubtitleMaxButtom)
return;
fSubtitleMaxButtom = bottom;
BRect oldSubtitleFrame = fSubtitleFrame;
_LayoutSubtitle();
Invalidate(fSubtitleFrame | oldSubtitleFrame);
}
// #pragma mark - // #pragma mark -
@@ -316,18 +368,20 @@ VideoView::_DrawBitmap(const BBitmap* bitmap)
SetDrawingMode(B_OP_COPY); SetDrawingMode(B_OP_COPY);
uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0; uint32 options = fUseBilinearScaling ? B_FILTER_BITMAP_BILINEAR : 0;
DrawBitmapAsync(bitmap, bitmap->Bounds(), fVideoFrame, options); DrawBitmapAsync(bitmap, bitmap->Bounds(), fVideoFrame, options);
}
if (fHasSubtitle) {
void
VideoView::_DrawSubtitle()
{
SetDrawingMode(B_OP_ALPHA); SetDrawingMode(B_OP_ALPHA);
SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
const BBitmap* subtitleBitmap = fSubtitleBitmap->Bitmap(); DrawBitmapAsync(fSubtitleBitmap->Bitmap(), fSubtitleFrame.LeftTop());
BPoint offset;
offset.x = (fVideoFrame.left + fVideoFrame.right // Unless the subtitle frame intersects the video frame, we don't have
- subtitleBitmap->Bounds().Width()) / 2; // to draw the subtitle again.
offset.y = fVideoFrame.bottom - subtitleBitmap->Bounds().Height(); fSubtitleChanged = false;
DrawBitmapAsync(subtitleBitmap, offset);
}
} }
@@ -340,7 +394,21 @@ VideoView::_AdoptGlobalSettings()
fUseOverlays = settings.useOverlays; fUseOverlays = settings.useOverlays;
fUseBilinearScaling = settings.scaleBilinear; fUseBilinearScaling = settings.scaleBilinear;
if (!fIsPlaying && !fOverlayMode) switch (settings.subtitleSize) {
case mpSettings::SUBTITLE_SIZE_SMALL:
fSubtitleBitmap->SetCharsPerLine(45.0);
break;
case mpSettings::SUBTITLE_SIZE_MEDIUM:
fSubtitleBitmap->SetCharsPerLine(36.0);
break;
case mpSettings::SUBTITLE_SIZE_LARGE:
fSubtitleBitmap->SetCharsPerLine(32.0);
break;
}
fSubtitlePlacement = settings.subtitlePlacement;
_LayoutSubtitle();
Invalidate(); Invalidate();
} }
@@ -353,3 +421,39 @@ VideoView::_SetOverlayMode(bool overlayMode)
} }
void
VideoView::_LayoutSubtitle()
{
if (!fHasSubtitle)
return;
const BBitmap* subtitleBitmap = fSubtitleBitmap->Bitmap();
if (subtitleBitmap == NULL)
return;
fSubtitleFrame = subtitleBitmap->Bounds();
BPoint offset;
offset.x = (fVideoFrame.left + fVideoFrame.right
- fSubtitleFrame.Width()) / 2;
switch (fSubtitlePlacement) {
default:
case mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO:
offset.y = fVideoFrame.bottom - fSubtitleFrame.Height();
break;
case mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN:
{
// Center between video and screen bottom, if there is still
// enough room.
float centeredOffset = (fVideoFrame.bottom + fSubtitleMaxButtom
- fSubtitleFrame.Height()) / 2;
float maxOffset = fSubtitleMaxButtom - fSubtitleFrame.Height();
offset.y = min_c(centeredOffset, maxOffset);
break;
}
}
fSubtitleFrame.OffsetTo(offset);
}
+11 -3
View File
@@ -52,11 +52,14 @@ public:
void SetVideoFrame(const BRect& frame); void SetVideoFrame(const BRect& frame);
void SetSubTitle(const char* text); void SetSubTitle(const char* text);
void SetSubTitleMaxBottom(float bottom);
private: private:
void _DrawBitmap(const BBitmap* bitmap); void _DrawBitmap(const BBitmap* bitmap);
void _DrawSubtitle();
void _AdoptGlobalSettings(); void _AdoptGlobalSettings();
void _SetOverlayMode(bool overlayMode); void _SetOverlayMode(bool overlayMode);
void _LayoutSubtitle();
private: private:
BRect fVideoFrame; BRect fVideoFrame;
@@ -67,12 +70,17 @@ private:
bool fIsFullscreen; bool fIsFullscreen;
bigtime_t fLastMouseMove; bigtime_t fLastMouseMove;
SubtitleBitmap* fSubtitleBitmap;
BRect fSubtitleFrame;
float fSubtitleMaxButtom;
bool fHasSubtitle;
bool fSubtitleChanged;
// Settings values:
ListenerAdapter fGlobalSettingsListener; ListenerAdapter fGlobalSettingsListener;
bool fUseOverlays; bool fUseOverlays;
bool fUseBilinearScaling; bool fUseBilinearScaling;
uint32 fSubtitlePlacement;
SubtitleBitmap* fSubtitleBitmap;
bool fHasSubtitle;
}; };
#endif // VIDEO_VIEW_H #endif // VIDEO_VIEW_H
@@ -19,6 +19,7 @@ SubtitleBitmap::SubtitleBitmap()
fBitmap(NULL), fBitmap(NULL),
fTextView(new BTextView("offscreen text")), fTextView(new BTextView("offscreen text")),
fShadowTextView(new BTextView("offscreen text shadow")), fShadowTextView(new BTextView("offscreen text shadow")),
fCharsPerLine(36),
fUseSoftShadow(true), fUseSoftShadow(true),
fOverlayMode(false) fOverlayMode(false)
{ {
@@ -42,15 +43,16 @@ SubtitleBitmap::~SubtitleBitmap()
} }
void bool
SubtitleBitmap::SetText(const char* text) SubtitleBitmap::SetText(const char* text)
{ {
if (text == fText) if (text == fText)
return; return false;
fText = text; fText = text;
_GenerateBitmap(); _GenerateBitmap();
return true;
} }
@@ -79,6 +81,19 @@ SubtitleBitmap::SetOverlayMode(bool overlayMode)
} }
void
SubtitleBitmap::SetCharsPerLine(float charsPerLine)
{
if (charsPerLine == fCharsPerLine)
return;
fCharsPerLine = charsPerLine;
fUseSoftShadow = true;
_GenerateBitmap();
}
const BBitmap* const BBitmap*
SubtitleBitmap::Bitmap() const SubtitleBitmap::Bitmap() const
{ {
@@ -313,7 +328,7 @@ SubtitleBitmap::_InsertText(BRect& textRect, float& outlineRadius,
bool overlayMode) bool overlayMode)
{ {
BFont font(be_plain_font); BFont font(be_plain_font);
float fontSize = ceilf((fVideoBounds.Width() * 0.9) / 36); float fontSize = ceilf((fVideoBounds.Width() * 0.9) / fCharsPerLine);
outlineRadius = ceilf(fontSize / 28.0); outlineRadius = ceilf(fontSize / 28.0);
font.SetSize(fontSize); font.SetSize(fontSize);
@@ -19,9 +19,10 @@ public:
SubtitleBitmap(); SubtitleBitmap();
virtual ~SubtitleBitmap(); virtual ~SubtitleBitmap();
void SetText(const char* text); bool SetText(const char* text);
void SetVideoBounds(BRect bounds); void SetVideoBounds(BRect bounds);
void SetOverlayMode(bool overlayMode); void SetOverlayMode(bool overlayMode);
void SetCharsPerLine(float charsPerLine);
const BBitmap* Bitmap() const; const BBitmap* Bitmap() const;
@@ -37,6 +38,7 @@ private:
BString fText; BString fText;
BRect fVideoBounds; BRect fVideoBounds;
float fCharsPerLine;
bool fUseSoftShadow; bool fUseSoftShadow;
bool fOverlayMode; bool fOverlayMode;
}; };
+14 -1
View File
@@ -22,6 +22,8 @@ mpSettings::operator!=(const mpSettings& other) const
|| useOverlays != other.useOverlays || useOverlays != other.useOverlays
|| scaleBilinear != other.scaleBilinear || scaleBilinear != other.scaleBilinear
|| scaleFullscreenControls != other.scaleFullscreenControls || scaleFullscreenControls != other.scaleFullscreenControls
|| subtitleSize != other.subtitleSize
|| subtitlePlacement != other.subtitlePlacement
|| backgroundMovieVolumeMode != other.backgroundMovieVolumeMode || backgroundMovieVolumeMode != other.backgroundMovieVolumeMode
|| filePanelFolder != other.filePanelFolder || filePanelFolder != other.filePanelFolder
|| audioPlayerWindowFrame != other.audioPlayerWindowFrame; || audioPlayerWindowFrame != other.audioPlayerWindowFrame;
@@ -29,7 +31,8 @@ mpSettings::operator!=(const mpSettings& other) const
Settings::Settings(const char* filename) Settings::Settings(const char* filename)
: BLocker("settings lock"), :
BLocker("settings lock"),
fSettingsMessage(B_USER_SETTINGS_DIRECTORY, filename) fSettingsMessage(B_USER_SETTINGS_DIRECTORY, filename)
{ {
// The settings are loaded from disk in the SettingsMessage constructor. // The settings are loaded from disk in the SettingsMessage constructor.
@@ -54,6 +57,13 @@ Settings::LoadSettings(mpSettings& settings) const
settings.scaleFullscreenControls settings.scaleFullscreenControls
= fSettingsMessage.GetValue("scaleFullscreenControls", true); = fSettingsMessage.GetValue("scaleFullscreenControls", true);
settings.subtitleSize
= fSettingsMessage.GetValue("subtitleSize",
(uint32)mpSettings::SUBTITLE_SIZE_MEDIUM);
settings.subtitlePlacement
= fSettingsMessage.GetValue("subtitlePlacement",
(uint32)mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO);
settings.backgroundMovieVolumeMode settings.backgroundMovieVolumeMode
= fSettingsMessage.GetValue("bgMovieVolumeMode", = fSettingsMessage.GetValue("bgMovieVolumeMode",
(uint32)mpSettings::BG_MOVIES_FULL_VOLUME); (uint32)mpSettings::BG_MOVIES_FULL_VOLUME);
@@ -86,6 +96,9 @@ Settings::SaveSettings(const mpSettings& settings)
fSettingsMessage.SetValue("scaleFullscreenControls", fSettingsMessage.SetValue("scaleFullscreenControls",
settings.scaleFullscreenControls); settings.scaleFullscreenControls);
fSettingsMessage.SetValue("subtitleSize", settings.subtitleSize);
fSettingsMessage.SetValue("subtitlePlacement", settings.subtitlePlacement);
fSettingsMessage.SetValue("bgMovieVolumeMode", fSettingsMessage.SetValue("bgMovieVolumeMode",
settings.backgroundMovieVolumeMode); settings.backgroundMovieVolumeMode);
+17 -5
View File
@@ -16,6 +16,21 @@
#include "SettingsMessage.h" #include "SettingsMessage.h"
struct mpSettings { struct mpSettings {
enum {
SUBTITLE_SIZE_SMALL = 0,
SUBTITLE_SIZE_MEDIUM = 1,
SUBTITLE_SIZE_LARGE = 2
};
enum {
SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO = 0,
SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN = 1
};
enum {
BG_MOVIES_FULL_VOLUME = 0,
BG_MOVIES_HALF_VLUME = 1,
BG_MOVIES_MUTED = 2
};
bool autostart; bool autostart;
bool closeWhenDonePlayingMovie; bool closeWhenDonePlayingMovie;
bool closeWhenDonePlayingSound; bool closeWhenDonePlayingSound;
@@ -24,11 +39,8 @@ struct mpSettings {
bool useOverlays; bool useOverlays;
bool scaleBilinear; bool scaleBilinear;
bool scaleFullscreenControls; bool scaleFullscreenControls;
enum { uint32 subtitleSize;
BG_MOVIES_FULL_VOLUME = 0, uint32 subtitlePlacement;
BG_MOVIES_HALF_VLUME = 1,
BG_MOVIES_MUTED = 2
};
uint32 backgroundMovieVolumeMode; uint32 backgroundMovieVolumeMode;
entry_ref filePanelFolder; entry_ref filePanelFolder;
@@ -7,6 +7,7 @@
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
*/ */
#include "SettingsWindow.h" #include "SettingsWindow.h"
#include <stdio.h> #include <stdio.h>
@@ -16,36 +17,31 @@
#include <CheckBox.h> #include <CheckBox.h>
#include <GridLayoutBuilder.h> #include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <OptionPopUp.h>
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
#include <String.h> #include <String.h>
#include <StringView.h> #include <StringView.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <View.h> #include <View.h>
enum { enum {
M_AUTOSTART = 0x3000, M_SETTINGS_CHANGED = 0x3000,
M_CLOSE_WINDOW_MOVIE,
M_CLOSE_WINDOW_SOUNDS,
M_LOOP_MOVIE,
M_LOOP_SOUND,
M_USE_OVERLAYS,
M_SCALE_BILINEAR,
M_SCALE_CONTROLS,
M_START_FULL_VOLUME,
M_START_HALF_VOLUME,
M_START_MUTE_VOLUME,
M_SETTINGS_SAVE, M_SETTINGS_SAVE,
M_SETTINGS_CANCEL, M_SETTINGS_CANCEL,
M_SETTINGS_REVERT M_SETTINGS_REVERT
}; };
#define SPACE 10 #define SPACE 10
#define SPACEING 7 #define SPACEING 7
#define BUTTONHEIGHT 20 #define BUTTONHEIGHT 20
SettingsWindow::SettingsWindow(BRect frame) SettingsWindow::SettingsWindow(BRect frame)
: BWindow(frame, "MediaPlayer settings", B_FLOATING_WINDOW_LOOK, :
BWindow(frame, "MediaPlayer settings", B_FLOATING_WINDOW_LOOK,
B_FLOATING_APP_WINDOW_FEEL, B_FLOATING_APP_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS) | B_AUTO_UPDATE_SIZE_LIMITS)
@@ -72,39 +68,52 @@ SettingsWindow::SettingsWindow(BRect frame)
bgMoviesModeLabel->SetFont(be_bold_font); bgMoviesModeLabel->SetFont(be_bold_font);
fAutostartCB = new BCheckBox("chkboxAutostart", fAutostartCB = new BCheckBox("chkboxAutostart",
"Automatically start playing", new BMessage(M_AUTOSTART)); "Automatically start playing", new BMessage(M_SETTINGS_CHANGED));
fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies", fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies",
"Close window when done playing movies", "Close window when done playing movies",
new BMessage(M_CLOSE_WINDOW_MOVIE)); new BMessage(M_SETTINGS_CHANGED));
fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds", fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds",
"Close window when done playing sounds", "Close window when done playing sounds",
new BMessage(M_CLOSE_WINDOW_SOUNDS)); new BMessage(M_SETTINGS_CHANGED));
fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie", fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie",
"Loop movies by default", new BMessage(M_LOOP_MOVIE)); "Loop movies by default", new BMessage(M_SETTINGS_CHANGED));
fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds", fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds",
"Loop sounds by default", new BMessage(M_LOOP_SOUND)); "Loop sounds by default", new BMessage(M_SETTINGS_CHANGED));
fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays", fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays",
"Use hardware video overlays if available", "Use hardware video overlays if available",
new BMessage(M_USE_OVERLAYS)); new BMessage(M_SETTINGS_CHANGED));
fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear", fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear",
"Scale movies smoothly (non-overlay mode)", "Scale movies smoothly (non-overlay mode)",
new BMessage(M_SCALE_BILINEAR)); new BMessage(M_SETTINGS_CHANGED));
fScaleFullscreenControlsCB = new BCheckBox("chkBoxScaleControls", fScaleFullscreenControlsCB = new BCheckBox("chkBoxScaleControls",
"Scale controls in full-screen mode", "Scale controls in full-screen mode",
new BMessage(M_SCALE_CONTROLS)); new BMessage(M_SETTINGS_CHANGED));
fSubtitleSizeOP = new BOptionPopUp("subtitleSize",
"Subtitle size", new BMessage(M_SETTINGS_CHANGED));
fSubtitleSizeOP->AddOption("Small", mpSettings::SUBTITLE_SIZE_SMALL);
fSubtitleSizeOP->AddOption("Medium", mpSettings::SUBTITLE_SIZE_MEDIUM);
fSubtitleSizeOP->AddOption("Large", mpSettings::SUBTITLE_SIZE_LARGE);
fSubtitlePlacementOP = new BOptionPopUp("subtitlePlacement",
"Subtitle placement", new BMessage(M_SETTINGS_CHANGED));
fSubtitlePlacementOP->AddOption("Bottom of video",
mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO);
fSubtitlePlacementOP->AddOption("Bottom of screen",
mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN);
fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
"Full volume", new BMessage(M_START_FULL_VOLUME)); "Full volume", new BMessage(M_SETTINGS_CHANGED));
fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume", fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume",
"Low volume", new BMessage(M_START_HALF_VOLUME)); "Low volume", new BMessage(M_SETTINGS_CHANGED));
fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
"Muted", new BMessage(M_START_MUTE_VOLUME)); "Muted", new BMessage(M_SETTINGS_CHANGED));
fRevertB = new BButton("revert", "Revert", fRevertB = new BButton("revert", "Revert",
new BMessage(M_SETTINGS_REVERT)); new BMessage(M_SETTINGS_REVERT));
@@ -146,6 +155,8 @@ SettingsWindow::SettingsWindow(BRect frame)
.Add(fUseOverlaysCB) .Add(fUseOverlaysCB)
.Add(fScaleBilinearCB) .Add(fScaleBilinearCB)
.Add(fScaleFullscreenControlsCB) .Add(fScaleFullscreenControlsCB)
.Add(fSubtitleSizeOP)
.Add(fSubtitlePlacementOP)
) )
) )
.Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(BSpaceLayoutItem::CreateVerticalStrut(5))
@@ -205,17 +216,7 @@ void
SettingsWindow::MessageReceived(BMessage* message) SettingsWindow::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case M_AUTOSTART: case M_SETTINGS_CHANGED:
case M_CLOSE_WINDOW_MOVIE:
case M_CLOSE_WINDOW_SOUNDS:
case M_LOOP_MOVIE:
case M_LOOP_SOUND:
case M_USE_OVERLAYS:
case M_SCALE_BILINEAR:
case M_SCALE_CONTROLS:
case M_START_FULL_VOLUME:
case M_START_HALF_VOLUME:
case M_START_MUTE_VOLUME:
ApplySettings(); ApplySettings();
break; break;
@@ -256,6 +257,9 @@ SettingsWindow::AdoptSettings()
fScaleBilinearCB->SetValue(fSettings.scaleBilinear); fScaleBilinearCB->SetValue(fSettings.scaleBilinear);
fScaleFullscreenControlsCB->SetValue(fSettings.scaleFullscreenControls); fScaleFullscreenControlsCB->SetValue(fSettings.scaleFullscreenControls);
fSubtitleSizeOP->SetValue(fSettings.subtitleSize);
fSubtitlePlacementOP->SetValue(fSettings.subtitlePlacement);
fFullVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode fFullVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
== mpSettings::BG_MOVIES_FULL_VOLUME); == mpSettings::BG_MOVIES_FULL_VOLUME);
fHalfVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode fHalfVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
@@ -283,6 +287,9 @@ SettingsWindow::ApplySettings()
fSettings.scaleFullscreenControls fSettings.scaleFullscreenControls
= fScaleFullscreenControlsCB->Value() == B_CONTROL_ON; = fScaleFullscreenControlsCB->Value() == B_CONTROL_ON;
fSettings.subtitleSize = fSubtitleSizeOP->Value();
fSettings.subtitlePlacement = fSubtitlePlacementOP->Value();
if (fFullVolumeBGMoviesRB->Value() == B_CONTROL_ON) { if (fFullVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
fSettings.backgroundMovieVolumeMode fSettings.backgroundMovieVolumeMode
= mpSettings::BG_MOVIES_FULL_VOLUME; = mpSettings::BG_MOVIES_FULL_VOLUME;
+13 -5
View File
@@ -5,16 +5,20 @@
* Authors: * Authors:
* Fredrik Modéen <fredrik@modeen.se> * Fredrik Modéen <fredrik@modeen.se>
*/ */
#ifndef SETTINGS_WINDOW_H
#define SETTINGS_WINDOW_H
#ifndef _SETTINGS_WINDOW_H
#define _SETTINGS_WINDOW_H
#include <Window.h> #include <Window.h>
#include <CheckBox.h>
#include <RadioButton.h>
#include "Settings.h" #include "Settings.h"
class BCheckBox;
class BOptionPopUp;
class BRadioButton;
class SettingsWindow : public BWindow { class SettingsWindow : public BWindow {
public: public:
SettingsWindow(BRect frame); SettingsWindow(BRect frame);
@@ -43,6 +47,9 @@ private:
BCheckBox* fScaleBilinearCB; BCheckBox* fScaleBilinearCB;
BCheckBox* fScaleFullscreenControlsCB; BCheckBox* fScaleFullscreenControlsCB;
BOptionPopUp* fSubtitleSizeOP;
BOptionPopUp* fSubtitlePlacementOP;
BRadioButton* fFullVolumeBGMoviesRB; BRadioButton* fFullVolumeBGMoviesRB;
BRadioButton* fHalfVolumeBGMoviesRB; BRadioButton* fHalfVolumeBGMoviesRB;
BRadioButton* fMutedVolumeBGMoviesRB; BRadioButton* fMutedVolumeBGMoviesRB;
@@ -50,4 +57,5 @@ private:
BButton* fRevertB; BButton* fRevertB;
}; };
#endif
#endif // SETTINGS_WINDOW_H