#define STATUS_PLAYING 1
#define STATUS_PAUSE 2
+#ifdef WIN32
+
+#include <commctrl.h>
+
+/*
+** On win32, clicking on the slider channel causes the thumb to jump up or down a page size
+** like a scrollbar. This is not particularily useful for a movie track, where we'd rather
+** see the thumb to jump where the mouse is.
+** Therefore, we replace the slider (TRACKBAR control) window proc with our, which intercept
+** the mouse down event, and move the thumb accordingly
+*/
+static LRESULT CALLBACK MovieSliderWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch( uMsg )
+ {
+ case WM_LBUTTONDOWN:
+ {
+ POINT click = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+ RECT tRect = {0, 0, 0, 0};
+ SendMessage(hWnd, TBM_GETTHUMBRECT, 0, (LPARAM)&tRect);
+
+ /* check whether click is not in thumb */
+ if( ! PtInRect(&tRect, click) )
+ {
+ LONG min = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
+ LONG max = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
+ LONG thumb = tRect.right-tRect.left;
+ LONG newpos;
+
+ SendMessage(hWnd, TBM_GETCHANNELRECT, 0, (LPARAM)&tRect);
+
+ /* following is only valid for horizontal a trackbar */
+ newpos = ((click.x-tRect.left-(thumb/2))*(max-min)+((tRect.right-tRect.left-thumb)/2))
+ /(tRect.right-tRect.left-thumb);
+
+ /* set new postion */
+ SendMessage(hWnd, TBM_SETPOS, TRUE, min+newpos);
+ /* notify parent of change */
+ SendMessage(GetParent(hWnd), WM_HSCROLL, TB_ENDTRACK, (LPARAM)hWnd);
+
+ return 0;
+ }
+ }
+
+ default:
+ return CallWindowProc((WNDPROC)GetWindowLongPtr(hWnd, GWLP_USERDATA),
+ hWnd, uMsg, wParam, lParam);
+ }
+}
+
+#endif
+
/*****************************************************************************
* Constructor.
*****************************************************************************/
p_input = NULL;
i_old_playing_status = STATUS_STOP;
i_old_rate = INPUT_RATE_DEFAULT;
- b_slider_free = VLC_TRUE;
+ b_slider_free = true;
i_input_hide_delay = 0;
/* Create slider */
slider = new wxSlider( this, SliderScroll_Event, 0, 0, SLIDER_MAX_POS );
+#ifdef WIN32
+ /* modify behaviour of WIN32 underlying control
+ in order to implement proper movie slider */
+ {
+ HWND sliderHwnd = (HWND)slider->GetHWND();
+ /* put original WNDPROC into USERDATA, this may be incompatible with future version of
+ wxwidgets. */
+ SetWindowLongPtr(sliderHwnd, GWLP_USERDATA,
+ (LONG_PTR)GetWindowLongPtr(sliderHwnd, GWLP_WNDPROC));
+ /* put our own WNDPROC */
+ SetWindowLongPtr(sliderHwnd, GWLP_WNDPROC, (LONG_PTR)MovieSliderWindowProc);
+ }
+#endif
+
/* Create disc buttons */
disc_frame = new wxPanel( this );
/*****************************************************************************
* Public methods.
*****************************************************************************/
-vlc_bool_t InputManager::IsPlaying()
+bool InputManager::IsPlaying()
{
return (p_input && !p_input->b_die);
}
*****************************************************************************/
void InputManager::UpdateInput()
{
- playlist_t *p_playlist =
- (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
+ playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist != NULL )
{
LockPlaylist( p_intf->p_sys, p_playlist );
if( p_intf->p_sys->p_input )
vlc_object_yield( p_intf->p_sys->p_input );
UnlockPlaylist( p_intf->p_sys, p_playlist );
- vlc_object_release( p_playlist );
+ pl_Release( p_playlist );
}
}
void InputManager::UpdateNowPlaying()
{
- char *psz_now_playing = p_input->input.p_item->p_meta->psz_nowplaying ?
- strdup( p_input->input.p_item->p_meta->psz_nowplaying ):
- strdup( "" );
+ char *psz_now_playing = input_item_GetNowPlaying( input_GetItem(p_input) );
if( psz_now_playing && *psz_now_playing )
{
p_main_intf->statusbar->SetStatusText(
wxString(wxU(psz_now_playing)) + wxT( " - " ) +
- wxU(p_input->input.p_item->psz_name), 2 );
+ wxU(input_GetItem(p_input)->psz_name), 2 );
}
else
{
p_main_intf->statusbar->SetStatusText(
- wxU(p_input->input.p_item->psz_name), 2 );
+ wxU(input_GetItem(p_input)->psz_name), 2 );
}
free( psz_now_playing );
}
-void InputManager::UpdateButtons( vlc_bool_t b_play )
+void InputManager::UpdateButtons( bool b_play )
{
if( !b_play )
{
if( p_main_intf->p_systray )
{
p_main_intf->p_systray->UpdateTooltip(
- wxU(p_input->input.p_item->psz_name) + wxString(wxT(" - ")) +
+ wxU(input_GetItem(p_input)->psz_name) + wxString(wxT(" - ")) +
(val.i_int == PAUSE_S ? wxU(_("Paused")) : wxU(_("Playing"))));
}
#endif
}
else if( p_input->b_dead )
{
- UpdateButtons( VLC_FALSE );
+ UpdateButtons( false );
vlc_object_release( p_input );
p_input = NULL;
}
vlc_value_t pos, len;
UpdateTime();
- UpdateButtons( VLC_TRUE );
+ UpdateButtons( true );
UpdateNowPlaying();
UpdateDiscButtons();
if( p_input )
{
int i_type = var_Type( p_input, "prev-chapter" );
- vlc_value_t val; val.b_bool = VLC_TRUE;
+ vlc_value_t val; val.b_bool = true;
var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
"prev-chapter" : "prev-title", val );
if( p_input )
{
int i_type = var_Type( p_input, "next-chapter" );
- vlc_value_t val; val.b_bool = VLC_TRUE;
+ vlc_value_t val; val.b_bool = true;
var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
"next-chapter" : "next-title", val );
}
#ifdef WIN32
- b_slider_free = VLC_TRUE;
+ b_slider_free = true;
}
else
{
- b_slider_free = VLC_FALSE;
+ b_slider_free = false;
if( p_intf->p_sys->p_input ) UpdateTime();
}
#endif