* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
- * Clément Stenac <zorglub@videolan.org>
+ * Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "input_manager.hpp"
#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.
*****************************************************************************/
/* 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 );
void InputManager::UpdateNowPlaying()
{
- char *psz_now_playing = vlc_input_item_GetInfo( p_input->input.p_item,
- _("Meta-information"), _(VLC_META_NOW_PLAYING) );
+ 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 );
}
p_main_intf->statusbar->SetStatusText( wxT(""), 0 );
p_main_intf->statusbar->SetStatusText( wxT(""), 2 );
+/* wxCocoa pretends to support this, but at least 2.6.x doesn't */
+#ifndef __APPLE__
#ifdef wxHAS_TASK_BAR_ICON
if( p_main_intf->p_systray )
{
p_main_intf->p_systray->UpdateTooltip(
wxString(wxT("VLC media player - ")) + wxU(_("Stopped")) );
}
+#endif
#endif
return;
p_main_intf->TogglePlayButton( val.i_int == STATUS_PAUSE ?
PAUSE_S : PLAYING_S );
+/* wxCocoa pretends to support this, but at least 2.6.x doesn't */
+#ifndef __APPLE__
#ifdef wxHAS_TASK_BAR_ICON
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
#endif
}
}
var_Get( p_input, "position", &pos );
var_Get( p_input, "length", &len );
- if( len.i_time > 0 && pos.f_float >= 0 &&
- !slider->IsShown() ) ShowSlider();
- else if( len.i_time < 0 && pos.f_float <= 0 &&
- slider->IsShown() ) HideSlider();
+ if( pos.f_float > 0 && !slider->IsShown() ) ShowSlider();
+ else if( pos.f_float <= 0 && slider->IsShown() ) HideSlider();
/* Update the slider if the user isn't dragging it. */
if( slider->IsShown() && b_slider_free )