Commit af178856 authored by Cyril Deguet's avatar Cyril Deguet

* all: the tooltip window is now managed by the window manager, not

  by the generic windows
parent bf0685f8
...@@ -110,9 +110,14 @@ Theme *Builder::build() ...@@ -110,9 +110,14 @@ Theme *Builder::build()
void Builder::addTheme( const BuilderData::Theme &rData ) void Builder::addTheme( const BuilderData::Theme &rData )
{ {
m_pTheme->getWindowManager().setMagnetValue( rData.m_magnet ); WindowManager &rManager = m_pTheme->getWindowManager();
m_pTheme->getWindowManager().setAlphaValue( rData.m_alpha ); rManager.setMagnetValue( rData.m_magnet );
m_pTheme->getWindowManager().setMoveAlphaValue( rData.m_moveAlpha ); rManager.setAlphaValue( rData.m_alpha );
rManager.setMoveAlphaValue( rData.m_moveAlpha );
// XXX: font to fix
GenericFont *pFont = new FT2Font( getIntf(), "FreeSans.ttf", 12 );
pFont->init();
rManager.createTooltip( *pFont );
} }
...@@ -135,12 +140,9 @@ void Builder::addFont( const BuilderData::Font &rData ) ...@@ -135,12 +140,9 @@ void Builder::addFont( const BuilderData::Font &rData )
void Builder::addWindow( const BuilderData::Window &rData ) void Builder::addWindow( const BuilderData::Window &rData )
{ {
// XXX: font to fix
GenericFont *pFont = new FT2Font( getIntf(), "FreeSans.ttf", 12 );
pFont->init();
GenericWindow *pWin = GenericWindow *pWin =
new GenericWindow( getIntf(), rData.m_xPos, rData.m_yPos, new GenericWindow( getIntf(), rData.m_xPos, rData.m_yPos,
m_pTheme->getWindowManager(), *pFont, m_pTheme->getWindowManager(),
rData.m_dragDrop, rData.m_playOnDrop ); rData.m_dragDrop, rData.m_playOnDrop );
m_pTheme->m_windows[rData.m_id] = GenericWindowPtr( pWin ); m_pTheme->m_windows[rData.m_id] = GenericWindowPtr( pWin );
......
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
#include "os_window.hpp" #include "os_window.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "theme.hpp" #include "theme.hpp"
#include "ft2_font.hpp"
#include "tooltip.hpp"
#include "dialogs.hpp" #include "dialogs.hpp"
#include "var_manager.hpp" #include "var_manager.hpp"
#include "../commands/cmd_on_top.hpp" #include "../commands/cmd_on_top.hpp"
...@@ -51,7 +49,6 @@ ...@@ -51,7 +49,6 @@
GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top, GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
WindowManager &rWindowManager, WindowManager &rWindowManager,
const GenericFont &rTipFont,
bool dragDrop, bool playOnDrop ): bool dragDrop, bool playOnDrop ):
SkinObject( pIntf ), m_rWindowManager( rWindowManager ), SkinObject( pIntf ), m_rWindowManager( rWindowManager ),
m_left( left ), m_top( top ), m_width( 0 ), m_height( 0 ), m_left( left ), m_top( top ), m_width( 0 ), m_height( 0 ),
...@@ -67,9 +64,6 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top, ...@@ -67,9 +64,6 @@ GenericWindow::GenericWindow( intf_thread_t *pIntf, int left, int top,
// Create an OSWindow to handle OS specific processing // Create an OSWindow to handle OS specific processing
m_pOsWindow = pOsFactory->createOSWindow( *this, dragDrop, playOnDrop ); m_pOsWindow = pOsFactory->createOSWindow( *this, dragDrop, playOnDrop );
// Create the tooltip window
m_pTooltip = new Tooltip( getIntf(), rTipFont, 500 );
// Observe the visibility variable // Observe the visibility variable
m_varVisible.addObserver( this ); m_varVisible.addObserver( this );
} }
...@@ -81,10 +75,6 @@ GenericWindow::~GenericWindow() ...@@ -81,10 +75,6 @@ GenericWindow::~GenericWindow()
// Unregister from the window manager // Unregister from the window manager
m_rWindowManager.unregisterWindow( *this ); m_rWindowManager.unregisterWindow( *this );
if( m_pTooltip )
{
delete m_pTooltip;
}
if( m_pOsWindow ) if( m_pOsWindow )
{ {
delete m_pOsWindow; delete m_pOsWindow;
...@@ -140,7 +130,7 @@ void GenericWindow::processEvent( EvtLeave &rEvtLeave ) ...@@ -140,7 +130,7 @@ void GenericWindow::processEvent( EvtLeave &rEvtLeave )
if( !m_pCapturingControl ) if( !m_pCapturingControl )
{ {
m_pTooltip->hide(); m_rWindowManager.hideTooltip();
} }
} }
...@@ -419,14 +409,14 @@ void GenericWindow::onControlRelease( const CtrlGeneric &rCtrl ) ...@@ -419,14 +409,14 @@ void GenericWindow::onControlRelease( const CtrlGeneric &rCtrl )
m_pLastHitControl->handleEvent( evt ); m_pLastHitControl->handleEvent( evt );
// Show the tooltip // Show the tooltip
m_pTooltip->hide(); m_rWindowManager.hideTooltip();
UString tipText = m_pLastHitControl->getTooltipText(); UString tipText = m_pLastHitControl->getTooltipText();
if( tipText.length() > 0 ) if( tipText.length() > 0 )
{ {
// Set the tooltip text variable // Set the tooltip text variable
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getTooltipText().set( tipText ); pVarManager->getTooltipText().set( tipText );
m_pTooltip->show(); m_rWindowManager.showTooltip();
} }
} }
} }
...@@ -533,14 +523,14 @@ CtrlGeneric *GenericWindow::findHitControl( int xPos, int yPos ) ...@@ -533,14 +523,14 @@ CtrlGeneric *GenericWindow::findHitControl( int xPos, int yPos )
if( !m_pCapturingControl ) if( !m_pCapturingControl )
{ {
// Show the tooltip // Show the tooltip
m_pTooltip->hide(); m_rWindowManager.hideTooltip();
UString tipText = pNewHitControl->getTooltipText(); UString tipText = pNewHitControl->getTooltipText();
if( tipText.length() > 0 ) if( tipText.length() > 0 )
{ {
// Set the tooltip text variable // Set the tooltip text variable
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
pVarManager->getTooltipText().set( tipText ); pVarManager->getTooltipText().set( tipText );
m_pTooltip->show(); m_rWindowManager.showTooltip();
} }
} }
} }
......
...@@ -34,7 +34,6 @@ class Anchor; ...@@ -34,7 +34,6 @@ class Anchor;
class OSWindow; class OSWindow;
class OSGraphics; class OSGraphics;
class GenericLayout; class GenericLayout;
class Tooltip;
class CtrlGeneric; class CtrlGeneric;
class EvtGeneric; class EvtGeneric;
class EvtFocus; class EvtFocus;
...@@ -44,7 +43,6 @@ class EvtMouse; ...@@ -44,7 +43,6 @@ class EvtMouse;
class EvtKey; class EvtKey;
class EvtRefresh; class EvtRefresh;
class EvtScroll; class EvtScroll;
class GenericFont;
class WindowManager; class WindowManager;
...@@ -54,7 +52,6 @@ class GenericWindow: public SkinObject, public Observer<VarBool> ...@@ -54,7 +52,6 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
public: public:
GenericWindow( intf_thread_t *pIntf, int xPos, int yPos, GenericWindow( intf_thread_t *pIntf, int xPos, int yPos,
WindowManager &rWindowManager, WindowManager &rWindowManager,
const GenericFont &rTipFont,
bool dragDrop, bool playOnDrop ); bool dragDrop, bool playOnDrop );
virtual ~GenericWindow(); virtual ~GenericWindow();
...@@ -141,10 +138,6 @@ class GenericWindow: public SkinObject, public Observer<VarBool> ...@@ -141,10 +138,6 @@ class GenericWindow: public SkinObject, public Observer<VarBool>
CtrlGeneric *m_pFocusControl; CtrlGeneric *m_pFocusControl;
/// List of the anchors of this window /// List of the anchors of this window
list<Anchor*> m_anchorList; list<Anchor*> m_anchorList;
/// Font for the tooltip
GenericFont *m_pFont;
/// Tooltip
Tooltip *m_pTooltip;
/// Variable for the visibility of the window /// Variable for the visibility of the window
VarBoolImpl m_varVisible; VarBoolImpl m_varVisible;
......
...@@ -26,9 +26,22 @@ ...@@ -26,9 +26,22 @@
#include "generic_window.hpp" #include "generic_window.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "anchor.hpp" #include "anchor.hpp"
#include "tooltip.hpp"
#include "../utils/position.hpp" #include "../utils/position.hpp"
WindowManager::WindowManager( intf_thread_t *pIntf ):
SkinObject( pIntf ), m_isOnTop( false ), m_magnet( 0 ), m_pTooltip( NULL )
{
}
WindowManager::~WindowManager()
{
delete m_pTooltip;
}
void WindowManager::registerWindow( GenericWindow &rWindow ) void WindowManager::registerWindow( GenericWindow &rWindow )
{ {
// Add the window to the set // Add the window to the set
...@@ -307,3 +320,33 @@ void WindowManager::checkAnchors( GenericWindow *pWindow, ...@@ -307,3 +320,33 @@ void WindowManager::checkAnchors( GenericWindow *pWindow,
} }
void WindowManager::createTooltip( const GenericFont &rTipFont )
{
// Create the tooltip window
if( !m_pTooltip )
{
m_pTooltip = new Tooltip( getIntf(), rTipFont, 500 );
}
else
{
msg_Warn( getIntf(), "Tooltip already created!");
}
}
void WindowManager::showTooltip()
{
if( m_pTooltip )
{
m_pTooltip->show();
}
}
void WindowManager::hideTooltip()
{
if( m_pTooltip )
{
m_pTooltip->hide();
}
}
...@@ -33,16 +33,20 @@ ...@@ -33,16 +33,20 @@
#include <utility> #include <utility>
class GenericFont;
class Anchor; class Anchor;
class Tooltip;
/// Window manager for skin windows /// Window manager for skin windows
class WindowManager: public SkinObject class WindowManager: public SkinObject
{ {
public: public:
WindowManager( intf_thread_t *pIntf ): /// Constructor
SkinObject( pIntf ), m_isOnTop( false ), m_magnet( 0 ) {} WindowManager( intf_thread_t *pIntf);
virtual ~WindowManager() {}
/// Destructor
virtual ~WindowManager();
/// Add a window to the list of known windows. Necessary if you want /// Add a window to the list of known windows. Necessary if you want
/// your window to be movable... /// your window to be movable...
...@@ -89,6 +93,15 @@ class WindowManager: public SkinObject ...@@ -89,6 +93,15 @@ class WindowManager: public SkinObject
/// Set the alpha value of the moving windows /// Set the alpha value of the moving windows
void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; } void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
/// Create the tooltip window
void createTooltip( const GenericFont &rTipFont );
/// Show the tooltip window
void showTooltip();
/// Hide the tooltip window
void hideTooltip();
private: private:
/// Some useful typedefs for lazy people like me /// Some useful typedefs for lazy people like me
typedef set<GenericWindow*> WinSet_t; typedef set<GenericWindow*> WinSet_t;
...@@ -100,25 +113,21 @@ class WindowManager: public SkinObject ...@@ -100,25 +113,21 @@ class WindowManager: public SkinObject
/// m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it /// m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
/// would be extremely rare...) /// would be extremely rare...)
map<GenericWindow*, WinSet_t> m_dependencies; map<GenericWindow*, WinSet_t> m_dependencies;
/// Store all the windows /// Store all the windows
WinSet_t m_allWindows; WinSet_t m_allWindows;
/// Store the moving windows; this set is updated at every start of /// Store the moving windows; this set is updated at every start of
/// move. /// move.
WinSet_t m_movingWindows; WinSet_t m_movingWindows;
/// Indicate whether the windows are currently on top /// Indicate whether the windows are currently on top
bool m_isOnTop; bool m_isOnTop;
/// Magnetism of the screen edges (= scope of action) /// Magnetism of the screen edges (= scope of action)
int m_magnet; int m_magnet;
/// Alpha value of the static windows /// Alpha value of the static windows
int m_alpha; int m_alpha;
/// Alpha value of the moving windows /// Alpha value of the moving windows
int m_moveAlpha; int m_moveAlpha;
/// Tooltip
Tooltip *m_pTooltip;
/// Recursively build a set of windows anchored to the one given. /// Recursively build a set of windows anchored to the one given.
void buildDependSet( WinSet_t &rWinSet, GenericWindow *pWindow ); void buildDependSet( WinSet_t &rWinSet, GenericWindow *pWindow );
......
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