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 \
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 \
/*****************************************************************************
- * 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 <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
*
* 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
* 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"
Playlist &rVar = VlcProc::instance( getIntf() )->getPlaylistVar();
rVar.onChange();
}
+
+
+void CmdSetStream::execute()
+{
+ // Change the stream variable
+ m_rStream.set( m_name, m_updateVLC );
+}
+
/*****************************************************************************
- * 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 <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
*
* 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
* 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
void CtrlList::onUpdate( Subject<VarList> &rList )
{
- makeImage();
- notifyLayout();
+ autoScroll();
m_pLastSelected = NULL;
}
}
+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 )
* 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 <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
/// 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();
};
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;
}
}
}
// 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 ),
#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"
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 );
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;
}
{
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
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;
}
class UString;
-/// Variable for VLC volume
+/// Variable for VLC stream name
class Stream: public VarText
{
public: