Commit 6f36d8b1 authored by Olivier Teulière's avatar Olivier Teulière

* skins2: Anchors are now stored in the layouts, not in the windows.

   If you change the layout all anchorings are lost, except for anchors that
   are in the same position in the old and the new layouts.
   Adding more 'persistent' anchorings should not be very difficult.
parent 732be244
...@@ -55,5 +55,6 @@ void CmdLayout::execute() ...@@ -55,5 +55,6 @@ void CmdLayout::execute()
// XXX TODO: check that the layout isn't a layout of another window // XXX TODO: check that the layout isn't a layout of another window
pWindow->setActiveLayout( pLayout ); getIntf()->p_sys->p_theme->getWindowManager().setActiveLayout( *pWindow,
*pLayout );
} }
...@@ -204,16 +204,16 @@ void Builder::addLayout( const BuilderData::Layout &rData ) ...@@ -204,16 +204,16 @@ void Builder::addLayout( const BuilderData::Layout &rData )
m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout ); m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout );
// Attach the layout to its window // Attach the layout to its window
pWin->setActiveLayout( pLayout ); m_pTheme->getWindowManager().addLayout( *pWin, *pLayout );
} }
void Builder::addAnchor( const BuilderData::Anchor &rData ) void Builder::addAnchor( const BuilderData::Anchor &rData )
{ {
TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get(); GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
if( pWin == NULL ) if( pLayout == NULL )
{ {
msg_Err( getIntf(), "unknown window id: %s", rData.m_windowId.c_str() ); msg_Err( getIntf(), "unknown layout id: %s", rData.m_layoutId.c_str() );
return; return;
} }
...@@ -228,8 +228,8 @@ void Builder::addAnchor( const BuilderData::Anchor &rData ) ...@@ -228,8 +228,8 @@ void Builder::addAnchor( const BuilderData::Anchor &rData )
Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos, Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos,
rData.m_range, rData.m_priority, rData.m_range, rData.m_priority,
*pCurve, *pWin ); *pCurve, *pLayout );
pWin->addAnchor( pAnc ); pLayout->addAnchor( pAnc );
} }
......
...@@ -4,7 +4,7 @@ BitmapFont id:string file:string type:string ...@@ -4,7 +4,7 @@ BitmapFont id:string file:string type:string
Font id:string fontFile:string size:int Font id:string fontFile:string size:int
Window id:string xPos:int yPos:int visible:bool dragDrop:bool playOnDrop:bool Window id:string xPos:int yPos:int visible:bool dragDrop:bool playOnDrop:bool
Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string Layout id:string width:int height:int minWidth:int maxWidth:int minHeight:int maxHeight:int windowId:string
Anchor xPos:int yPos:int range:int priority:int points:string windowId:string Anchor xPos:int yPos:int range:int priority:int points:string layoutId:string
Button id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string Button id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string
Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string up1Id:string down1Id:string over1Id:string up2Id:string down2Id:string over2Id:string state:string action1:string action2:string tooltip1:string tooltip2:string help:string layer:int windowId:string layoutId:string Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string up1Id:string down1Id:string over1Id:string up2Id:string down2Id:string over2Id:string state:string action1:string action2:string tooltip1:string tooltip2:string help:string layer:int windowId:string layoutId:string
Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string help:string layer:int windowId:string layoutId:string Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string help:string layer:int windowId:string layoutId:string
......
...@@ -130,15 +130,15 @@ m_id( id ), m_width( width ), m_height( height ), m_minWidth( minWidth ), m_maxW ...@@ -130,15 +130,15 @@ m_id( id ), m_width( width ), m_height( height ), m_minWidth( minWidth ), m_maxW
/// Type definition /// Type definition
struct Anchor struct Anchor
{ {
Anchor( int xPos, int yPos, int range, int priority, const string & points, const string & windowId ): Anchor( int xPos, int yPos, int range, int priority, const string & points, const string & layoutId ):
m_xPos( xPos ), m_yPos( yPos ), m_range( range ), m_priority( priority ), m_points( points ), m_windowId( windowId ) {} m_xPos( xPos ), m_yPos( yPos ), m_range( range ), m_priority( priority ), m_points( points ), m_layoutId( layoutId ) {}
int m_xPos; int m_xPos;
int m_yPos; int m_yPos;
int m_range; int m_range;
int m_priority; int m_priority;
const string m_points; const string m_points;
const string m_windowId; const string m_layoutId;
}; };
/// List /// List
list<Anchor> m_listAnchor; list<Anchor> m_listAnchor;
......
...@@ -40,7 +40,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) ...@@ -40,7 +40,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
{ {
const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset, const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset,
atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ), atoi( attr["y"] ) + m_yOffset, atoi( attr["range"] ),
atoi( attr["priority"] ), attr["points"], m_curWindowId ); atoi( attr["priority"] ), attr["points"], m_curLayoutId );
m_data.m_listAnchor.push_back( anchor ); m_data.m_listAnchor.push_back( anchor );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* anchor.hpp * anchor.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: anchor.hpp,v 1.2 2004/03/02 21:45:15 ipkiss Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulière <ipkiss@via.ecp.fr> * Olivier Teulière <ipkiss@via.ecp.fr>
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define ANCHOR_HPP #define ANCHOR_HPP
#include "skin_common.hpp" #include "skin_common.hpp"
#include "generic_window.hpp" #include "generic_layout.hpp"
#include "../utils/bezier.hpp" #include "../utils/bezier.hpp"
...@@ -35,10 +35,10 @@ class Anchor: public SkinObject ...@@ -35,10 +35,10 @@ class Anchor: public SkinObject
{ {
public: public:
Anchor( intf_thread_t *pIntf, int xPos, int yPos, int range, Anchor( intf_thread_t *pIntf, int xPos, int yPos, int range,
int priority, const Bezier &rCurve, GenericWindow &rWindow ): int priority, const Bezier &rCurve, GenericLayout &rLayout ):
SkinObject( pIntf ), m_xPos( xPos ), m_yPos( yPos ), SkinObject( pIntf ), m_xPos( xPos ), m_yPos( yPos ),
m_rCurve( rCurve ), m_range( range ), m_priority( priority ), m_rCurve( rCurve ), m_range( range ), m_priority( priority ),
m_rWindow( rWindow ) {} m_rLayout( rLayout ) {}
virtual ~Anchor() {} virtual ~Anchor() {}
/// Return true if the given anchor is hanged by this one /// Return true if the given anchor is hanged by this one
...@@ -62,8 +62,8 @@ class Anchor: public SkinObject ...@@ -62,8 +62,8 @@ class Anchor: public SkinObject
bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; } bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
// Getters // Getters
int getXPosAbs() const { return (m_xPos + m_rWindow.getLeft()); } int getXPosAbs() const { return (m_xPos + m_rLayout.getLeft()); }
int getYPosAbs() const { return (m_yPos + m_rWindow.getTop()); } int getYPosAbs() const { return (m_yPos + m_rLayout.getTop()); }
private: private:
/// Coordinates relative to the window /// Coordinates relative to the window
...@@ -79,7 +79,7 @@ class Anchor: public SkinObject ...@@ -79,7 +79,7 @@ class Anchor: public SkinObject
int m_priority; int m_priority;
/// Parent window /// Parent window
GenericWindow &m_rWindow; GenericLayout &m_rLayout;
}; };
......
...@@ -198,3 +198,15 @@ void GenericLayout::refreshAll() ...@@ -198,3 +198,15 @@ void GenericLayout::refreshAll()
} }
} }
const list<Anchor*>& GenericLayout::getAnchorList() const
{
return m_anchorList;
}
void GenericLayout::addAnchor( Anchor *pAnchor )
{
m_anchorList.push_back( pAnchor );
}
...@@ -26,12 +26,13 @@ ...@@ -26,12 +26,13 @@
#define GENERIC_LAYOUT_HPP #define GENERIC_LAYOUT_HPP
#include "skin_common.hpp" #include "skin_common.hpp"
#include "top_window.hpp"
#include "../utils/pointer.hpp" #include "../utils/pointer.hpp"
#include "../utils/position.hpp" #include "../utils/position.hpp"
#include <list> #include <list>
class TopWindow; class Anchor;
class OSGraphics; class OSGraphics;
class CtrlGeneric; class CtrlGeneric;
...@@ -77,6 +78,10 @@ class GenericLayout: public SkinObject, public Box ...@@ -77,6 +78,10 @@ class GenericLayout: public SkinObject, public Box
/// Get the image of the layout /// Get the image of the layout
virtual OSGraphics *getImage() const { return m_pImage; } virtual OSGraphics *getImage() const { return m_pImage; }
/// Get the position of the layout (relative to the screen)
virtual int getLeft() const { return m_pWindow->getLeft(); }
virtual int getTop() const { return m_pWindow->getTop(); }
/// Get the size of the layout /// Get the size of the layout
virtual int getWidth() const { return m_width; } virtual int getWidth() const { return m_width; }
virtual int getHeight() const { return m_height; } virtual int getHeight() const { return m_height; }
...@@ -102,6 +107,12 @@ class GenericLayout: public SkinObject, public Box ...@@ -102,6 +107,12 @@ class GenericLayout: public SkinObject, public Box
/// Called by a control when its image has changed /// Called by a control when its image has changed
virtual void onControlUpdate( const CtrlGeneric &rCtrl ); virtual void onControlUpdate( const CtrlGeneric &rCtrl );
/// Get the list of the anchors of this layout
virtual const list<Anchor*>& getAnchorList() const;
/// Add an anchor to this layout
virtual void addAnchor( Anchor *pAnchor );
private: private:
/// Parent window of the layout /// Parent window of the layout
TopWindow *m_pWindow; TopWindow *m_pWindow;
...@@ -113,6 +124,8 @@ class GenericLayout: public SkinObject, public Box ...@@ -113,6 +124,8 @@ class GenericLayout: public SkinObject, public Box
OSGraphics *m_pImage; OSGraphics *m_pImage;
/// List of the controls in the layout /// List of the controls in the layout
list<LayeredControl> m_controlList; list<LayeredControl> m_controlList;
/// List of the anchors in the layout
list<Anchor*> m_anchorList;
}; };
......
...@@ -301,6 +301,12 @@ void TopWindow::setActiveLayout( GenericLayout *pLayout ) ...@@ -301,6 +301,12 @@ void TopWindow::setActiveLayout( GenericLayout *pLayout )
} }
const GenericLayout& TopWindow::getActiveLayout() const
{
return *m_pActiveLayout;
}
void TopWindow::innerShow() void TopWindow::innerShow()
{ {
// First, refresh the layout and update the shape of the window // First, refresh the layout and update the shape of the window
...@@ -328,18 +334,6 @@ void TopWindow::updateShape() ...@@ -328,18 +334,6 @@ void TopWindow::updateShape()
} }
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 ) void TopWindow::onControlCapture( const CtrlGeneric &rCtrl )
{ {
// Set the capturing control // Set the capturing control
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "../utils/pointer.hpp" #include "../utils/pointer.hpp"
#include <list> #include <list>
class Anchor;
class OSWindow; class OSWindow;
class OSGraphics; class OSGraphics;
class GenericLayout; class GenericLayout;
...@@ -63,6 +62,9 @@ class TopWindow: public GenericWindow ...@@ -63,6 +62,9 @@ class TopWindow: public GenericWindow
/// Change the active layout /// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout ); virtual void setActiveLayout( GenericLayout *pLayout );
/// Get the active layout
virtual const GenericLayout& getActiveLayout() const;
/// Update the shape of the window from the active layout /// Update the shape of the window from the active layout
virtual void updateShape(); virtual void updateShape();
...@@ -75,12 +77,6 @@ class TopWindow: public GenericWindow ...@@ -75,12 +77,6 @@ class TopWindow: public GenericWindow
/// Called by a control when its tooltip changed /// Called by a control when its tooltip changed
virtual void onTooltipChange( const CtrlGeneric &rCtrl ); 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: protected:
/// Actually show the window /// Actually show the window
virtual void innerShow(); virtual void innerShow();
...@@ -96,8 +92,6 @@ class TopWindow: public GenericWindow ...@@ -96,8 +92,6 @@ class TopWindow: public GenericWindow
CtrlGeneric *m_pCapturingControl; CtrlGeneric *m_pCapturingControl;
/// Control that has the focus /// Control that has the focus
CtrlGeneric *m_pFocusControl; CtrlGeneric *m_pFocusControl;
/// List of the anchors of this window
list<Anchor*> m_anchorList;
/// Current key modifier (also used for mouse) /// Current key modifier (also used for mouse)
int m_currModifier; int m_currModifier;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*****************************************************************************/ *****************************************************************************/
#include "window_manager.hpp" #include "window_manager.hpp"
#include "generic_layout.hpp"
#include "generic_window.hpp" #include "generic_window.hpp"
#include "os_factory.hpp" #include "os_factory.hpp"
#include "anchor.hpp" #include "anchor.hpp"
...@@ -92,8 +93,9 @@ void WindowManager::stopMove() ...@@ -92,8 +93,9 @@ void WindowManager::stopMove()
// Iterate through all the windows // Iterate through all the windows
for( itWin1 = m_allWindows.begin(); itWin1 != m_allWindows.end(); itWin1++ ) for( itWin1 = m_allWindows.begin(); itWin1 != m_allWindows.end(); itWin1++ )
{ {
// Get the anchors of the window // Get the anchors of the layout associated to the window
const AncList_t &ancList1 = (*itWin1)->getAnchorList(); const AncList_t &ancList1 =
(*itWin1)->getActiveLayout().getAnchorList();
// Iterate through all the windows, starting with (*itWin1) // Iterate through all the windows, starting with (*itWin1)
for( itWin2 = itWin1; itWin2 != m_allWindows.end(); itWin2++ ) for( itWin2 = itWin1; itWin2 != m_allWindows.end(); itWin2++ )
...@@ -103,7 +105,8 @@ void WindowManager::stopMove() ...@@ -103,7 +105,8 @@ void WindowManager::stopMove()
continue; continue;
// Now, check for anchoring between the 2 windows // Now, check for anchoring between the 2 windows
const AncList_t &ancList2 = (*itWin2)->getAnchorList(); const AncList_t &ancList2 =
(*itWin2)->getActiveLayout().getAnchorList();
for( itAnc1 = ancList1.begin(); itAnc1 != ancList1.end(); itAnc1++ ) for( itAnc1 = ancList1.begin(); itAnc1 != ancList1.end(); itAnc1++ )
{ {
for( itAnc2 = ancList2.begin(); for( itAnc2 = ancList2.begin();
...@@ -261,8 +264,9 @@ void WindowManager::checkAnchors( TopWindow *pWindow, ...@@ -261,8 +264,9 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
continue; continue;
} }
// Get the anchors of this moving window // Get the anchors in the main layout of this moving window
const AncList_t &movAnchors = (*itMov)->getAnchorList(); const AncList_t &movAnchors =
(*itMov)->getActiveLayout().getAnchorList();
// Iterate through the static windows // Iterate through the static windows
for( itSta = m_allWindows.begin(); for( itSta = m_allWindows.begin();
...@@ -275,8 +279,9 @@ void WindowManager::checkAnchors( TopWindow *pWindow, ...@@ -275,8 +279,9 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
continue; continue;
} }
// Get the anchors of this static window // Get the anchors in the main layout of this static window
const AncList_t &staAnchors = (*itSta)->getAnchorList(); const AncList_t &staAnchors =
(*itSta)->getActiveLayout().getAnchorList();
// Check if there is an anchoring between one of the movAnchors // Check if there is an anchoring between one of the movAnchors
// and one of the staAnchors // and one of the staAnchors
...@@ -350,3 +355,18 @@ void WindowManager::hideTooltip() ...@@ -350,3 +355,18 @@ void WindowManager::hideTooltip()
m_pTooltip->hide(); m_pTooltip->hide();
} }
} }
void WindowManager::addLayout( TopWindow &rWindow, GenericLayout &rLayout )
{
rWindow.setActiveLayout( &rLayout );
}
void WindowManager::setActiveLayout( TopWindow &rWindow,
GenericLayout &rLayout )
{
rWindow.setActiveLayout( &rLayout );
// Rebuild the dependencies
stopMove();
}
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
class GenericFont; class GenericFont;
class GenericLayout;
class Anchor; class Anchor;
class Tooltip; class Tooltip;
...@@ -102,6 +103,13 @@ class WindowManager: public SkinObject ...@@ -102,6 +103,13 @@ class WindowManager: public SkinObject
/// Hide the tooltip window /// Hide the tooltip window
void hideTooltip(); void hideTooltip();
/// Add a layout of the given window. This new layout will be the
/// active one.
void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
/// Change the active layout of the given window
void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
private: private:
/// Some useful typedefs for lazy people like me /// Some useful typedefs for lazy people like me
typedef set<TopWindow*> WinSet_t; typedef set<TopWindow*> WinSet_t;
......
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