Commit 1e34cf51 authored by Cyril Deguet's avatar Cyril Deguet
Browse files

* all: split GenericWindow into GenericWindow (general interface for

  windows) and TopWindow (implementation for top-level windows)
parent a5ca00dc
......@@ -112,6 +112,8 @@ SOURCES_skins2 = \
src/theme_loader.hpp \
src/tooltip.cpp \
src/tooltip.hpp \
src/top_window.cpp \
src/top_window.hpp \
src/var_manager.cpp \
src/var_manager.hpp \
src/vlcproc.cpp \
......
......@@ -2,7 +2,7 @@
* cmd_layout.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: cmd_layout.cpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -23,7 +23,7 @@
*****************************************************************************/
#include "cmd_layout.hpp"
#include "../src/generic_window.hpp"
#include "../src/top_window.hpp"
#include "../src/generic_layout.hpp"
#include "../src/theme.hpp"
......@@ -42,7 +42,7 @@ void CmdLayout::execute()
{
return;
}
GenericWindow *pWindow =
TopWindow *pWindow =
getIntf()->p_sys->p_theme->getWindowById( m_windowId );
GenericLayout *pLayout =
getIntf()->p_sys->p_theme->getLayoutById( m_layoutId );
......
......@@ -26,7 +26,7 @@
#define CMD_SHOW_WINDOW_HPP
#include "cmd_generic.hpp"
#include "../src/generic_window.hpp"
#include "../src/top_window.hpp"
#include "../src/window_manager.hpp"
......@@ -35,7 +35,7 @@ class CmdShowWindow: public CmdGeneric
{
public:
CmdShowWindow( intf_thread_t *pIntf, WindowManager &rWinManager,
GenericWindow &rWin ):
TopWindow &rWin ):
CmdGeneric( pIntf ), m_rWinManager( rWinManager ), m_rWin( rWin ) {}
virtual ~CmdShowWindow() {}
......@@ -49,7 +49,7 @@ class CmdShowWindow: public CmdGeneric
/// Reference to the window manager
WindowManager &m_rWinManager;
/// Reference to the window
GenericWindow &m_rWin;
TopWindow &m_rWin;
};
......@@ -58,7 +58,7 @@ class CmdHideWindow: public CmdGeneric
{
public:
CmdHideWindow( intf_thread_t *pIntf, WindowManager &rWinManager,
GenericWindow &rWin ):
TopWindow &rWin ):
CmdGeneric( pIntf ), m_rWinManager( rWinManager ), m_rWin( rWin ) {}
virtual ~CmdHideWindow() {}
......@@ -72,7 +72,7 @@ class CmdHideWindow: public CmdGeneric
/// Reference to the window manager
WindowManager &m_rWinManager;
/// Reference to the window
GenericWindow &m_rWin;
TopWindow &m_rWin;
};
......
......@@ -2,7 +2,7 @@
* ctrl_generic.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_generic.cpp,v 1.2 2004/02/29 16:49:55 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -24,7 +24,7 @@
#include "ctrl_generic.hpp"
#include "../src/generic_layout.hpp"
#include "../src/generic_window.hpp"
#include "../src/top_window.hpp"
#include "../src/os_graphics.hpp"
#include "../utils/position.hpp"
#include "../utils/var_bool.hpp"
......@@ -101,7 +101,7 @@ void CtrlGeneric::releaseMouse() const
void CtrlGeneric::notifyTooltipChange() const
{
GenericWindow *pWin = getWindow();
TopWindow *pWin = getWindow();
if( pWin )
{
// Notify the window
......@@ -110,7 +110,7 @@ void CtrlGeneric::notifyTooltipChange() const
}
GenericWindow *CtrlGeneric::getWindow() const
TopWindow *CtrlGeneric::getWindow() const
{
if( m_pLayout )
{
......
......@@ -2,7 +2,7 @@
* ctrl_generic.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_generic.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>
......@@ -35,7 +35,7 @@ class EvtGeneric;
class OSGraphics;
class GenericLayout;
class Position;
class GenericWindow;
class TopWindow;
class VarBool;
......@@ -96,7 +96,7 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
virtual void notifyTooltipChange() const;
/// Get the associated window, if any
virtual GenericWindow *getWindow() const;
virtual TopWindow *getWindow() const;
/// Overload this method if you want to do something special when
/// the Position object is set
......
......@@ -26,13 +26,13 @@
#include "../events/evt_generic.hpp"
#include "../events/evt_mouse.hpp"
#include "../events/evt_motion.hpp"
#include "../src/generic_window.hpp"
#include "../src/top_window.hpp"
#include "../src/window_manager.hpp"
#include "../utils/position.hpp"
CtrlMove::CtrlMove( intf_thread_t *pIntf, WindowManager &rWindowManager,
CtrlFlat &rCtrl, GenericWindow &rWindow,
CtrlFlat &rCtrl, TopWindow &rWindow,
const UString &rHelp, VarBool *pVisible ):
CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rWindowManager( rWindowManager ),
......
......@@ -2,7 +2,7 @@
* ctrl_move.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_move.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>
......@@ -29,7 +29,7 @@
#include "../utils/fsm.hpp"
#include "ctrl_flat.hpp"
class GenericWindow;
class TopWindow;
class WindowManager;
......@@ -38,7 +38,7 @@ class CtrlMove: public CtrlFlat
{
public:
CtrlMove( intf_thread_t *pIntf, WindowManager &rWindowManager,
CtrlFlat &rCtrl, GenericWindow &rWindow,
CtrlFlat &rCtrl, TopWindow &rWindow,
const UString &rHelp, VarBool *pVisible );
virtual ~CtrlMove() {}
......@@ -69,7 +69,7 @@ class CtrlMove: public CtrlFlat
/// Decorated CtrlFlat
CtrlFlat &m_rCtrl;
/// The window moved by this control
GenericWindow &m_rWindow;
TopWindow &m_rWindow;
/// The last received event
EvtGeneric *m_pEvt;
/// Position of the click that started the move
......
......@@ -2,7 +2,7 @@
* ctrl_slider.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: ctrl_slider.cpp,v 1.5 2004/03/02 21:45:15 ipkiss Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -27,7 +27,7 @@
#include "../events/evt_mouse.hpp"
#include "../events/evt_scroll.hpp"
#include "../src/generic_bitmap.hpp"
#include "../src/generic_window.hpp"
#include "../src/top_window.hpp"
#include "../src/os_factory.hpp"
#include "../src/os_graphics.hpp"
#include "../utils/position.hpp"
......@@ -342,7 +342,7 @@ void CtrlSliderBg::handleEvent( EvtGeneric &rEvent )
// Forward the clic to the cursor
EvtMouse evt( getIntf(), x, y, EvtMouse::kLeft, EvtMouse::kDown );
GenericWindow *pWin = getWindow();
TopWindow *pWin = getWindow();
if( pWin )
{
EvtEnter evtEnter( getIntf() );
......
......@@ -27,10 +27,9 @@
#include "../src/os_graphics.hpp"
CtrlVideo::CtrlVideo( intf_thread_t *pIntf, WindowManager &rWindowManager,
const UString &rHelp, VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_rWindowManager( rWindowManager ),
m_pVout( NULL )
CtrlVideo::CtrlVideo( intf_thread_t *pIntf, const UString &rHelp,
VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_pVout( NULL )
{
}
......@@ -80,8 +79,7 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
if (!m_pVout)
{
m_pVout = new VoutWindow( getIntf(), pPos->getLeft(),
pPos->getTop(), m_rWindowManager, false,
false, *pParent );
pPos->getTop(), false, false, *pParent );
m_pVout->resize( pPos->getWidth(), pPos->getHeight() );
m_pVout->show();
}
......
......@@ -27,14 +27,13 @@
#include "ctrl_generic.hpp"
class VoutWindow;
class WindowManager;
/// Control video
class CtrlVideo: public CtrlGeneric
{
public:
CtrlVideo( intf_thread_t *pIntf, WindowManager &rWindowManager,
const UString &rHelp, VarBool *pVisible );
CtrlVideo( intf_thread_t *pIntf, const UString &rHelp,
VarBool *pVisible );
virtual ~CtrlVideo();
/// Handle an event on the control
......@@ -50,8 +49,6 @@ class CtrlVideo: public CtrlGeneric
virtual void draw( OSGraphics &rImage, int xDest, int yDest );
private:
/// Window manager
WindowManager &m_rWindowManager;
/// Vout window
VoutWindow *m_pVout;
};
......
......@@ -29,8 +29,7 @@
#include "../src/png_bitmap.hpp"
#include "../src/os_factory.hpp"
#include "../src/generic_bitmap.hpp"
#include "../src/generic_window.hpp"
#include "../src/vout_window.hpp"
#include "../src/top_window.hpp"
#include "../src/anchor.hpp"
#include "../src/ft2_font.hpp"
#include "../src/theme.hpp"
......@@ -149,18 +148,18 @@ void Builder::addFont( const BuilderData::Font &rData )
void Builder::addWindow( const BuilderData::Window &rData )
{
GenericWindow *pWin =
new GenericWindow( getIntf(), rData.m_xPos, rData.m_yPos,
TopWindow *pWin =
new TopWindow( getIntf(), rData.m_xPos, rData.m_yPos,
m_pTheme->getWindowManager(),
rData.m_dragDrop, rData.m_playOnDrop );
m_pTheme->m_windows[rData.m_id] = GenericWindowPtr( pWin );
m_pTheme->m_windows[rData.m_id] = TopWindowPtr( pWin );
}
void Builder::addLayout( const BuilderData::Layout &rData )
{
GenericWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
if( pWin == NULL )
{
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
......@@ -186,7 +185,7 @@ void Builder::addLayout( const BuilderData::Layout &rData )
void Builder::addAnchor( const BuilderData::Anchor &rData )
{
GenericWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
if( pWin == NULL )
{
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
......@@ -335,7 +334,7 @@ void Builder::addImage( const BuilderData::Image &rData )
return;
}
GenericWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get();
TopWindow *pWindow = m_pTheme->m_windows[rData.m_windowId].get();
if( pWindow == NULL )
{
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() );
......@@ -570,9 +569,8 @@ void Builder::addVideo( const BuilderData::Video &rData )
return;
}
CtrlVideo *pVideo =
new CtrlVideo( getIntf(), m_pTheme->getWindowManager(),
UString( getIntf(), rData.m_help.c_str() ), NULL);
CtrlVideo *pVideo = new CtrlVideo( getIntf(),
UString( getIntf(), rData.m_help.c_str() ), NULL);
// Compute the position of the control
const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
......
......@@ -118,7 +118,7 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
{
int leftPos = rAction.find( ".show()" );
string windowId = rAction.substr( 0, leftPos );
GenericWindow *pWin = pTheme->getWindowById( windowId );
TopWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
pCommand = new CmdShowWindow( getIntf(), pTheme->getWindowManager(),
......@@ -133,7 +133,7 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
{
int leftPos = rAction.find( ".hide()" );
string windowId = rAction.substr( 0, leftPos );
GenericWindow *pWin = pTheme->getWindowById( windowId );
TopWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
pCommand = new CmdHideWindow( getIntf(), pTheme->getWindowManager(),
......@@ -210,7 +210,7 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
{
int leftPos = rName.find( ".isVisible" );
string windowId = rName.substr( 0, leftPos );
GenericWindow *pWin = pTheme->getWindowById( windowId );
TopWindow *pWin = pTheme->getWindowById( windowId );
if( pWin )
{
return &pWin->getVisibleVar();
......
......@@ -2,7 +2,7 @@
* generic_layout.cpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic_layout.cpp,v 1.2 2004/02/29 16:49:55 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -23,7 +23,7 @@
*****************************************************************************/
#include "generic_layout.hpp"
#include "generic_window.hpp"
#include "top_window.hpp"
#include "os_factory.hpp"
#include "os_graphics.hpp"
#include "../controls/ctrl_generic.hpp"
......@@ -52,7 +52,7 @@ GenericLayout::~GenericLayout()
}
void GenericLayout::setWindow( GenericWindow *pWindow )
void GenericLayout::setWindow( TopWindow *pWindow )
{
m_pWindow = pWindow;
}
......@@ -61,7 +61,7 @@ void GenericLayout::setWindow( GenericWindow *pWindow )
void GenericLayout::onControlCapture( const CtrlGeneric &rCtrl )
{
// Just forward the request to the window
GenericWindow *pWindow = getWindow();
TopWindow *pWindow = getWindow();
if( pWindow )
{
pWindow->onControlCapture( rCtrl );
......@@ -72,7 +72,7 @@ void GenericLayout::onControlCapture( const CtrlGeneric &rCtrl )
void GenericLayout::onControlRelease( const CtrlGeneric &rCtrl )
{
// Just forward the request to the window
GenericWindow *pWindow = getWindow();
TopWindow *pWindow = getWindow();
if( pWindow )
{
pWindow->onControlRelease( rCtrl );
......@@ -161,7 +161,7 @@ void GenericLayout::resize( int width, int height )
}
// Resize and refresh the associated window
GenericWindow *pWindow = getWindow();
TopWindow *pWindow = getWindow();
if( pWindow )
{
// Resize the window
......@@ -191,7 +191,7 @@ void GenericLayout::refreshAll()
}
// Refresh the associated window
GenericWindow *pWindow = getWindow();
TopWindow *pWindow = getWindow();
if( pWindow )
{
pWindow->refresh( 0, 0, m_width, m_height );
......
......@@ -2,7 +2,7 @@
* generic_layout.hpp
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: generic_layout.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -31,7 +31,7 @@
#include <list>
class GenericWindow;
class TopWindow;
class OSGraphics;
class CtrlGeneric;
......@@ -60,10 +60,10 @@ class GenericLayout: public SkinObject, public Box
virtual ~GenericLayout();
/// Attach the layout to a window
virtual void setWindow( GenericWindow *pWindow );
virtual void setWindow( TopWindow *pWindow );
/// Get the associated window, if any
virtual GenericWindow *getWindow() const { return m_pWindow; }
virtual TopWindow *getWindow() const { return m_pWindow; }
/// Called by a control which wants to capture the mouse
virtual void onControlCapture( const CtrlGeneric &rCtrl );
......@@ -104,7 +104,7 @@ class GenericLayout: public SkinObject, public Box
private:
/// Parent window of the layout
GenericWindow *m_pWindow;
TopWindow *m_pWindow;
/// Layout size
int m_width, m_height;
int m_minWidth, m_maxWidth;
......
......@@ -23,39 +23,15 @@
*****************************************************************************/
#include "generic_window.hpp"
#include "generic_layout.hpp"
#include "os_graphics.hpp"
#include "os_window.hpp"
#include "os_factory.hpp"
#include "theme.hpp"
#include "dialogs.hpp"
#include "var_manager.hpp"
#include "../commands/cmd_on_top.hpp"
#include "../controls/ctrl_generic.hpp"
#include "../events/evt_enter.hpp"
#include "../events/evt_focus.hpp"
#include "../events/evt_leave.hpp"
#include "../events/evt_motion.hpp"
#include "../events/evt_mouse.hpp"
#include "../events/evt_key.hpp"
#include "../events/evt_refresh.hpp"
#include "../events/evt_special.hpp"
#include "../events/evt_scroll.hpp"
#include "../utils/position.hpp"
#include "../utils/ustring.hpp"
#include <vlc_keys.h>
GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop,
GenericWindow *pParent ):
SkinObject( pIntf ), m_rWindowManager( rWindowManager ),
m_left( left ), m_top( top ), m_width( 0 ), m_height( 0 ),
m_isChild( true ), m_pActiveLayout( NULL ), m_pLastHitControl( NULL ),
m_pCapturingControl( NULL ), m_pFocusControl( NULL ), m_varVisible( pIntf ),
m_currModifier( 0 )
SkinObject( pIntf ), m_left( left ), m_top( top ), m_width( 0 ),
m_height( 0 ), m_varVisible( pIntf )
{
// Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
......@@ -71,14 +47,6 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
m_pOsWindow = pOsFactory->createOSWindow( *this, dragDrop, playOnDrop,
pOSParent );
// Child windows don't need that
if( !pParent )
{
m_isChild = false;
// Register as a moving window
m_rWindowManager.registerWindow( *this );
}
// Observe the visibility variable
m_varVisible.addObserver( this );
}
......@@ -86,11 +54,6 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
GenericWindow::~GenericWindow()
{
if( !m_isChild )
{
// Unregister from the window manager
m_rWindowManager.unregisterWindow( *this );
}
m_varVisible.delObserver( this );
if( m_pOsWindow )
......@@ -100,227 +63,6 @@ GenericWindow::~GenericWindow()
}
void GenericWindow::processEvent( EvtFocus &rEvtFocus )
{
// fprintf(stderr, rEvtFocus.getAsString().c_str()) ;
}
void GenericWindow::processEvent( EvtMotion &rEvtMotion )
{
// New control hit by the mouse
CtrlGeneric *pNewHitControl =
findHitControl( rEvtMotion.getXPos() - m_left,
rEvtMotion.getYPos() - m_top );
setLastHit( pNewHitControl );
/// Update the help text
VarManager *pVarManager = VarManager::instance( getIntf() );
if( pNewHitControl )
{
pVarManager->getHelpText().set( pNewHitControl->getHelpText() );
}
// Send a motion event to the hit control, or to the control
// that captured the mouse, if any
CtrlGeneric *pActiveControl = pNewHitControl;
if( m_pCapturingControl )
{
pActiveControl = m_pCapturingControl;
}
if( pActiveControl )
{
// Compute the coordinates relative to the window
int xPos = rEvtMotion.getXPos() - m_left;
int yPos = rEvtMotion.getYPos() - m_top;
// Send a motion event
EvtMotion evt( getIntf(), xPos, yPos );
pActiveControl->handleEvent( evt );
}
}
void GenericWindow::processEvent( EvtLeave &rEvtLeave )
{
// No more hit control
setLastHit( NULL );
if( !m_pCapturingControl )
{
m_rWindowManager.hideTooltip();
}
}
void GenericWindow::processEvent( EvtMouse &rEvtMouse )
{
// Get the control hit by the mouse
CtrlGeneric *pNewHitControl = findHitControl( rEvtMouse.getXPos(),
rEvtMouse.getYPos() );
setLastHit( pNewHitControl );
// Change the focused control
if( rEvtMouse.getAction() == EvtMouse::kDown )
{
// Raise all the windows
m_rWindowManager.raiseAll( *this );
if( pNewHitControl && pNewHitControl->isFocusable() )
{
// If a new control gains the focus, the previous one loses it
if( m_pFocusControl && m_pFocusControl != pNewHitControl )
{
EvtFocus evt( getIntf(), false );
m_pFocusControl->handleEvent( evt );
}
if( pNewHitControl != m_pFocusControl )
{
m_pFocusControl = pNewHitControl;
EvtFocus evt( getIntf(), false );