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