]> git.sesse.net Git - vlc/commitdiff
* skins2: Anchors are now stored in the layouts, not in the windows.
authorOlivier Teulière <ipkiss@videolan.org>
Thu, 1 Apr 2004 21:04:43 +0000 (21:04 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Thu, 1 Apr 2004 21:04:43 +0000 (21:04 +0000)
   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.

12 files changed:
modules/gui/skins2/commands/cmd_layout.cpp
modules/gui/skins2/parser/builder.cpp
modules/gui/skins2/parser/builder_data.def
modules/gui/skins2/parser/builder_data.hpp
modules/gui/skins2/parser/skin_parser.cpp
modules/gui/skins2/src/anchor.hpp
modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/src/top_window.cpp
modules/gui/skins2/src/top_window.hpp
modules/gui/skins2/src/window_manager.cpp
modules/gui/skins2/src/window_manager.hpp

index 1e40b11fb035522a1eb747a7c08362aea562815d..d3dc423577c94f401929fcff59534f194d78ff11 100755 (executable)
@@ -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 );
 }
index 9f384606f14986387f2e3b400e4ee6f894df89a6..9326b4555607b93a2dd4a593ee0b754725f271ea 100755 (executable)
@@ -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 );
 }
 
 
index b60a224ef603d39c7ce2a4f3c7bd54d97ac28f7f..8a835ab0ce808adcf6b6005b3231846cfbc53573 100644 (file)
@@ -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
index e0ad5c002b3ac757c917b7b9b48d448d3186af64..28595049fb97ee8764496cebc30f66c42bdd1408 100644 (file)
@@ -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;
index d10a926a92f08095389fd6718fe2f60e6e4e93cd..d9d3661b9ae932e74930821d15716b4b4609416e 100644 (file)
@@ -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 );
     }
 
index 0f9ecafc66341d0c26d96f2ff82945bff2d40f4e..bfc5b5d2f8169c59da729c4d2487d50c75838b58 100644 (file)
@@ -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;
 };
 
 
index 2a5b1c4be20c63eab84d1cb81d9c6872f2949c35..7e025d18b6372c1fb4a29fd080fa16c922f97af7 100644 (file)
@@ -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 );
+}
+
index 9acd72216fedbace82d6171e0a3d288e78ffb6ff..64b3343154ab7ab4dda5743700b0e809574dce23 100644 (file)
 #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;
 };
 
 
index 2f5472fe22d4adf8b54ed6d824b986a2129f5142..7d7608867c035a6fbc8c549059dd53fb302e3536 100644 (file)
@@ -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
index f85f3d658733d5a70417a09bce0cd3f8c11ce990..e952e69da29ec7da1a10f8c152181cb83c95a030 100644 (file)
@@ -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;
 
index f386d86af58c451ecdd58aac7e3421f028372681..bbc5ca403b03a439d37be7111290ba7159adc908 100755 (executable)
@@ -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();
+}
index 7bd1a258baf47e9a3238e3b33bd542c45f41c2f9..fb14f6a5afcb746f4e07edda7ecb73ae41cff37f 100644 (file)
@@ -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;