diff --git a/modules/gui/skins2/Modules.am b/modules/gui/skins2/Modules.am index d09f95734f..be8bc23672 100644 --- a/modules/gui/skins2/Modules.am +++ b/modules/gui/skins2/Modules.am @@ -14,8 +14,6 @@ SOURCES_skins2 = \ commands/cmd_input.hpp \ commands/cmd_layout.cpp \ commands/cmd_layout.hpp \ - commands/cmd_notify_playlist.cpp \ - commands/cmd_notify_playlist.hpp \ commands/cmd_on_top.cpp \ commands/cmd_on_top.hpp \ commands/cmd_playlist.cpp \ @@ -25,6 +23,8 @@ SOURCES_skins2 = \ commands/cmd_resize.cpp \ commands/cmd_resize.hpp \ commands/cmd_show_window.hpp \ + commands/cmd_vars.cpp \ + commands/cmd_vars.hpp \ \ controls/ctrl_button.cpp \ controls/ctrl_button.hpp \ diff --git a/modules/gui/skins2/commands/cmd_notify_playlist.cpp b/modules/gui/skins2/commands/cmd_vars.cpp similarity index 84% rename from modules/gui/skins2/commands/cmd_notify_playlist.cpp rename to modules/gui/skins2/commands/cmd_vars.cpp index 92c1b1762e..3aa169a52e 100644 --- a/modules/gui/skins2/commands/cmd_notify_playlist.cpp +++ b/modules/gui/skins2/commands/cmd_vars.cpp @@ -1,11 +1,10 @@ /***************************************************************************** - * cmd_notify_playlist.cpp + * cmd_vars.cpp ***************************************************************************** - * Copyright (C) 2003 VideoLAN - * $Id: cmd_notify_playlist.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $ + * Copyright (C) 2004 VideoLAN + * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière * * 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 @@ -22,8 +21,9 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ -#include "cmd_notify_playlist.hpp" +#include "cmd_vars.hpp" #include "../src/vlcproc.hpp" +#include "../vars/stream.hpp" #include "../vars/playlist.hpp" @@ -33,3 +33,11 @@ void CmdNotifyPlaylist::execute() Playlist &rVar = VlcProc::instance( getIntf() )->getPlaylistVar(); rVar.onChange(); } + + +void CmdSetStream::execute() +{ + // Change the stream variable + m_rStream.set( m_name, m_updateVLC ); +} + diff --git a/modules/gui/skins2/commands/cmd_notify_playlist.hpp b/modules/gui/skins2/commands/cmd_vars.hpp similarity index 56% rename from modules/gui/skins2/commands/cmd_notify_playlist.hpp rename to modules/gui/skins2/commands/cmd_vars.hpp index 074af4937d..0d2708c905 100644 --- a/modules/gui/skins2/commands/cmd_notify_playlist.hpp +++ b/modules/gui/skins2/commands/cmd_vars.hpp @@ -1,11 +1,10 @@ /***************************************************************************** - * cmd_notify_playlist.hpp + * cmd_vars.hpp ***************************************************************************** - * Copyright (C) 2003 VideoLAN - * $Id: cmd_notify_playlist.hpp,v 1.2 2004/01/05 22:17:32 asmax Exp $ + * Copyright (C) 2004 VideoLAN + * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière * * 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 @@ -22,13 +21,41 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************/ -#ifndef CMD_NOTIFY_PLAYLIST_HPP -#define CMD_NOTIFY_PLAYLIST_HPP +#ifndef CMD_VARS_HPP +#define CMD_VARS_HPP #include "cmd_generic.hpp" +#include "../utils/ustring.hpp" +class Stream; /// Command to notify the playlist of a change DEFINE_COMMAND( NotifyPlaylist, "notify playlist" ) + +/// Command to set a stream variable +class CmdSetStream: public CmdGeneric +{ + public: + CmdSetStream( intf_thread_t *pIntf, Stream &rStream, + const UString &rName, bool updateVLC ): + CmdGeneric( pIntf ), m_rStream( rStream ), m_name( rName ), + m_updateVLC( updateVLC ) {} + virtual ~CmdSetStream() {} + + /// This method does the real job of the command + virtual void execute(); + + /// Return the type of the command + virtual string getType() const { return "set stream"; } + + private: + /// Stream variable to set + Stream &m_rStream; + /// Value to set + const UString m_name; + bool m_updateVLC; +}; + + #endif diff --git a/modules/gui/skins2/controls/ctrl_list.cpp b/modules/gui/skins2/controls/ctrl_list.cpp index 722c77ae74..c6d7d50867 100644 --- a/modules/gui/skins2/controls/ctrl_list.cpp +++ b/modules/gui/skins2/controls/ctrl_list.cpp @@ -72,8 +72,7 @@ CtrlList::~CtrlList() void CtrlList::onUpdate( Subject &rList ) { - makeImage(); - notifyLayout(); + autoScroll(); m_pLastSelected = NULL; } @@ -324,6 +323,47 @@ void CtrlList::draw( OSGraphics &rImage, int xDest, int yDest ) } +void CtrlList::autoScroll() +{ + // Get the size of the control + const Position *pPos = getPosition(); + if( !pPos ) + { + return; + } + int height = pPos->getHeight(); + + // How many lines can be displayed ? + int itemHeight = m_rFont.getSize() + LINE_INTERVAL; + int maxItems = height / itemHeight; + + // Find the current playing stream + int playIndex = 0; + VarList::ConstIterator it; + for( it = m_rList.begin(); it != m_rList.end(); it++ ) + { + if( (*it).m_playing ) + { + break; + } + playIndex++; + } + if( it != m_rList.end() && + ( playIndex < m_lastPos || playIndex >= m_lastPos + maxItems ) ) + { + // Scroll the list to have the playing stream visible + VarPercent &rVarPos = m_rList.getPositionVar(); + rVarPos.set( 1.0 - (float)playIndex / (float)m_rList.size() ); + // The image will be changed by onUpdate(VarPercent&) + } + else + { + makeImage(); + notifyLayout(); + } +} + + void CtrlList::makeImage() { if( m_pImage ) diff --git a/modules/gui/skins2/controls/ctrl_list.hpp b/modules/gui/skins2/controls/ctrl_list.hpp index ae84d7049c..8d552d0741 100644 --- a/modules/gui/skins2/controls/ctrl_list.hpp +++ b/modules/gui/skins2/controls/ctrl_list.hpp @@ -2,7 +2,7 @@ * ctrl_list.hpp ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: ctrl_list.hpp,v 1.2 2004/02/29 16:49:55 asmax Exp $ + * $Id$ * * Authors: Cyril Deguet * Olivier Teulière @@ -88,6 +88,9 @@ class CtrlList: public CtrlGeneric, public Observer, /// Called when the position is set virtual void onPositionChange(); + /// Check if the list must be scrolled + void autoScroll(); + /// Draw the image of the control void makeImage(); }; diff --git a/modules/gui/skins2/src/bitmap_font.cpp b/modules/gui/skins2/src/bitmap_font.cpp index 66a2fec916..55d3a19a9c 100644 --- a/modules/gui/skins2/src/bitmap_font.cpp +++ b/modules/gui/skins2/src/bitmap_font.cpp @@ -69,17 +69,9 @@ BitmapFont::BitmapFont( intf_thread_t *pIntf, const GenericBitmap &rBitmap, m_table[(size_t)specialChars[i]].m_xPos = (11 + i) * m_width; m_table[(size_t)specialChars[i]].m_yPos = m_height; } - m_table[(size_t)'Å'].m_xPos = m_table[(size_t)'å'].m_xPos = 0; - m_table[(size_t)'Ö'].m_xPos = m_table[(size_t)'ö'].m_xPos = m_width; - m_table[(size_t)'Ä'].m_xPos = m_table[(size_t)'ä'].m_xPos = 3 * m_width; m_table[(size_t)'?'].m_xPos = 4 * m_width; m_table[(size_t)'*'].m_xPos = 5 * m_width; - static const char thirdLine[] = {'Å', 'å', 'Ö', 'ö', 'Ä', 'ä', '?', - '*'}; - for( int i = 0; i < 8; i++ ) - { - m_table[(size_t)thirdLine[i]].m_yPos = 2 * m_height; - } + m_table[(size_t)'?'].m_yPos = m_table[(size_t)'*'].m_yPos = 2 * m_height; } } diff --git a/modules/gui/skins2/src/ft2_font.cpp b/modules/gui/skins2/src/ft2_font.cpp index 020ea793f5..fa3eae2871 100644 --- a/modules/gui/skins2/src/ft2_font.cpp +++ b/modules/gui/skins2/src/ft2_font.cpp @@ -238,8 +238,8 @@ GenericBitmap *FT2Font::drawString( const UString &rString, uint32_t color, } // Adjust the size for vertical padding - yMax == __MAX( yMax, m_ascender ); - yMin == __MIN( yMin, m_descender ); + yMax = __MAX( yMax, m_ascender ); + yMin = __MIN( yMin, m_descender ); // Create the bitmap FT2Bitmap *pBmp = new FT2Bitmap( getIntf(), __MIN( width1, width2 ), diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp index 52da3f38d6..f038de29c5 100755 --- a/modules/gui/skins2/src/vlcproc.cpp +++ b/modules/gui/skins2/src/vlcproc.cpp @@ -29,8 +29,8 @@ #include "os_timer.hpp" #include "var_manager.hpp" #include "../commands/async_queue.hpp" -#include "../commands/cmd_notify_playlist.hpp" #include "../commands/cmd_quit.hpp" +#include "../commands/cmd_vars.hpp" #include "../utils/var_bool.hpp" @@ -82,6 +82,11 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ) REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" ) #undef REGISTER_VAR + // XXX WARNING XXX + // The object variable callbacks are called from other VLC threads, + // so they must put commands in the queue and NOT do anything else + // (X11 calls are not reentrant) + // Called when the playlist changes var_AddCallback( pIntf->p_sys->p_playlist, "intf-change", onIntfChange, this ); @@ -226,8 +231,7 @@ int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable, AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() ); pQueue->remove( "notify playlist" ); pQueue->push( CmdGenericPtr( pCmd ) ); -/* - p_playlist_dialog->UpdateItem( new_val.i_int );*/ + return VLC_SUCCESS; } @@ -238,16 +242,22 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable, { VlcProc *pThis = ( VlcProc* )pParam; - // Update the stream variable - // XXX: we should not need to access p_inpu->psz_source directly, a - // getter should be provided by VLC core + AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() ); + playlist_t *p_playlist = (playlist_t*)pObj; if( p_playlist->p_input ) { + // Create a command to update the stream variable + // XXX: we should not need to access p_inpu->psz_source directly, a + // getter should be provided by VLC core Stream *pStream = (Stream*)pThis->m_cVarStream.get(); UString srcName( pThis->getIntf(), p_playlist->p_input->psz_source ); - pStream->set( srcName, false ); + CmdSetStream *pCmd = new CmdSetStream( pThis->getIntf(), *pStream, + srcName, false ); + // Push the command in the asynchronous command queue + pQueue->remove( "set stream" ); + pQueue->push( CmdGenericPtr( pCmd ) ); } // Create a playlist notify command @@ -255,12 +265,9 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable, CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() ); // Push the command in the asynchronous command queue - AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() ); pQueue->remove( "notify playlist" ); pQueue->push( CmdGenericPtr( pCmd ) ); -// p_playlist_dialog->UpdateItem( old_val.i_int ); -// p_playlist_dialog->UpdateItem( new_val.i_int ); return VLC_SUCCESS; } diff --git a/modules/gui/skins2/vars/stream.hpp b/modules/gui/skins2/vars/stream.hpp index 92371d21f9..4c65407265 100644 --- a/modules/gui/skins2/vars/stream.hpp +++ b/modules/gui/skins2/vars/stream.hpp @@ -29,7 +29,7 @@ class UString; -/// Variable for VLC volume +/// Variable for VLC stream name class Stream: public VarText { public: