Commit 4e3c8943 authored by ipkiss's avatar ipkiss
Browse files

* skins2: Added friend classes where appropriate, to reduce the scope of

   some methods.
parent c0c09ac8
...@@ -104,7 +104,7 @@ Theme *Builder::build() ...@@ -104,7 +104,7 @@ Theme *Builder::build()
#define GET_BMP( pBmp, id ) \ #define GET_BMP( pBmp, id ) \
if( id != "none" ) \ if( id != "none" ) \
{ \ { \
pBmp = m_pTheme->m_bitmaps[id].get(); \ pBmp = m_pTheme->getBitmapById(id); \
if( pBmp == NULL ) \ if( pBmp == NULL ) \
{ \ { \
msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \ msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
...@@ -184,7 +184,7 @@ void Builder::addWindow( const BuilderData::Window &rData ) ...@@ -184,7 +184,7 @@ void Builder::addWindow( const BuilderData::Window &rData )
void Builder::addLayout( const BuilderData::Layout &rData ) void Builder::addLayout( const BuilderData::Layout &rData )
{ {
TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get(); TopWindow *pWin = m_pTheme->getWindowById(rData.m_windowId);
if( pWin == NULL ) if( pWin == NULL )
{ {
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() ); msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
...@@ -210,7 +210,7 @@ void Builder::addLayout( const BuilderData::Layout &rData ) ...@@ -210,7 +210,7 @@ void Builder::addLayout( const BuilderData::Layout &rData )
void Builder::addAnchor( const BuilderData::Anchor &rData ) void Builder::addAnchor( const BuilderData::Anchor &rData )
{ {
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -245,7 +245,7 @@ void Builder::addButton( const BuilderData::Button &rData ) ...@@ -245,7 +245,7 @@ void Builder::addButton( const BuilderData::Button &rData )
GenericBitmap *pBmpOver = pBmpUp; GenericBitmap *pBmpOver = pBmpUp;
GET_BMP( pBmpOver, rData.m_overId ); GET_BMP( pBmpOver, rData.m_overId );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -302,7 +302,7 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData ) ...@@ -302,7 +302,7 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
GenericBitmap *pBmpOver2 = pBmpUp2; GenericBitmap *pBmpOver2 = pBmpUp2;
GET_BMP( pBmpOver2, rData.m_over2Id ); GET_BMP( pBmpOver2, rData.m_over2Id );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -361,14 +361,14 @@ void Builder::addImage( const BuilderData::Image &rData ) ...@@ -361,14 +361,14 @@ void Builder::addImage( const BuilderData::Image &rData )
GenericBitmap *pBmp = NULL; GenericBitmap *pBmp = NULL;
GET_BMP( pBmp, rData.m_bmpId ); GET_BMP( pBmp, rData.m_bmpId );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
return; return;
} }
TopWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get(); TopWindow *pWindow = m_pTheme->getWindowById(rData.m_windowId);
if( pWindow == NULL ) if( pWindow == NULL )
{ {
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() ); msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
...@@ -414,7 +414,7 @@ void Builder::addImage( const BuilderData::Image &rData ) ...@@ -414,7 +414,7 @@ void Builder::addImage( const BuilderData::Image &rData )
void Builder::addText( const BuilderData::Text &rData ) void Builder::addText( const BuilderData::Text &rData )
{ {
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -459,7 +459,7 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData ) ...@@ -459,7 +459,7 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
GenericBitmap *pSeq = NULL; GenericBitmap *pSeq = NULL;
GET_BMP( pSeq, rData.m_sequence ); GET_BMP( pSeq, rData.m_sequence );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -511,7 +511,7 @@ void Builder::addSlider( const BuilderData::Slider &rData ) ...@@ -511,7 +511,7 @@ void Builder::addSlider( const BuilderData::Slider &rData )
GenericBitmap *pBmpOver = pBmpUp; GenericBitmap *pBmpOver = pBmpUp;
GET_BMP( pBmpOver, rData.m_overId ); GET_BMP( pBmpOver, rData.m_overId );
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -566,7 +566,7 @@ void Builder::addSlider( const BuilderData::Slider &rData ) ...@@ -566,7 +566,7 @@ void Builder::addSlider( const BuilderData::Slider &rData )
void Builder::addList( const BuilderData::List &rData ) void Builder::addList( const BuilderData::List &rData )
{ {
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -613,7 +613,7 @@ void Builder::addList( const BuilderData::List &rData ) ...@@ -613,7 +613,7 @@ void Builder::addList( const BuilderData::List &rData )
void Builder::addVideo( const BuilderData::Video &rData ) void Builder::addVideo( const BuilderData::Video &rData )
{ {
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get(); GenericLayout *pLayout = m_pTheme->getLayoutById(rData.m_layoutId);
if( pLayout == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
...@@ -711,7 +711,7 @@ const Position Builder::makePosition( const string &rLeftTop, ...@@ -711,7 +711,7 @@ const Position Builder::makePosition( const string &rLeftTop,
GenericFont *Builder::getFont( const string &fontId ) GenericFont *Builder::getFont( const string &fontId )
{ {
GenericFont *pFont = m_pTheme->m_fonts[fontId].get(); GenericFont *pFont = m_pTheme->getFontById(fontId);
if( !pFont && fontId == "defaultfont" ) if( !pFont && fontId == "defaultfont" )
{ {
#ifdef WIN32_SKINS #ifdef WIN32_SKINS
......
...@@ -37,11 +37,14 @@ class EvtMouse; ...@@ -37,11 +37,14 @@ class EvtMouse;
class EvtKey; class EvtKey;
class EvtRefresh; class EvtRefresh;
class EvtScroll; class EvtScroll;
class WindowManager;
/// Generic window class /// Generic window class
class GenericWindow: public SkinObject, public Observer<VarBool> class GenericWindow: public SkinObject, public Observer<VarBool>
{ {
private:
friend class WindowManager;
public: public:
GenericWindow( intf_thread_t *pIntf, int xPos, int yPos, GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
bool dragDrop, bool playOnDrop, bool dragDrop, bool playOnDrop,
...@@ -58,21 +61,37 @@ class GenericWindow: public SkinObject, public Observer<VarBool> ...@@ -58,21 +61,37 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
virtual void processEvent( EvtRefresh &rEvtRefresh ); virtual void processEvent( EvtRefresh &rEvtRefresh );
// Show the window /// Resize the window
virtual void resize( int width, int height );
/// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height ) {}
/// Get the coordinates of the window
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
virtual int getWidth() const { return m_width; }
virtual int getHeight() const { return m_height; }
/// Give access to the visibility variable
VarBool &getVisibleVar() { return m_varVisible; }
protected:
/// Get the OS window
OSWindow *getOSWindow() const { return m_pOsWindow; }
/// These methods do not need to be public since they are accessed
/// only by the window manager or by inheritant classes.
//@{
/// Show the window
virtual void show(); virtual void show();
// Hide the window /// Hide the window
virtual void hide(); virtual void hide();
// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height ) {}
/// Move the window /// Move the window
virtual void move( int left, int top ); virtual void move( int left, int top );
/// Resize the window
virtual void resize( int width, int height );
/// Bring the window on top /// Bring the window on top
virtual void raise() const; virtual void raise() const;
...@@ -81,26 +100,14 @@ class GenericWindow: public SkinObject, public Observer<VarBool> ...@@ -81,26 +100,14 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
/// Toggle the window on top /// Toggle the window on top
virtual void toggleOnTop( bool onTop ) const; virtual void toggleOnTop( bool onTop ) const;
//@}
/// Get the coordinates of the window
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
virtual int getWidth() const { return m_width; }
virtual int getHeight() const { return m_height; }
/// Give access to the visibility variable
VarBool &getVisibleVar() { return m_varVisible; }
protected:
/// Actually show the window /// Actually show the window
virtual void innerShow(); virtual void innerShow();
/// Actually hide the window /// Actually hide the window
virtual void innerHide(); virtual void innerHide();
/// Get the OS window
OSWindow *getOSWindow() const { return m_pOsWindow; }
private: private:
/// Window position and size /// Window position and size
int m_left, m_top, m_width, m_height; int m_left, m_top, m_width, m_height;
......
...@@ -53,20 +53,25 @@ void Theme::loadConfig() ...@@ -53,20 +53,25 @@ void Theme::loadConfig()
// Initialization // Initialization
map<string, TopWindowPtr>::const_iterator it; map<string, TopWindowPtr>::const_iterator it;
int i = 0; int i = 0;
int x, y, v, scan; int x, y, visible, scan;
// Get config for each window // Get config for each window
for( it = m_windows.begin(); it != m_windows.end(); it++ ) for( it = m_windows.begin(); it != m_windows.end(); it++ )
{ {
TopWindow *pWin = (*it).second.get(); TopWindow *pWin = (*it).second.get();
// Get config // Get config
scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v ); scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &visible );
// If config has the correct number of arguments // If config has the correct number of arguments
if( scan > 2 ) if( scan > 2 )
{ {
pWin->move( x, y ); m_windowManager.startMove( *pWin );
if( v ) pWin->show(); m_windowManager.move( *pWin, x, y );
m_windowManager.stopMove();
if( visible )
{
m_windowManager.show( *pWin );
}
} }
// Next window // Next window
......
...@@ -37,10 +37,15 @@ ...@@ -37,10 +37,15 @@
#include <list> #include <list>
#include <map> #include <map>
class Builder;
class Interpreter;
/// Class storing the data of the current theme /// Class storing the data of the current theme
class Theme: public SkinObject class Theme: public SkinObject
{ {
private:
friend class Builder;
friend class Interpreter;
public: public:
Theme( intf_thread_t *pIntf ): SkinObject( pIntf ), Theme( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_windowManager( getIntf() ) {} m_windowManager( getIntf() ) {}
...@@ -57,9 +62,7 @@ class Theme: public SkinObject ...@@ -57,9 +62,7 @@ class Theme: public SkinObject
WindowManager &getWindowManager() { return m_windowManager; } WindowManager &getWindowManager() { return m_windowManager; }
// XXX: It would be nicer to put everything private, and have the private:
// builder and interpreter classes as friends of this one
// private:
/// Store the bitmaps by ID /// Store the bitmaps by ID
map<string, GenericBitmapPtr> m_bitmaps; map<string, GenericBitmapPtr> m_bitmaps;
/// Store the fonts by ID /// Store the fonts by ID
...@@ -77,7 +80,6 @@ class Theme: public SkinObject ...@@ -77,7 +80,6 @@ class Theme: public SkinObject
/// Store the variables /// Store the variables
list<VariablePtr> m_vars; list<VariablePtr> m_vars;
private:
WindowManager m_windowManager; WindowManager m_windowManager;
}; };
......
...@@ -39,10 +39,12 @@ class WindowManager; ...@@ -39,10 +39,12 @@ class WindowManager;
/// Class to handle top-level windows /// Class to handle top-level windows
class TopWindow: public GenericWindow class TopWindow: public GenericWindow
{ {
private:
friend class WindowManager;
public: public:
TopWindow( intf_thread_t *pIntf, int xPos, int yPos, TopWindow( intf_thread_t *pIntf, int xPos, int yPos,
WindowManager &rWindowManager, WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop ); bool dragDrop, bool playOnDrop );
virtual ~TopWindow(); virtual ~TopWindow();
/// Methods to process OS events. /// Methods to process OS events.
...@@ -59,9 +61,6 @@ class TopWindow: public GenericWindow ...@@ -59,9 +61,6 @@ class TopWindow: public GenericWindow
// Refresh an area of the window // Refresh an area of the window
virtual void refresh( int left, int top, int width, int height ); virtual void refresh( int left, int top, int width, int height );
/// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout );
/// Get the active layout /// Get the active layout
virtual const GenericLayout& getActiveLayout() const; virtual const GenericLayout& getActiveLayout() const;
...@@ -82,6 +81,9 @@ class TopWindow: public GenericWindow ...@@ -82,6 +81,9 @@ class TopWindow: public GenericWindow
virtual void innerShow(); virtual void innerShow();
private: private:
/// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout );
/// Window manager /// Window manager
WindowManager &m_rWindowManager; WindowManager &m_rWindowManager;
/// Current active layout of the window /// Current active layout of the window
......
...@@ -37,6 +37,19 @@ class VoutWindow: public GenericWindow ...@@ -37,6 +37,19 @@ class VoutWindow: public GenericWindow
bool dragDrop, bool playOnDrop, GenericWindow &rParent ); bool dragDrop, bool playOnDrop, GenericWindow &rParent );
virtual ~VoutWindow(); virtual ~VoutWindow();
/// These methods are redefined here to make them public
//@{
/// Show the window
virtual void show() { GenericWindow::show(); }
/// Hide the window
virtual void hide() { GenericWindow::hide(); }
/// Move the window
virtual void move( int left, int top )
{ GenericWindow::move( left, top ); }
//@}
/// Resize the window /// Resize the window
virtual void resize( int width, int height ); virtual void resize( int width, int height );
......
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