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 \
* 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 Teulière <ipkiss@via.ecp.fr>
*****************************************************************************/
#include "cmd_layout.hpp"
-#include "../src/generic_window.hpp"
+#include "../src/top_window.hpp"
#include "../src/generic_layout.hpp"
#include "../src/theme.hpp"
{
return;
}
- GenericWindow *pWindow =
+ TopWindow *pWindow =
getIntf()->p_sys->p_theme->getWindowById( m_windowId );
GenericLayout *pLayout =
getIntf()->p_sys->p_theme->getLayoutById( m_layoutId );
#define CMD_SHOW_WINDOW_HPP
#include "cmd_generic.hpp"
-#include "../src/generic_window.hpp"
+#include "../src/top_window.hpp"
#include "../src/window_manager.hpp"
{
public:
CmdShowWindow( intf_thread_t *pIntf, WindowManager &rWinManager,
- GenericWindow &rWin ):
+ TopWindow &rWin ):
CmdGeneric( pIntf ), m_rWinManager( rWinManager ), m_rWin( rWin ) {}
virtual ~CmdShowWindow() {}
/// Reference to the window manager
WindowManager &m_rWinManager;
/// Reference to the window
- GenericWindow &m_rWin;
+ TopWindow &m_rWin;
};
{
public:
CmdHideWindow( intf_thread_t *pIntf, WindowManager &rWinManager,
- GenericWindow &rWin ):
+ TopWindow &rWin ):
CmdGeneric( pIntf ), m_rWinManager( rWinManager ), m_rWin( rWin ) {}
virtual ~CmdHideWindow() {}
/// Reference to the window manager
WindowManager &m_rWinManager;
/// Reference to the window
- GenericWindow &m_rWin;
+ TopWindow &m_rWin;
};
* 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 Teulière <ipkiss@via.ecp.fr>
#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"
void CtrlGeneric::notifyTooltipChange() const
{
- GenericWindow *pWin = getWindow();
+ TopWindow *pWin = getWindow();
if( pWin )
{
// Notify the window
}
-GenericWindow *CtrlGeneric::getWindow() const
+TopWindow *CtrlGeneric::getWindow() const
{
if( m_pLayout )
{
* 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>
class OSGraphics;
class GenericLayout;
class Position;
-class GenericWindow;
+class TopWindow;
class 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
#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 ),
* 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>
#include "../utils/fsm.hpp"
#include "ctrl_flat.hpp"
-class GenericWindow;
+class TopWindow;
class WindowManager;
{
public:
CtrlMove( intf_thread_t *pIntf, WindowManager &rWindowManager,
- CtrlFlat &rCtrl, GenericWindow &rWindow,
+ CtrlFlat &rCtrl, TopWindow &rWindow,
const UString &rHelp, VarBool *pVisible );
virtual ~CtrlMove() {}
/// 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
* 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 Teulière <ipkiss@via.ecp.fr>
#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"
// 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() );
#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 )
{
}
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();
}
#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
virtual void draw( OSGraphics &rImage, int xDest, int yDest );
private:
- /// Window manager
- WindowManager &m_rWindowManager;
/// Vout window
VoutWindow *m_pVout;
};
#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"
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() );
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() );
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() );
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,
{
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(),
{
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(),
{
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();
* 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 Teulière <ipkiss@via.ecp.fr>
*****************************************************************************/
#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"
}
-void GenericLayout::setWindow( GenericWindow *pWindow )
+void GenericLayout::setWindow( TopWindow *pWindow )
{
m_pWindow = 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 );
void GenericLayout::onControlRelease( const CtrlGeneric &rCtrl )
{
// Just forward the request to the window
- GenericWindow *pWindow = getWindow();
+ TopWindow *pWindow = getWindow();
if( pWindow )
{
pWindow->onControlRelease( rCtrl );
}
// Resize and refresh the associated window
- GenericWindow *pWindow = getWindow();
+ TopWindow *pWindow = getWindow();
if( pWindow )
{
// Resize the window
}
// Refresh the associated window
- GenericWindow *pWindow = getWindow();
+ TopWindow *pWindow = getWindow();
if( pWindow )
{
pWindow->refresh( 0, 0, m_width, m_height );
* 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 Teulière <ipkiss@via.ecp.fr>
#include <list>
-class GenericWindow;
+class TopWindow;
class OSGraphics;
class CtrlGeneric;
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 );
private:
/// Parent window of the layout
- GenericWindow *m_pWindow;
+ TopWindow *m_pWindow;
/// Layout size
int m_width, m_height;
int m_minWidth, m_maxWidth;
*****************************************************************************/
#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() );
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 );
}
GenericWindow::~GenericWindow()
{
- if( !m_isChild )
- {
- // Unregister from the window manager
- m_rWindowManager.unregisterWindow( *this );
- }
m_varVisible.delObserver( this );
if( m_pOsWindow )
}
-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 );
- pNewHitControl->handleEvent( evt );
- }
- }
- else if( m_pFocusControl )
- {
- // The previous control loses the focus
- EvtFocus evt( getIntf(), false );
- m_pFocusControl->handleEvent( evt );
- m_pFocusControl = NULL;
- }
- }
-
- // Send a mouse 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 )
- {
- pActiveControl->handleEvent( rEvtMouse );
- }
-}
-
-
-void GenericWindow::processEvent( EvtKey &rEvtKey )
-{
- // Forward the event to the focused control, if any
- if( m_pFocusControl )
- {
- m_pFocusControl->handleEvent( rEvtKey );
- return;
- }
-
- // Only do the action when the key is down
- if( rEvtKey.getAsString().find( "key:down") != string::npos )
- {
- //XXX not to be hardcoded !
- // Ctrl-S = Change skin
- if( (rEvtKey.getMod() & EvtInput::kModCtrl) &&
- rEvtKey.getKey() == 's' )
- {
- Dialogs *pDialogs = Dialogs::instance( getIntf() );
- if( pDialogs != NULL )
- {
- pDialogs->showChangeSkin();
- }
- return;
- }
-
- //XXX not to be hardcoded !
- // Ctrl-T = Toggle on top
- if( (rEvtKey.getMod() & EvtInput::kModCtrl) &&
- rEvtKey.getKey() == 't' )
- {
- CmdOnTop cmd( getIntf() );
- cmd.execute();
- return;
- }
-
- vlc_value_t val;
- // Set the key
- val.i_int = rEvtKey.getKey();
- // Set the modifiers
- if( rEvtKey.getMod() & EvtInput::kModAlt )
- {
- val.i_int |= KEY_MODIFIER_ALT;
- }
- if( rEvtKey.getMod() & EvtInput::kModCtrl )
- {
- val.i_int |= KEY_MODIFIER_CTRL;
- }
- if( rEvtKey.getMod() & EvtInput::kModShift )
- {
- val.i_int |= KEY_MODIFIER_SHIFT;
- }
-
- var_Set( getIntf()->p_vlc, "key-pressed", val );
- }
-
- // Always store the modifier, which can be needed for scroll events
- m_currModifier = rEvtKey.getMod();
-}
-
-
-void GenericWindow::processEvent( EvtRefresh &rEvtRefresh )
-{
- // Refresh the given area
- refresh( rEvtRefresh.getXStart(), rEvtRefresh.getYStart(),
- rEvtRefresh.getWidth(), rEvtRefresh.getHeight() );
-}
-
-
-void GenericWindow::processEvent( EvtScroll &rEvtScroll )
-{
- // Raise the windows
- raise();
-
- // Get the control hit by the mouse
- CtrlGeneric *pNewHitControl = findHitControl( rEvtScroll.getXPos(),
- rEvtScroll.getYPos());
- setLastHit( pNewHitControl );
-
- // Send a mouse 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 )
- {
- pActiveControl->handleEvent( rEvtScroll );
- }
- else
- {
- // Treat the scroll event as a hotkey
- vlc_value_t val;
- if( rEvtScroll.getDirection() == EvtScroll::kUp )
- {
- val.i_int = KEY_MOUSEWHEELUP;
- }
- else
- {
- val.i_int = KEY_MOUSEWHEELDOWN;
- }
- // Add the modifiers
- val.i_int |= m_currModifier;
-
- var_Set( getIntf()->p_vlc, "key-pressed", val );
- }
-}
-
-
-void GenericWindow::forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl )
-{
- // XXX: We should do some checks here
- rCtrl.handleEvent( rEvt );
-}
-
-
void GenericWindow::show()
{
m_varVisible.set( true );
}
-void GenericWindow::refresh( int left, int top, int width, int height )
-{
- if( m_pActiveLayout )
- {
- m_pActiveLayout->getImage()->copyToWindow( *m_pOsWindow, left, top,
- width, height, left, top );
- }
-}
-
-
void GenericWindow::move( int left, int top )
{
// Update the window coordinates
}
-void GenericWindow::setActiveLayout( GenericLayout *pLayout )
-{
- pLayout->setWindow( this );
- m_pActiveLayout = pLayout;
- // Get the size of the layout and resize the window
- m_width = pLayout->getWidth();
- m_height = pLayout->getHeight();
- m_pOsWindow->moveResize( m_left, m_top, m_width, m_height );
- updateShape();
- pLayout->refreshAll();
-}
-
-
-void GenericWindow::updateShape()
-{
- // Set the shape of the window
- if( m_pActiveLayout )
- {
- OSGraphics *pImage = m_pActiveLayout->getImage();
- if( pImage )
- {
- pImage->applyMaskToWindow( *m_pOsWindow );
- }
- }
-}
-
-
-const list<Anchor*> GenericWindow::getAnchorList() const
-{
- return m_anchorList;
-}
-
-
-void GenericWindow::addAnchor( Anchor *pAnchor )
-{
- m_anchorList.push_back( pAnchor );
-}
-
-
-void GenericWindow::onControlCapture( const CtrlGeneric &rCtrl )
-{
- // Set the capturing control
- m_pCapturingControl = (CtrlGeneric*) &rCtrl;
-}
-
-
-void GenericWindow::onControlRelease( const CtrlGeneric &rCtrl )
-{
- // Release the capturing control
- if( m_pCapturingControl == &rCtrl )
- {
- m_pCapturingControl = NULL;
- }
- else
- {
- msg_Dbg( getIntf(), "Control had not captured the mouse" );
- }
-
- // Send an enter event to the control under the mouse, if it doesn't
- // have received it yet
- if( m_pLastHitControl && m_pLastHitControl != &rCtrl )
- {
- EvtEnter evt( getIntf() );
- m_pLastHitControl->handleEvent( evt );
-
- // Show the tooltip
- m_rWindowManager.hideTooltip();
- UString tipText = m_pLastHitControl->getTooltipText();
- if( tipText.length() > 0 )
- {
- // Set the tooltip text variable
- VarManager *pVarManager = VarManager::instance( getIntf() );
- pVarManager->getTooltipText().set( tipText );
- m_rWindowManager.showTooltip();
- }
- }
-}
-
-
-void GenericWindow::onTooltipChange( const CtrlGeneric &rCtrl )
-{
- // Check that the control is the active one
- if( m_pLastHitControl && m_pLastHitControl == &rCtrl )
- {
- // Set the tooltip text variable
- VarManager *pVarManager = VarManager::instance( getIntf() );
- pVarManager->getTooltipText().set( rCtrl.getTooltipText() );
- }
-}
-
-
void GenericWindow::onUpdate( Subject<VarBool> &rVariable )
{
if( m_varVisible.get() )
void GenericWindow::innerShow()
{
- // First, refresh the layout and update the shape of the window
- if( m_pActiveLayout )
- {
- updateShape();
- m_pActiveLayout->refreshAll();
- }
-
if( m_pOsWindow )
{
m_pOsWindow->show( m_left, m_top );
}
}
-
-CtrlGeneric *GenericWindow::findHitControl( int xPos, int yPos )
-{
- if( m_pActiveLayout == NULL )
- {
- return NULL;
- }
-
- // Get the controls in the active layout
- const list<LayeredControl> &ctrlList = m_pActiveLayout->getControlList();
- list<LayeredControl>::const_reverse_iterator iter;
-
- // New control hit by the mouse
- CtrlGeneric *pNewHitControl = NULL;
-
- // Loop on the control list to find the uppest hit control
- for( iter = ctrlList.rbegin(); iter != ctrlList.rend(); iter++ )
- {
- // Get the position of the control in the layout
- const Position *pos = (*iter).m_pControl->getPosition();
- if( pos != NULL )
- {
- // Compute the coordinates of the mouse relative to the control
- int xRel = xPos - pos->getLeft();
- int yRel = yPos - pos->getTop();
-
- CtrlGeneric *pCtrl = (*iter).m_pControl;
- // Control hit ?
- if( pCtrl->isVisible() && pCtrl->mouseOver( xRel, yRel ) )
- {
- pNewHitControl = (*iter).m_pControl;
- break;
- }
- }
- else
- {
- msg_Dbg( getIntf(), "Control at NULL position" );
- }
- }
-
- // If the hit control has just been entered, send it an enter event
- if( pNewHitControl && (pNewHitControl != m_pLastHitControl) )
- {
- // Don't send the event if another control captured the mouse
- if( !m_pCapturingControl || (m_pCapturingControl == pNewHitControl ) )
- {
- EvtEnter evt( getIntf() );
- pNewHitControl->handleEvent( evt );
-
- if( !m_pCapturingControl )
- {
- // Show the tooltip
- m_rWindowManager.hideTooltip();
- UString tipText = pNewHitControl->getTooltipText();
- if( tipText.length() > 0 )
- {
- // Set the tooltip text variable
- VarManager *pVarManager = VarManager::instance( getIntf() );
- pVarManager->getTooltipText().set( tipText );
- m_rWindowManager.showTooltip();
- }
- }
- }
- }
-
- return pNewHitControl;
-}
-
-
-
-void GenericWindow::setLastHit( CtrlGeneric *pNewHitControl )
-{
- // Send a leave event to the left control
- if( m_pLastHitControl && (pNewHitControl != m_pLastHitControl) )
- {
- // Don't send the event if another control captured the mouse
- if( !m_pCapturingControl || (m_pCapturingControl == m_pLastHitControl))
- {
- EvtLeave evt( getIntf() );
- m_pLastHitControl->handleEvent( evt );
- }
- }
-
- m_pLastHitControl = pNewHitControl;
-}
-
#define GENERIC_WINDOW_HPP
#include "skin_common.hpp"
-#include "../utils/pointer.hpp"
#include "../utils/var_bool.hpp"
-#include <list>
-class Anchor;
class OSWindow;
-class OSGraphics;
-class GenericLayout;
-class CtrlGeneric;
class EvtGeneric;
class EvtFocus;
class EvtLeave;
class EvtKey;
class EvtRefresh;
class EvtScroll;
-class WindowManager;
/// Generic window class
{
public:
GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
- WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop,
GenericWindow *pParent = NULL );
virtual ~GenericWindow();
/// Methods to process OS events.
- virtual void processEvent( EvtFocus &rEvtFocus );
- virtual void processEvent( EvtMotion &rEvtMotion );
- virtual void processEvent( EvtMouse &rEvtMouse );
- virtual void processEvent( EvtLeave &rEvtLeave );
- virtual void processEvent( EvtKey &rEvtKey );
- virtual void processEvent( EvtRefresh &rEvtRefresh );
- virtual void processEvent( EvtScroll &rEvtScroll );
-
- /// Forward an event to a control
- virtual void forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl );
+ virtual void processEvent( EvtFocus &rEvtFocus ) {}
+ virtual void processEvent( EvtMotion &rEvtMotion ) {}
+ virtual void processEvent( EvtMouse &rEvtMouse ) {}
+ virtual void processEvent( EvtLeave &rEvtLeave ) {}
+ virtual void processEvent( EvtKey &rEvtKey ) {}
+ virtual void processEvent( EvtRefresh &rEvtRefresh ) {}
+ virtual void processEvent( EvtScroll &rEvtScroll ) {}
// Show the window
virtual void show();
virtual void hide();
// 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 ) {}
/// Move the window
virtual void move( int left, int top );
/// Toggle the window on top
virtual void toggleOnTop( bool onTop ) const;
- /// Change the active layout
- virtual void setActiveLayout( GenericLayout *pLayout );
-
- /// Update the shape of the window from the active layout
- virtual void updateShape();
-
- /// Called by a control that wants to capture the mouse
- virtual void onControlCapture( const CtrlGeneric &rCtrl );
-
- /// Called by a control that wants to release the mouse
- virtual void onControlRelease( const CtrlGeneric &rCtrl );
-
- /// Called by a control when its tooltip changed
- virtual void onTooltipChange( const CtrlGeneric &rCtrl );
-
/// Get the coordinates of the window
virtual int getLeft() const { return m_left; }
virtual int getTop() const { return m_top; }
/// Give access to the visibility variable
VarBool &getVisibleVar() { return m_varVisible; }
- /// Get the list of the anchors of this window
- virtual const list<Anchor*> getAnchorList() const;
+ protected:
+ /// Actually show the window
+ virtual void innerShow();
+
+ /// Actually hide the window
+ virtual void innerHide();
- /// Add an anchor to this window
- virtual void addAnchor( Anchor *pAnchor );
+ /// Get the OS window
+ OSWindow *getOSWindow() const { return m_pOsWindow; }
private:
- /// Window manager
- WindowManager &m_rWindowManager;
/// Window position and size
int m_left, m_top, m_width, m_height;
- /// Flag set if the window has a parent
- bool m_isChild;
/// OS specific implementation
OSWindow *m_pOsWindow;
- /// Current active layout of the window
- GenericLayout *m_pActiveLayout;
- /// Last control on which the mouse was over
- CtrlGeneric *m_pLastHitControl;
- /// Control that has captured the mouse
- CtrlGeneric *m_pCapturingControl;
- /// Control that has the focus
- CtrlGeneric *m_pFocusControl;
- /// List of the anchors of this window
- list<Anchor*> m_anchorList;
/// Variable for the visibility of the window
VarBoolImpl m_varVisible;
- /// Current key modifier (also used for mouse)
- int m_currModifier;
/// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarBool> &rVariable );
-
- // Actually show the window
- virtual void innerShow();
-
- // Actually hide the window
- virtual void innerHide();
-
- /// Find the uppest control in the layout hit by the mouse, and send
- /// it an enter event if needed
- CtrlGeneric *findHitControl( int xPos, int yPos );
-
- /// Update the lastHitControl pointer and send a leave event to the
- /// right control
- void setLastHit( CtrlGeneric *pNewHitControl );
};
-typedef CountedPtr<GenericWindow> GenericWindowPtr;
-
#endif
return;
// Initialization
- map<string, GenericWindowPtr>::const_iterator it;
+ map<string, TopWindowPtr>::const_iterator it;
int i = 0;
int x, y, v, scan;
// Get config for each window
for( it = m_windows.begin(); it != m_windows.end(); it++ )
{
- GenericWindow *pWin = (*it).second.get();
+ TopWindow *pWin = (*it).second.get();
// Get config
scan = sscanf( &save[i * 13], "(%4d,%4d,%1d)", &x, &y, &v );
// Initialize char where config is stored
char *save = new char[400];
- map<string, GenericWindowPtr>::const_iterator it;
+ map<string, TopWindowPtr>::const_iterator it;
int i = 0;
int x, y;
// Save config of every window
for( it = m_windows.begin(); it != m_windows.end(); it++ )
{
- GenericWindow *pWin = (*it).second.get();
+ TopWindow *pWin = (*it).second.get();
// Print config
x = pWin->getLeft();
y = pWin->getTop();
FIND_OBJECT( GenericFontPtr, m_fonts );
}
-GenericWindow *Theme::getWindowById( const string &id )
+TopWindow *Theme::getWindowById( const string &id )
{
- FIND_OBJECT( GenericWindowPtr, m_windows );
+ FIND_OBJECT( TopWindowPtr, m_windows );
}
GenericLayout *Theme::getLayoutById( const string &id )
GenericBitmap *getBitmapById( const string &id );
GenericFont *getFontById( const string &id );
- GenericWindow *getWindowById( const string &id );
+ TopWindow *getWindowById( const string &id );
GenericLayout *getLayoutById( const string &id );
CtrlGeneric *getControlById( const string &id );
/// Store the fonts by ID
map<string, GenericFontPtr> m_fonts;
/// Store the windows by ID
- map<string, GenericWindowPtr> m_windows;
+ map<string, TopWindowPtr> m_windows;
/// Store the layouts by ID
map<string, GenericLayoutPtr> m_layouts;
/// Store the controls by ID
--- /dev/null
+/*****************************************************************************
+ * top_window.cpp
+ *****************************************************************************
+ * Copyright (C) 2003 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+#include "top_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>
+
+
+TopWindow::TopWindow( intf_thread_t *pIntf, int left, int top,
+ WindowManager &rWindowManager,
+ bool dragDrop, bool playOnDrop ):
+ GenericWindow( pIntf, left, top, dragDrop, playOnDrop,
+ NULL),
+ m_rWindowManager( rWindowManager ), m_pActiveLayout( NULL ),
+ m_pLastHitControl( NULL ), m_pCapturingControl( NULL ),
+ m_pFocusControl( NULL ), m_currModifier( 0 )
+{
+ // Register as a moving window
+ m_rWindowManager.registerWindow( *this );
+}
+
+
+TopWindow::~TopWindow()
+{
+ // Unregister from the window manager
+ m_rWindowManager.unregisterWindow( *this );
+}
+
+
+void TopWindow::processEvent( EvtFocus &rEvtFocus )
+{
+// fprintf(stderr, rEvtFocus.getAsString().c_str()) ;
+}
+
+
+void TopWindow::processEvent( EvtMotion &rEvtMotion )
+{
+ // New control hit by the mouse
+ CtrlGeneric *pNewHitControl =
+ findHitControl( rEvtMotion.getXPos() - getLeft(),
+ rEvtMotion.getYPos() - getTop() );
+
+ 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() - getLeft();
+ int yPos = rEvtMotion.getYPos() - getTop();
+ // Send a motion event
+ EvtMotion evt( getIntf(), xPos, yPos );
+ pActiveControl->handleEvent( evt );
+ }
+}
+
+
+void TopWindow::processEvent( EvtLeave &rEvtLeave )
+{
+ // No more hit control
+ setLastHit( NULL );
+
+ if( !m_pCapturingControl )
+ {
+ m_rWindowManager.hideTooltip();
+ }
+}
+
+
+void TopWindow::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 );
+ pNewHitControl->handleEvent( evt );
+ }
+ }
+ else if( m_pFocusControl )
+ {
+ // The previous control loses the focus
+ EvtFocus evt( getIntf(), false );
+ m_pFocusControl->handleEvent( evt );
+ m_pFocusControl = NULL;
+ }
+ }
+
+ // Send a mouse 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 )
+ {
+ pActiveControl->handleEvent( rEvtMouse );
+ }
+}
+
+
+void TopWindow::processEvent( EvtKey &rEvtKey )
+{
+ // Forward the event to the focused control, if any
+ if( m_pFocusControl )
+ {
+ m_pFocusControl->handleEvent( rEvtKey );
+ return;
+ }
+
+ // Only do the action when the key is down
+ if( rEvtKey.getAsString().find( "key:down") != string::npos )
+ {
+ //XXX not to be hardcoded !
+ // Ctrl-S = Change skin
+ if( (rEvtKey.getMod() & EvtInput::kModCtrl) &&
+ rEvtKey.getKey() == 's' )
+ {
+ Dialogs *pDialogs = Dialogs::instance( getIntf() );
+ if( pDialogs != NULL )
+ {
+ pDialogs->showChangeSkin();
+ }
+ return;
+ }
+
+ //XXX not to be hardcoded !
+ // Ctrl-T = Toggle on top
+ if( (rEvtKey.getMod() & EvtInput::kModCtrl) &&
+ rEvtKey.getKey() == 't' )
+ {
+ CmdOnTop cmd( getIntf() );
+ cmd.execute();
+ return;
+ }
+
+ vlc_value_t val;
+ // Set the key
+ val.i_int = rEvtKey.getKey();
+ // Set the modifiers
+ if( rEvtKey.getMod() & EvtInput::kModAlt )
+ {
+ val.i_int |= KEY_MODIFIER_ALT;
+ }
+ if( rEvtKey.getMod() & EvtInput::kModCtrl )
+ {
+ val.i_int |= KEY_MODIFIER_CTRL;
+ }
+ if( rEvtKey.getMod() & EvtInput::kModShift )
+ {
+ val.i_int |= KEY_MODIFIER_SHIFT;
+ }
+
+ var_Set( getIntf()->p_vlc, "key-pressed", val );
+ }
+
+ // Always store the modifier, which can be needed for scroll events
+ m_currModifier = rEvtKey.getMod();
+}
+
+
+void TopWindow::processEvent( EvtRefresh &rEvtRefresh )
+{
+ // Refresh the given area
+ refresh( rEvtRefresh.getXStart(), rEvtRefresh.getYStart(),
+ rEvtRefresh.getWidth(), rEvtRefresh.getHeight() );
+}
+
+
+void TopWindow::processEvent( EvtScroll &rEvtScroll )
+{
+ // Raise the windows
+ raise();
+
+ // Get the control hit by the mouse
+ CtrlGeneric *pNewHitControl = findHitControl( rEvtScroll.getXPos(),
+ rEvtScroll.getYPos());
+ setLastHit( pNewHitControl );
+
+ // Send a mouse 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 )
+ {
+ pActiveControl->handleEvent( rEvtScroll );
+ }
+ else
+ {
+ // Treat the scroll event as a hotkey
+ vlc_value_t val;
+ if( rEvtScroll.getDirection() == EvtScroll::kUp )
+ {
+ val.i_int = KEY_MOUSEWHEELUP;
+ }
+ else
+ {
+ val.i_int = KEY_MOUSEWHEELDOWN;
+ }
+ // Add the modifiers
+ val.i_int |= m_currModifier;
+
+ var_Set( getIntf()->p_vlc, "key-pressed", val );
+ }
+}
+
+
+void TopWindow::forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl )
+{
+ // XXX: We should do some checks here
+ rCtrl.handleEvent( rEvt );
+}
+
+
+void TopWindow::refresh( int left, int top, int width, int height )
+{
+ if( m_pActiveLayout )
+ {
+ m_pActiveLayout->getImage()->copyToWindow( *getOSWindow(), left, top,
+ width, height, left, top );
+ }
+}
+
+
+void TopWindow::setActiveLayout( GenericLayout *pLayout )
+{
+ pLayout->setWindow( this );
+ m_pActiveLayout = pLayout;
+ // Get the size of the layout and resize the window
+ resize( pLayout->getWidth(), pLayout->getHeight() );
+ updateShape();
+ pLayout->refreshAll();
+}
+
+
+void TopWindow::innerShow()
+{
+ // First, refresh the layout and update the shape of the window
+ if( m_pActiveLayout )
+ {
+ updateShape();
+ m_pActiveLayout->refreshAll();
+ }
+ // Show the window
+ GenericWindow::innerShow();
+}
+
+
+void TopWindow::updateShape()
+{
+ // Set the shape of the window
+ if( m_pActiveLayout )
+ {
+ OSGraphics *pImage = m_pActiveLayout->getImage();
+ if( pImage )
+ {
+ pImage->applyMaskToWindow( *getOSWindow() );
+ }
+ }
+}
+
+
+const list<Anchor*> TopWindow::getAnchorList() const
+{
+ return m_anchorList;
+}
+
+
+void TopWindow::addAnchor( Anchor *pAnchor )
+{
+ m_anchorList.push_back( pAnchor );
+}
+
+
+void TopWindow::onControlCapture( const CtrlGeneric &rCtrl )
+{
+ // Set the capturing control
+ m_pCapturingControl = (CtrlGeneric*) &rCtrl;
+}
+
+
+void TopWindow::onControlRelease( const CtrlGeneric &rCtrl )
+{
+ // Release the capturing control
+ if( m_pCapturingControl == &rCtrl )
+ {
+ m_pCapturingControl = NULL;
+ }
+ else
+ {
+ msg_Dbg( getIntf(), "Control had not captured the mouse" );
+ }
+
+ // Send an enter event to the control under the mouse, if it doesn't
+ // have received it yet
+ if( m_pLastHitControl && m_pLastHitControl != &rCtrl )
+ {
+ EvtEnter evt( getIntf() );
+ m_pLastHitControl->handleEvent( evt );
+
+ // Show the tooltip
+ m_rWindowManager.hideTooltip();
+ UString tipText = m_pLastHitControl->getTooltipText();
+ if( tipText.length() > 0 )
+ {
+ // Set the tooltip text variable
+ VarManager *pVarManager = VarManager::instance( getIntf() );
+ pVarManager->getTooltipText().set( tipText );
+ m_rWindowManager.showTooltip();
+ }
+ }
+}
+
+
+void TopWindow::onTooltipChange( const CtrlGeneric &rCtrl )
+{
+ // Check that the control is the active one
+ if( m_pLastHitControl && m_pLastHitControl == &rCtrl )
+ {
+ // Set the tooltip text variable
+ VarManager *pVarManager = VarManager::instance( getIntf() );
+ pVarManager->getTooltipText().set( rCtrl.getTooltipText() );
+ }
+}
+
+
+CtrlGeneric *TopWindow::findHitControl( int xPos, int yPos )
+{
+ if( m_pActiveLayout == NULL )
+ {
+ return NULL;
+ }
+
+ // Get the controls in the active layout
+ const list<LayeredControl> &ctrlList = m_pActiveLayout->getControlList();
+ list<LayeredControl>::const_reverse_iterator iter;
+
+ // New control hit by the mouse
+ CtrlGeneric *pNewHitControl = NULL;
+
+ // Loop on the control list to find the uppest hit control
+ for( iter = ctrlList.rbegin(); iter != ctrlList.rend(); iter++ )
+ {
+ // Get the position of the control in the layout
+ const Position *pos = (*iter).m_pControl->getPosition();
+ if( pos != NULL )
+ {
+ // Compute the coordinates of the mouse relative to the control
+ int xRel = xPos - pos->getLeft();
+ int yRel = yPos - pos->getTop();
+
+ CtrlGeneric *pCtrl = (*iter).m_pControl;
+ // Control hit ?
+ if( pCtrl->isVisible() && pCtrl->mouseOver( xRel, yRel ) )
+ {
+ pNewHitControl = (*iter).m_pControl;
+ break;
+ }
+ }
+ else
+ {
+ msg_Dbg( getIntf(), "Control at NULL position" );
+ }
+ }
+
+ // If the hit control has just been entered, send it an enter event
+ if( pNewHitControl && (pNewHitControl != m_pLastHitControl) )
+ {
+ // Don't send the event if another control captured the mouse
+ if( !m_pCapturingControl || (m_pCapturingControl == pNewHitControl ) )
+ {
+ EvtEnter evt( getIntf() );
+ pNewHitControl->handleEvent( evt );
+
+ if( !m_pCapturingControl )
+ {
+ // Show the tooltip
+ m_rWindowManager.hideTooltip();
+ UString tipText = pNewHitControl->getTooltipText();
+ if( tipText.length() > 0 )
+ {
+ // Set the tooltip text variable
+ VarManager *pVarManager = VarManager::instance( getIntf() );
+ pVarManager->getTooltipText().set( tipText );
+ m_rWindowManager.showTooltip();
+ }
+ }
+ }
+ }
+
+ return pNewHitControl;
+}
+
+
+
+void TopWindow::setLastHit( CtrlGeneric *pNewHitControl )
+{
+ // Send a leave event to the left control
+ if( m_pLastHitControl && (pNewHitControl != m_pLastHitControl) )
+ {
+ // Don't send the event if another control captured the mouse
+ if( !m_pCapturingControl || (m_pCapturingControl == m_pLastHitControl))
+ {
+ EvtLeave evt( getIntf() );
+ m_pLastHitControl->handleEvent( evt );
+ }
+ }
+
+ m_pLastHitControl = pNewHitControl;
+}
+
--- /dev/null
+/*****************************************************************************
+ * top_window.hpp
+ *****************************************************************************
+ * Copyright (C) 2003 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+#ifndef TOP_WINDOW_HPP
+#define TOP_WINDOW_HPP
+
+#include "generic_window.hpp"
+#include "../utils/pointer.hpp"
+#include <list>
+
+class Anchor;
+class OSWindow;
+class OSGraphics;
+class GenericLayout;
+class CtrlGeneric;
+class WindowManager;
+
+
+/// Class to handle top-level windows
+class TopWindow: public GenericWindow
+{
+ public:
+ TopWindow( intf_thread_t *pIntf, int xPos, int yPos,
+ WindowManager &rWindowManager,
+ bool dragDrop, bool playOnDrop );
+ virtual ~TopWindow();
+
+ /// Methods to process OS events.
+ virtual void processEvent( EvtFocus &rEvtFocus );
+ virtual void processEvent( EvtMotion &rEvtMotion );
+ virtual void processEvent( EvtMouse &rEvtMouse );
+ virtual void processEvent( EvtLeave &rEvtLeave );
+ virtual void processEvent( EvtKey &rEvtKey );
+ virtual void processEvent( EvtRefresh &rEvtRefresh );
+ virtual void processEvent( EvtScroll &rEvtScroll );
+
+ /// Forward an event to a control
+ virtual void forwardEvent( EvtGeneric &rEvt, CtrlGeneric &rCtrl );
+
+ // Refresh an area of the window
+ virtual void refresh( int left, int top, int width, int height );
+
+ /// Change the active layout
+ virtual void setActiveLayout( GenericLayout *pLayout );
+
+ /// Update the shape of the window from the active layout
+ virtual void updateShape();
+
+ /// Called by a control that wants to capture the mouse
+ virtual void onControlCapture( const CtrlGeneric &rCtrl );
+
+ /// Called by a control that wants to release the mouse
+ virtual void onControlRelease( const CtrlGeneric &rCtrl );
+
+ /// Called by a control when its tooltip changed
+ virtual void onTooltipChange( const CtrlGeneric &rCtrl );
+
+ /// Get the list of the anchors of this window
+ virtual const list<Anchor*> getAnchorList() const;
+
+ /// Add an anchor to this window
+ virtual void addAnchor( Anchor *pAnchor );
+
+ protected:
+ /// Actually show the window
+ virtual void innerShow();
+
+ private:
+ /// Window manager
+ WindowManager &m_rWindowManager;
+ /// Current active layout of the window
+ GenericLayout *m_pActiveLayout;
+ /// Last control on which the mouse was over
+ CtrlGeneric *m_pLastHitControl;
+ /// Control that has captured the mouse
+ CtrlGeneric *m_pCapturingControl;
+ /// Control that has the focus
+ CtrlGeneric *m_pFocusControl;
+ /// List of the anchors of this window
+ list<Anchor*> m_anchorList;
+ /// Current key modifier (also used for mouse)
+ int m_currModifier;
+
+ /// Find the uppest control in the layout hit by the mouse, and send
+ /// it an enter event if needed
+ CtrlGeneric *findHitControl( int xPos, int yPos );
+
+ /// Update the lastHitControl pointer and send a leave event to the
+ /// right control
+ void setLastHit( CtrlGeneric *pNewHitControl );
+};
+
+typedef CountedPtr<TopWindow> TopWindowPtr;
+
+
+#endif
VoutWindow::VoutWindow( intf_thread_t *pIntf, int left, int top,
- WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop, GenericWindow &rParent ):
- GenericWindow( pIntf, left, top, rWindowManager, dragDrop, playOnDrop,
+ GenericWindow( pIntf, left, top, dragDrop, playOnDrop,
&rParent )
{
}
{
public:
VoutWindow( intf_thread_t *pIntf, int xPos, int yPos,
- WindowManager &rWindowManager,
bool dragDrop, bool playOnDrop, GenericWindow &rParent );
virtual ~VoutWindow();
};
}
-void WindowManager::registerWindow( GenericWindow &rWindow )
+void WindowManager::registerWindow( TopWindow &rWindow )
{
// Add the window to the set
m_allWindows.insert( &rWindow );
}
-void WindowManager::unregisterWindow( GenericWindow &rWindow )
+void WindowManager::unregisterWindow( TopWindow &rWindow )
{
// Erase every possible reference to the window
m_allWindows.erase( &rWindow );
}
-void WindowManager::startMove( GenericWindow &rWindow )
+void WindowManager::startMove( TopWindow &rWindow )
{
// Rebuild the set of moving windows
m_movingWindows.clear();
}
-void WindowManager::move( GenericWindow &rWindow, int left, int top ) const
+void WindowManager::move( TopWindow &rWindow, int left, int top ) const
{
// Compute the real move offset
int xOffset = left - rWindow.getLeft();
}
-void WindowManager::raiseAll( GenericWindow &rWindow ) const
+void WindowManager::raiseAll( TopWindow &rWindow ) const
{
// Raise all the windows
WinSet_t::const_iterator it;
void WindowManager::buildDependSet( WinSet_t &rWinSet,
- GenericWindow *pWindow )
+ TopWindow *pWindow )
{
// pWindow is in the set
rWinSet.insert( pWindow );
}
-void WindowManager::checkAnchors( GenericWindow *pWindow,
+void WindowManager::checkAnchors( TopWindow *pWindow,
int &xOffset, int &yOffset ) const
{
WinSet_t::const_iterator itMov, itSta;
#define WINDOW_MANAGER_HPP
#include "skin_common.hpp"
-#include "generic_window.hpp"
+#include "top_window.hpp"
#include <list>
#include <map>
#include <set>
/// Add a window to the list of known windows. Necessary if you want
/// your window to be movable...
- void registerWindow( GenericWindow &rWindow );
+ void registerWindow( TopWindow &rWindow );
/// Remove a previously registered window
- void unregisterWindow( GenericWindow &rWindow );
+ void unregisterWindow( TopWindow &rWindow );
/// Tell the window manager that a move is initiated for pWindow.
- void startMove( GenericWindow &rWindow );
+ void startMove( TopWindow &rWindow );
/// Tell the window manager that the current move ended.
void stopMove();
/// Move the pWindow window to (left, top), and move all its
/// anchored windows.
/// If a new anchoring is detected, the windows will move accordingly.
- void move( GenericWindow &rWindow, int left, int top ) const;
+ void move( TopWindow &rWindow, int left, int top ) const;
/// Raise all the windows, rWindow being above the others
- void raiseAll( GenericWindow &rWindow ) const;
+ void raiseAll( TopWindow &rWindow ) const;
/// Show all the registered windows
void showAll() const;
void hideAll() const;
/// Show the given window
- void show( GenericWindow &rWindow ) { rWindow.show(); }
+ void show( TopWindow &rWindow ) { rWindow.show(); }
/// Hide the given window
- void hide( GenericWindow &rWindow ) { rWindow.hide(); }
+ void hide( TopWindow &rWindow ) { rWindow.hide(); }
/// Toggle all the windows on top
void toggleOnTop();
private:
/// Some useful typedefs for lazy people like me
- typedef set<GenericWindow*> WinSet_t;
+ typedef set<TopWindow*> WinSet_t;
typedef list<Anchor*> AncList_t;
/// This map represents the graph of anchored windows: it associates
/// This is not transitive, i.e. if a is in m_dep[b] and if b is in
/// m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
/// would be extremely rare...)
- map<GenericWindow*, WinSet_t> m_dependencies;
+ map<TopWindow*, WinSet_t> m_dependencies;
/// Store all the windows
WinSet_t m_allWindows;
/// Store the moving windows; this set is updated at every start of
Tooltip *m_pTooltip;
/// Recursively build a set of windows anchored to the one given.
- void buildDependSet( WinSet_t &rWinSet, GenericWindow *pWindow );
+ void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
/// Check anchoring: this function updates xOffset and yOffset,
/// to take care of a new anchoring (if any)
- void checkAnchors( GenericWindow *pWindow,
+ void checkAnchors( TopWindow *pWindow,
int &xOffset, int &yOffset ) const;
};
<Bitmap id="stop_disabled" file="stop_disabled.png" alphacolor="#FF0000"/>
<Bitmap id="stop_onclick" file="stop_onclick.png" alphacolor="#FF0000"/>
<Bitmap id="volume_radial" file="volume.png" alphacolor="#FF0000"/>
- <Bitmap id="vout" file="vout.png" alphacolor="#FF0000"/>
<Font id="default_font" font="FreeSansBold.ttf" size="15"/>
<Font id="playlist_font" font="FreeSansBold.ttf" size="12"/>