Commit d36327cc authored by Cyril Deguet's avatar Cyril Deguet

* src/vlcproc.cpp: DO NOT update the GUI directly from the vlc callbacks,

  skins are not reentrant (at least with x11). Put commands in the queue
  instead.
  * commands/cmd_vars: commands to change variables
  * controls/ctrl_list.cpp: automatic scroll when the stream changes
  * src/bitmap.cpp: removed the scandinavian characters from the
    text font, they don't belong to ASCII (caused a stack corruption)
parent 99c11d8e
......@@ -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 \
......
/*****************************************************************************
* 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 Teulire <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
......@@ -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 );
}
/*****************************************************************************
* 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 Teulire <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
......@@ -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
......@@ -72,8 +72,7 @@ CtrlList::~CtrlList()
void CtrlList::onUpdate( Subject<VarList> &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 )
......
......@@ -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 <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -88,6 +88,9 @@ class CtrlList: public CtrlGeneric, public Observer<VarList>,
/// 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();
};
......
......@@ -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;
}
}
......
......@@ -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 ),
......
......@@ -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;
}
......@@ -29,7 +29,7 @@
class UString;
/// Variable for VLC volume
/// Variable for VLC stream name
class Stream: public VarText
{
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment