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()
// 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 )
m_pTheme->m_layouts[rData.m_id] = GenericLayoutPtr( pLayout );
// Attach the layout to its window
pWin->setActiveLayout( pLayout );
m_pTheme->getWindowManager().addLayout( *pWin, *pLayout );
}
void Builder::addAnchor( const BuilderData::Anchor &rData )
{
TopWindow *pWin = m_pTheme->m_windows[rData.m_windowId].get();
if( pWin == NULL )
GenericLayout *pLayout = m_pTheme->m_layouts[rData.m_layoutId].get();
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;
}
......@@ -228,8 +228,8 @@ void Builder::addAnchor( const BuilderData::Anchor &rData )
Anchor *pAnc = new Anchor( getIntf(), rData.m_xPos, rData.m_yPos,
rData.m_range, rData.m_priority,
*pCurve, *pWin );
pWin->addAnchor( pAnc );
*pCurve, *pLayout );
pLayout->addAnchor( pAnc );
}
......
......@@ -4,7 +4,7 @@ BitmapFont id:string file:string type:string
Font id:string fontFile:string size:int
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
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
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
......
......@@ -130,15 +130,15 @@ m_id( id ), m_width( width ), m_height( height ), m_minWidth( minWidth ), m_maxW
/// Type definition
struct Anchor
{
Anchor( int xPos, int yPos, int range, int priority, const string & points, const string & windowId ):
m_xPos( xPos ), m_yPos( yPos ), m_range( range ), m_priority( priority ), m_points( points ), m_windowId( 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_layoutId( layoutId ) {}
int m_xPos;
int m_yPos;
int m_range;
int m_priority;
const string m_points;
const string m_windowId;
const string m_layoutId;
};
/// List
list<Anchor> m_listAnchor;
......
......@@ -40,7 +40,7 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
{
const BuilderData::Anchor anchor( atoi( attr["x"] ) + m_xOffset,
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 );
}
......
......@@ -2,7 +2,7 @@
* anchor.hpp
*****************************************************************************
* 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>
* Olivier Teulière <ipkiss@via.ecp.fr>
......@@ -26,7 +26,7 @@
#define ANCHOR_HPP
#include "skin_common.hpp"
#include "generic_window.hpp"
#include "generic_layout.hpp"
#include "../utils/bezier.hpp"
......@@ -35,10 +35,10 @@ class Anchor: public SkinObject
{
public:
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 ),
m_rCurve( rCurve ), m_range( range ), m_priority( priority ),
m_rWindow( rWindow ) {}
m_rLayout( rLayout ) {}
virtual ~Anchor() {}
/// Return true if the given anchor is hanged by this one
......@@ -62,8 +62,8 @@ class Anchor: public SkinObject
bool isPoint() const { return m_rCurve.getNbCtrlPoints() == 1; }
// Getters
int getXPosAbs() const { return (m_xPos + m_rWindow.getLeft()); }
int getYPosAbs() const { return (m_yPos + m_rWindow.getTop()); }
int getXPosAbs() const { return (m_xPos + m_rLayout.getLeft()); }
int getYPosAbs() const { return (m_yPos + m_rLayout.getTop()); }
private:
/// Coordinates relative to the window
......@@ -79,7 +79,7 @@ class Anchor: public SkinObject
int m_priority;
/// Parent window
GenericWindow &m_rWindow;
GenericLayout &m_rLayout;
};
......
......@@ -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 @@
#define GENERIC_LAYOUT_HPP
#include "skin_common.hpp"
#include "top_window.hpp"
#include "../utils/pointer.hpp"
#include "../utils/position.hpp"
#include <list>
class TopWindow;
class Anchor;
class OSGraphics;
class CtrlGeneric;
......@@ -77,6 +78,10 @@ class GenericLayout: public SkinObject, public Box
/// Get the image of the layout
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
virtual int getWidth() const { return m_width; }
virtual int getHeight() const { return m_height; }
......@@ -102,6 +107,12 @@ class GenericLayout: public SkinObject, public Box
/// Called by a control when its image has changed
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:
/// Parent window of the layout
TopWindow *m_pWindow;
......@@ -113,6 +124,8 @@ class GenericLayout: public SkinObject, public Box
OSGraphics *m_pImage;
/// List of the controls in the layout
list<LayeredControl> m_controlList;
/// List of the anchors in the layout
list<Anchor*> m_anchorList;
};
......
......@@ -301,6 +301,12 @@ void TopWindow::setActiveLayout( GenericLayout *pLayout )
}
const GenericLayout& TopWindow::getActiveLayout() const
{
return *m_pActiveLayout;
}
void TopWindow::innerShow()
{
// First, refresh the layout and update the shape of the window
......@@ -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 )
{
// Set the capturing control
......
......@@ -29,7 +29,6 @@
#include "../utils/pointer.hpp"
#include <list>
class Anchor;
class OSWindow;
class OSGraphics;
class GenericLayout;
......@@ -63,6 +62,9 @@ class TopWindow: public GenericWindow
/// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout );
/// Get the active layout
virtual const GenericLayout& getActiveLayout() const;
/// Update the shape of the window from the active layout
virtual void updateShape();
......@@ -75,12 +77,6 @@ class TopWindow: public GenericWindow
/// 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();
......@@ -96,8 +92,6 @@ class TopWindow: public GenericWindow
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;
......
......@@ -23,6 +23,7 @@
*****************************************************************************/
#include "window_manager.hpp"
#include "generic_layout.hpp"
#include "generic_window.hpp"
#include "os_factory.hpp"
#include "anchor.hpp"
......@@ -92,8 +93,9 @@ void WindowManager::stopMove()
// Iterate through all the windows
for( itWin1 = m_allWindows.begin(); itWin1 != m_allWindows.end(); itWin1++ )
{
// Get the anchors of the window
const AncList_t &ancList1 = (*itWin1)->getAnchorList();
// Get the anchors of the layout associated to the window
const AncList_t &ancList1 =
(*itWin1)->getActiveLayout().getAnchorList();
// Iterate through all the windows, starting with (*itWin1)
for( itWin2 = itWin1; itWin2 != m_allWindows.end(); itWin2++ )
......@@ -103,7 +105,8 @@ void WindowManager::stopMove()
continue;
// 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( itAnc2 = ancList2.begin();
......@@ -261,8 +264,9 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
continue;
}
// Get the anchors of this moving window
const AncList_t &movAnchors = (*itMov)->getAnchorList();
// Get the anchors in the main layout of this moving window
const AncList_t &movAnchors =
(*itMov)->getActiveLayout().getAnchorList();
// Iterate through the static windows
for( itSta = m_allWindows.begin();
......@@ -275,8 +279,9 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
continue;
}
// Get the anchors of this static window
const AncList_t &staAnchors = (*itSta)->getAnchorList();
// Get the anchors in the main layout of this static window
const AncList_t &staAnchors =
(*itSta)->getActiveLayout().getAnchorList();
// Check if there is an anchoring between one of the movAnchors
// and one of the staAnchors
......@@ -350,3 +355,18 @@ void WindowManager::hideTooltip()
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 @@
class GenericFont;
class GenericLayout;
class Anchor;
class Tooltip;
......@@ -102,6 +103,13 @@ class WindowManager: public SkinObject
/// Hide the tooltip window
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:
/// Some useful typedefs for lazy people like me
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