* Show the controls in full-screen mode when the mouse moves.
* Propagate the current audio channel count to the controls. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38490 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -355,8 +355,6 @@ Controller::SetTo(const PlaylistItemRef& item)
|
|||||||
const media_format& audioTrackFormat = fAudioTrackSupplier->Format();
|
const media_format& audioTrackFormat = fAudioTrackSupplier->Format();
|
||||||
audioFrameRate = audioTrackFormat.u.raw_audio.frame_rate;
|
audioFrameRate = audioTrackFormat.u.raw_audio.frame_rate;
|
||||||
audioChannels = audioTrackFormat.u.raw_audio.channel_count;
|
audioChannels = audioTrackFormat.u.raw_audio.channel_count;
|
||||||
// if (fVideoTrackSupplier == NULL)
|
|
||||||
// fVideoFrameRate = audioFrameRate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InitCheck() != B_OK) {
|
if (InitCheck() != B_OK) {
|
||||||
@@ -500,6 +498,17 @@ Controller::CurrentAudioTrack()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
Controller::AudioTrackChannelCount()
|
||||||
|
{
|
||||||
|
media_format format;
|
||||||
|
if (GetEncodedAudioFormat(&format) == B_OK)
|
||||||
|
return format.u.encoded_audio.output.channel_count;
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Controller::SelectVideoTrack(int n)
|
Controller::SelectVideoTrack(int n)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ public:
|
|||||||
|
|
||||||
status_t SelectAudioTrack(int n);
|
status_t SelectAudioTrack(int n);
|
||||||
int CurrentAudioTrack();
|
int CurrentAudioTrack();
|
||||||
|
int AudioTrackChannelCount();
|
||||||
status_t SelectVideoTrack(int n);
|
status_t SelectVideoTrack(int n);
|
||||||
int CurrentVideoTrack();
|
int CurrentVideoTrack();
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,10 @@ enum {
|
|||||||
|
|
||||||
M_FILE_DELETE,
|
M_FILE_DELETE,
|
||||||
|
|
||||||
M_SHOW_IF_NEEDED
|
M_SHOW_IF_NEEDED,
|
||||||
|
|
||||||
|
M_SLIDE_CONTROLS,
|
||||||
|
M_FINISH_SLIDING_CONTROLS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -162,13 +165,19 @@ MainWin::MainWin(bool isFirstWindow, BMessage* message)
|
|||||||
fIsFullscreen(false),
|
fIsFullscreen(false),
|
||||||
fAlwaysOnTop(false),
|
fAlwaysOnTop(false),
|
||||||
fNoInterface(false),
|
fNoInterface(false),
|
||||||
|
fShowsFullscreenControls(false),
|
||||||
fSourceWidth(-1),
|
fSourceWidth(-1),
|
||||||
fSourceHeight(-1),
|
fSourceHeight(-1),
|
||||||
fWidthAspect(0),
|
fWidthAspect(0),
|
||||||
fHeightAspect(0),
|
fHeightAspect(0),
|
||||||
fSavedFrame(),
|
fSavedFrame(),
|
||||||
fNoVideoFrame(),
|
fNoVideoFrame(),
|
||||||
|
|
||||||
fMouseDownTracking(false),
|
fMouseDownTracking(false),
|
||||||
|
fLastMousePos(0, 0),
|
||||||
|
fLastMouseMovedTime(system_time()),
|
||||||
|
fMouseMoveDist(0),
|
||||||
|
|
||||||
fGlobalSettingsListener(this),
|
fGlobalSettingsListener(this),
|
||||||
fInitialSeekPosition(0)
|
fInitialSeekPosition(0)
|
||||||
{
|
{
|
||||||
@@ -376,17 +385,20 @@ MainWin::DispatchMessage(BMessage* msg, BHandler* handler)
|
|||||||
{
|
{
|
||||||
if ((msg->what == B_MOUSE_DOWN)
|
if ((msg->what == B_MOUSE_DOWN)
|
||||||
&& (handler == fBackground || handler == fVideoView
|
&& (handler == fBackground || handler == fVideoView
|
||||||
|| handler == fControls))
|
|| handler == fControls)) {
|
||||||
_MouseDown(msg, dynamic_cast<BView*>(handler));
|
_MouseDown(msg, dynamic_cast<BView*>(handler));
|
||||||
|
}
|
||||||
|
|
||||||
if ((msg->what == B_MOUSE_MOVED)
|
if ((msg->what == B_MOUSE_MOVED)
|
||||||
&& (handler == fBackground || handler == fVideoView
|
&& (handler == fBackground || handler == fVideoView
|
||||||
|| handler == fControls))
|
|| handler == fControls)) {
|
||||||
_MouseMoved(msg, dynamic_cast<BView*>(handler));
|
_MouseMoved(msg, dynamic_cast<BView*>(handler));
|
||||||
|
}
|
||||||
|
|
||||||
if ((msg->what == B_MOUSE_UP)
|
if ((msg->what == B_MOUSE_UP)
|
||||||
&& (handler == fBackground || handler == fVideoView))
|
&& (handler == fBackground || handler == fVideoView)) {
|
||||||
_MouseUp(msg);
|
_MouseUp(msg);
|
||||||
|
}
|
||||||
|
|
||||||
if ((msg->what == B_KEY_DOWN)
|
if ((msg->what == B_KEY_DOWN)
|
||||||
&& (handler == fBackground || handler == fVideoView)) {
|
&& (handler == fBackground || handler == fVideoView)) {
|
||||||
@@ -642,6 +654,7 @@ MainWin::MessageReceived(BMessage* msg)
|
|||||||
item->SetMarked(i == index);
|
item->SetMarked(i == index);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
_UpdateAudioChannelCount(index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -838,6 +851,48 @@ MainWin::MessageReceived(BMessage* msg)
|
|||||||
_ShowIfNeeded();
|
_ShowIfNeeded();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case M_SLIDE_CONTROLS:
|
||||||
|
{
|
||||||
|
float offset;
|
||||||
|
if (msg->FindFloat("offset", &offset) == B_OK) {
|
||||||
|
fControls->MoveBy(0, offset);
|
||||||
|
UpdateIfNeeded();
|
||||||
|
snooze(15000);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case M_FINISH_SLIDING_CONTROLS:
|
||||||
|
{
|
||||||
|
float offset;
|
||||||
|
bool show;
|
||||||
|
if (msg->FindFloat("offset", &offset) == B_OK
|
||||||
|
&& msg->FindBool("show", &show) == B_OK) {
|
||||||
|
if (show)
|
||||||
|
fControls->MoveTo(fControls->Frame().left, offset);
|
||||||
|
else {
|
||||||
|
fControls->RemoveSelf();
|
||||||
|
fControls->MoveTo(fVideoView->Frame().left,
|
||||||
|
fVideoView->Frame().bottom + 1);
|
||||||
|
fBackground->AddChild(fControls);
|
||||||
|
while (!fControls->IsHidden())
|
||||||
|
fControls->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case M_HIDE_FULL_SCREEN_CONTROLS:
|
||||||
|
if (fIsFullscreen) {
|
||||||
|
BPoint videoViewWhere;
|
||||||
|
if (msg->FindPoint("where", &videoViewWhere) == B_OK) {
|
||||||
|
if (!fControls->Frame().Contains(videoViewWhere)) {
|
||||||
|
_ShowFullscreenControls(false);
|
||||||
|
// hide the mouse cursor until the user moves it
|
||||||
|
be_app->ObscureCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (msg->what >= M_SELECT_AUDIO_TRACK
|
if (msg->what >= M_SELECT_AUDIO_TRACK
|
||||||
&& msg->what <= M_SELECT_AUDIO_TRACK_END) {
|
&& msg->what <= M_SELECT_AUDIO_TRACK_END) {
|
||||||
@@ -1204,6 +1259,7 @@ MainWin::_SetupWindow()
|
|||||||
// printf("MainWin::_SetupWindow\n");
|
// printf("MainWin::_SetupWindow\n");
|
||||||
// Populate the track menus
|
// Populate the track menus
|
||||||
_SetupTrackMenus(fAudioTrackMenu, fVideoTrackMenu);
|
_SetupTrackMenus(fAudioTrackMenu, fVideoTrackMenu);
|
||||||
|
_UpdateAudioChannelCount(fController->CurrentAudioTrack());
|
||||||
|
|
||||||
fVideoMenu->SetEnabled(fHasVideo);
|
fVideoMenu->SetEnabled(fHasVideo);
|
||||||
fAudioMenu->SetEnabled(fHasAudio);
|
fAudioMenu->SetEnabled(fHasAudio);
|
||||||
@@ -1436,6 +1492,13 @@ MainWin::_SetupTrackMenus(BMenu* audioTrackMenu, BMenu* videoTrackMenu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWin::_UpdateAudioChannelCount(int32 audioTrackIndex)
|
||||||
|
{
|
||||||
|
fControls->SetAudioChannelCount(fController->AudioTrackChannelCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MainWin::_GetMinimumWindowSize(int& width, int& height) const
|
MainWin::_GetMinimumWindowSize(int& width, int& height) const
|
||||||
{
|
{
|
||||||
@@ -1682,9 +1745,6 @@ MainWin::_MouseMoved(BMessage* msg, BView* originalHandler)
|
|||||||
|
|
||||||
BPoint mousePos;
|
BPoint mousePos;
|
||||||
uint32 buttons = msg->FindInt32("buttons");
|
uint32 buttons = msg->FindInt32("buttons");
|
||||||
|
|
||||||
if (buttons == B_PRIMARY_MOUSE_BUTTON && fMouseDownTracking
|
|
||||||
&& !fIsFullscreen) {
|
|
||||||
// On Zeta, only "screen_where" is reliable, "where"
|
// On Zeta, only "screen_where" is reliable, "where"
|
||||||
// and "be:view_where" seem to be broken
|
// and "be:view_where" seem to be broken
|
||||||
if (msg->FindPoint("screen_where", &mousePos) != B_OK) {
|
if (msg->FindPoint("screen_where", &mousePos) != B_OK) {
|
||||||
@@ -1694,6 +1754,9 @@ MainWin::_MouseMoved(BMessage* msg, BView* originalHandler)
|
|||||||
return;
|
return;
|
||||||
originalHandler->ConvertToScreen(&mousePos);
|
originalHandler->ConvertToScreen(&mousePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buttons == B_PRIMARY_MOUSE_BUTTON && fMouseDownTracking
|
||||||
|
&& !fIsFullscreen) {
|
||||||
// printf("screen where: %.0f, %.0f => ", mousePos.x, mousePos.y);
|
// printf("screen where: %.0f, %.0f => ", mousePos.x, mousePos.y);
|
||||||
float delta_x = mousePos.x - fMouseDownMousePos.x;
|
float delta_x = mousePos.x - fMouseDownMousePos.x;
|
||||||
float delta_y = mousePos.y - fMouseDownMousePos.y;
|
float delta_y = mousePos.y - fMouseDownMousePos.y;
|
||||||
@@ -1702,6 +1765,25 @@ MainWin::_MouseMoved(BMessage* msg, BView* originalHandler)
|
|||||||
// printf("move window to %.0f, %.0f\n", x, y);
|
// printf("move window to %.0f, %.0f\n", x, y);
|
||||||
MoveTo(x, y);
|
MoveTo(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bigtime_t eventTime;
|
||||||
|
if (msg->FindInt64("when", &eventTime) != B_OK)
|
||||||
|
eventTime = system_time();
|
||||||
|
|
||||||
|
if (buttons == 0 && fIsFullscreen) {
|
||||||
|
BPoint moveDelta = mousePos - fLastMousePos;
|
||||||
|
float moveDeltaDist
|
||||||
|
= sqrtf(moveDelta.x * moveDelta.x + moveDelta.y * moveDelta.y);
|
||||||
|
if (eventTime - fLastMouseMovedTime < 200000)
|
||||||
|
fMouseMoveDist += moveDeltaDist;
|
||||||
|
else
|
||||||
|
fMouseMoveDist = moveDeltaDist;
|
||||||
|
if (fMouseMoveDist > 5)
|
||||||
|
_ShowFullscreenControls(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
fLastMousePos = mousePos;
|
||||||
|
fLastMouseMovedTime =eventTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1931,6 +2013,7 @@ MainWin::_ToggleFullscreen()
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// switch back from full screen mode
|
// switch back from full screen mode
|
||||||
|
_ShowFullscreenControls(false, false);
|
||||||
|
|
||||||
Hide();
|
Hide();
|
||||||
MoveTo(fSavedFrame.left, fSavedFrame.top);
|
MoveTo(fSavedFrame.left, fSavedFrame.top);
|
||||||
@@ -2000,6 +2083,54 @@ MainWin::_ShowIfNeeded()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MainWin::_ShowFullscreenControls(bool show, bool animate)
|
||||||
|
{
|
||||||
|
if (fShowsFullscreenControls == show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fShowsFullscreenControls = show;
|
||||||
|
|
||||||
|
if (show) {
|
||||||
|
fControls->RemoveSelf();
|
||||||
|
fControls->MoveTo(fVideoView->Bounds().left,
|
||||||
|
fVideoView->Bounds().bottom + 1);
|
||||||
|
fVideoView->AddChild(fControls);
|
||||||
|
while (fControls->IsHidden())
|
||||||
|
fControls->Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animate) {
|
||||||
|
// Slide the controls into view. We need to do this with
|
||||||
|
// messages, otherwise we block the video playback for the
|
||||||
|
// time of the animation.
|
||||||
|
const float kAnimationOffsets[] = { 0.05, 0.2, 0.5, 0.2, 0.05 };
|
||||||
|
const int32 steps = sizeof(kAnimationOffsets) / sizeof(float);
|
||||||
|
float moveDist = show ? -fControlsHeight : fControlsHeight;
|
||||||
|
float originalY = fControls->Frame().top;
|
||||||
|
for (int32 i = 0; i < steps; i++) {
|
||||||
|
BMessage message(M_SLIDE_CONTROLS);
|
||||||
|
message.AddFloat("offset",
|
||||||
|
floorf(moveDist * kAnimationOffsets[i]));
|
||||||
|
PostMessage(&message, this);
|
||||||
|
}
|
||||||
|
BMessage finalMessage(M_FINISH_SLIDING_CONTROLS);
|
||||||
|
finalMessage.AddFloat("offset", originalY + moveDist);
|
||||||
|
finalMessage.AddBool("show", show);
|
||||||
|
PostMessage(&finalMessage, this);
|
||||||
|
} else {
|
||||||
|
if (!show) {
|
||||||
|
fControls->RemoveSelf();
|
||||||
|
fControls->MoveTo(fVideoView->Frame().left,
|
||||||
|
fVideoView->Frame().bottom + 1);
|
||||||
|
fBackground->AddChild(fControls);
|
||||||
|
while (!fControls->IsHidden())
|
||||||
|
fControls->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ private:
|
|||||||
void _SetupVideoAspectItems(BMenu* menu);
|
void _SetupVideoAspectItems(BMenu* menu);
|
||||||
void _SetupTrackMenus(BMenu* audioTrackMenu,
|
void _SetupTrackMenus(BMenu* audioTrackMenu,
|
||||||
BMenu* videoTrackMenu);
|
BMenu* videoTrackMenu);
|
||||||
|
void _UpdateAudioChannelCount(int32 audioTrackIndex);
|
||||||
|
|
||||||
void _GetMinimumWindowSize(int& width,
|
void _GetMinimumWindowSize(int& width,
|
||||||
int& height) const;
|
int& height) const;
|
||||||
@@ -115,6 +116,8 @@ private:
|
|||||||
void _ToggleAlwaysOnTop();
|
void _ToggleAlwaysOnTop();
|
||||||
void _ToggleNoInterface();
|
void _ToggleNoInterface();
|
||||||
void _ShowIfNeeded();
|
void _ShowIfNeeded();
|
||||||
|
void _ShowFullscreenControls(bool show,
|
||||||
|
bool animate = true);
|
||||||
|
|
||||||
void _SetFileAttributes();
|
void _SetFileAttributes();
|
||||||
void _UpdateControlsEnabledStatus();
|
void _UpdateControlsEnabledStatus();
|
||||||
@@ -155,9 +158,12 @@ private:
|
|||||||
PlaylistObserver* fPlaylistObserver;
|
PlaylistObserver* fPlaylistObserver;
|
||||||
Controller* fController;
|
Controller* fController;
|
||||||
ControllerObserver* fControllerObserver;
|
ControllerObserver* fControllerObserver;
|
||||||
volatile bool fIsFullscreen;
|
|
||||||
volatile bool fAlwaysOnTop;
|
bool fIsFullscreen;
|
||||||
volatile bool fNoInterface;
|
bool fAlwaysOnTop;
|
||||||
|
bool fNoInterface;
|
||||||
|
bool fShowsFullscreenControls;
|
||||||
|
|
||||||
int fSourceWidth;
|
int fSourceWidth;
|
||||||
int fSourceHeight;
|
int fSourceHeight;
|
||||||
int fWidthAspect;
|
int fWidthAspect;
|
||||||
@@ -169,9 +175,13 @@ private:
|
|||||||
int fNoVideoWidth;
|
int fNoVideoWidth;
|
||||||
BRect fSavedFrame;
|
BRect fSavedFrame;
|
||||||
BRect fNoVideoFrame;
|
BRect fNoVideoFrame;
|
||||||
|
|
||||||
bool fMouseDownTracking;
|
bool fMouseDownTracking;
|
||||||
BPoint fMouseDownMousePos;
|
BPoint fMouseDownMousePos;
|
||||||
BPoint fMouseDownWindowPos;
|
BPoint fMouseDownWindowPos;
|
||||||
|
BPoint fLastMousePos;
|
||||||
|
bigtime_t fLastMouseMovedTime;
|
||||||
|
float fMouseMoveDist;
|
||||||
|
|
||||||
ListenerAdapter fGlobalSettingsListener;
|
ListenerAdapter fGlobalSettingsListener;
|
||||||
bool fCloseWhenDonePlayingMovie;
|
bool fCloseWhenDonePlayingMovie;
|
||||||
|
|||||||
@@ -100,17 +100,19 @@ VideoView::Pulse()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
bigtime_t now = system_time();
|
bigtime_t now = system_time();
|
||||||
if (now - fLastMouseMove > 2LL * 1000000) {
|
if (now - fLastMouseMove > 1500000) {
|
||||||
fLastMouseMove = now;
|
fLastMouseMove = now;
|
||||||
// take care of disabling the screen saver
|
// take care of disabling the screen saver
|
||||||
BPoint where;
|
BPoint where;
|
||||||
uint32 buttons;
|
uint32 buttons;
|
||||||
GetMouse(&where, &buttons, false);
|
GetMouse(&where, &buttons, false);
|
||||||
if (buttons == 0) {
|
if (buttons == 0) {
|
||||||
|
BMessage message(M_HIDE_FULL_SCREEN_CONTROLS);
|
||||||
|
message.AddPoint("where", where);
|
||||||
|
Window()->PostMessage(&message, Window());
|
||||||
|
|
||||||
ConvertToScreen(&where);
|
ConvertToScreen(&where);
|
||||||
set_mouse_position((int32)where.x, (int32)where.y);
|
set_mouse_position((int32)where.x, (int32)where.y);
|
||||||
// hide the mouse cursor until the user moves it
|
|
||||||
be_app->ObscureCursor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,11 @@
|
|||||||
#include "VideoTarget.h"
|
#include "VideoTarget.h"
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
M_HIDE_FULL_SCREEN_CONTROLS = 'hfsc'
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class VideoView : public BView, public VideoTarget {
|
class VideoView : public BView, public VideoTarget {
|
||||||
public:
|
public:
|
||||||
VideoView(BRect frame, const char* name,
|
VideoView(BRect frame, const char* name,
|
||||||
|
|||||||
Reference in New Issue
Block a user