]> git.sesse.net Git - vlc/commitdiff
* skins2:
authorOlivier Teulière <ipkiss@videolan.org>
Sun, 28 Jan 2007 20:37:21 +0000 (20:37 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sun, 28 Jan 2007 20:37:21 +0000 (20:37 +0000)
    - new WindowID.maximize() and WindowID.unmaximize() actions
    - new WindowID.isMaximized boolean variable
    - doc updated

doc/skins/skins2-howto.xml
modules/gui/skins2/commands/cmd_minimize.cpp
modules/gui/skins2/commands/cmd_minimize.hpp
modules/gui/skins2/parser/interpreter.cpp
modules/gui/skins2/src/generic_window.cpp
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
modules/gui/skins2/utils/position.hpp

index 55db43dc2daca0a598e640e6777bc323258d2733..9d4eddbe94c5dbf474ba1641d76527857e714671 100644 (file)
@@ -995,6 +995,12 @@ difficulty to understand how VLC skins work.</para>
   <listitem><para>
     <emphasis>WindowID.hide()</emphasis>: Hide the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'.
   </para></listitem>
+  <listitem><para>
+    <emphasis>WindowID.maximize()</emphasis>: Maximize the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'. Since VLC 0.9.0.
+  </para></listitem>
+  <listitem><para>
+    <emphasis>WindowID.unmaximize()</emphasis>: Unmaximize the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID'. Since VLC 0.9.0.
+  </para></listitem>
   <listitem><para>
     <emphasis>WindowID.setLayout(LayoutID)</emphasis>: Change the layout of the <link linkend="Window">Window</link> whose <link linkend="windowid">id</link> attribute is 'WindowID', using the <link linkend="Layout">Layout</link> whose <link linkend="layoutid">id</link> attribute is 'LayoutID'.
   </para></listitem>
@@ -1097,6 +1103,9 @@ difficulty to understand how VLC skins work.</para>
   <listitem><para>
    <emphasis>dvd.isActive</emphasis>: True when a DVD is currently playing. This variable can be used to display buttons associated to the <link linkend="dvdactions">dvd.* actions</link> only when needed (since VLC 0.8.5).
   </para></listitem>
+  <listitem><para>
+    <emphasis>WindowID.isMaximized</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is maximized, false otherwise.
+  </para></listitem>
   <listitem><para>
     <emphasis>WindowID.isVisible</emphasis>: True when the window whose <link linkend="windowid">id</link> is "WindowID" is visible, false otherwise.
   </para></listitem>
index 815e6f6c15b1ff2e7aa17308f49eee2335caf849..043c440d087cff68b955a9cf2169393d431dd485 100644 (file)
@@ -5,6 +5,7 @@
  * $Id$
  *
  * Authors: Mohammed Adnène Trojette     <adn@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@
  *****************************************************************************/
 
 #include "cmd_minimize.hpp"
+#include "../src/window_manager.hpp"
 #include "../src/os_factory.hpp"
 
 
@@ -41,6 +43,38 @@ void CmdRestore::execute()
 }
 
 
+CmdMaximize::CmdMaximize( intf_thread_t *pIntf,
+                          WindowManager &rWindowManager,
+                          TopWindow &rWindow ):
+    CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ),
+    m_rWindow( rWindow )
+{
+}
+
+
+void CmdMaximize::execute()
+{
+    // Simply delegate the job to the WindowManager
+    m_rWindowManager.maximize( m_rWindow );
+}
+
+
+CmdUnmaximize::CmdUnmaximize( intf_thread_t *pIntf,
+                              WindowManager &rWindowManager,
+                              TopWindow &rWindow ):
+    CmdGeneric( pIntf ), m_rWindowManager( rWindowManager ),
+    m_rWindow( rWindow )
+{
+}
+
+
+void CmdUnmaximize::execute()
+{
+    // Simply delegate the job to the WindowManager
+    m_rWindowManager.unmaximize( m_rWindow );
+}
+
+
 void CmdAddInTray::execute()
 {
     // Get the instance of OSFactory
index 4748313a003337e3fd423de8f3883a97c7580f6c..14a72c372b209076e56edd2fc828c0bf84b4b1a4 100644 (file)
 
 #include "cmd_generic.hpp"
 
+class WindowManager;
+class TopWindow;
+
 
 DEFINE_COMMAND(Minimize, "minimize" )
 DEFINE_COMMAND(Restore, "restore" )
+
+/// Command to maximize a window
+class CmdMaximize: public CmdGeneric
+{
+    public:
+        /// Maximize the given layout
+        CmdMaximize( intf_thread_t *pIntf, WindowManager &rWindowManager,
+                     TopWindow &rWindow );
+        virtual ~CmdMaximize() {}
+
+        /// This method does the real job of the command
+        virtual void execute();
+
+        /// Return the type of the command
+        virtual string getType() const { return "maximize"; }
+
+    private:
+        WindowManager &m_rWindowManager;
+        TopWindow &m_rWindow;
+};
+
+
+/// Command to unmaximize a window
+class CmdUnmaximize: public CmdGeneric
+{
+    public:
+        /// Unmaximize the given layout
+        CmdUnmaximize( intf_thread_t *pIntf, WindowManager &rWindowManager,
+                     TopWindow &rWindow );
+        virtual ~CmdUnmaximize() {}
+
+        /// This method does the real job of the command
+        virtual void execute();
+
+        /// Return the type of the command
+        virtual string getType() const { return "unmaximize"; }
+
+    private:
+        WindowManager &m_rWindowManager;
+        TopWindow &m_rWindow;
+};
+
+
 DEFINE_COMMAND(AddInTray, "add in tray" )
 DEFINE_COMMAND(RemoveFromTray, "remove from tray" )
 DEFINE_COMMAND(AddInTaskBar, "add in taskbar" )
index 9ad32a57c8429bf81a202cfc1c9067839ddd1cb0..5f3ae2223c8a052468184be2a5b2a829ebc1858a 100644 (file)
@@ -225,6 +225,40 @@ CmdGeneric *Interpreter::parseAction( const string &rAction, Theme *pTheme )
             pCommand = new CmdLayout( getIntf(), *pWin, *pLayout );
         }
     }
+    else if( rAction.find( ".maximize()" ) != string::npos )
+    {
+        int leftPos = rAction.find( ".maximize()" );
+        string windowId = rAction.substr( 0, leftPos );
+
+        TopWindow *pWin = pTheme->getWindowById( windowId );
+        if( !pWin )
+        {
+            msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+        }
+        else
+        {
+            pCommand = new CmdMaximize( getIntf(),
+                                        pTheme->getWindowManager(),
+                                        *pWin );
+        }
+    }
+    else if( rAction.find( ".unmaximize()" ) != string::npos )
+    {
+        int leftPos = rAction.find( ".unmaximize()" );
+        string windowId = rAction.substr( 0, leftPos );
+
+        TopWindow *pWin = pTheme->getWindowById( windowId );
+        if( !pWin )
+        {
+            msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+        }
+        else
+        {
+            pCommand = new CmdUnmaximize( getIntf(),
+                                          pTheme->getWindowManager(),
+                                          *pWin );
+        }
+    }
     else if( rAction.find( ".show()" ) != string::npos )
     {
         int leftPos = rAction.find( ".show()" );
@@ -420,7 +454,25 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
                 }
                 else
                 {
-                    msg_Err( getIntf(), "unknown window (%s)", windowId.c_str() );
+                    msg_Err( getIntf(), "unknown window (%s)",
+                             windowId.c_str() );
+                    return NULL;
+                }
+            }
+            else if( token.find( ".isMaximized" ) != string::npos )
+            {
+                int leftPos = token.find( ".isMaximized" );
+                string windowId = token.substr( 0, leftPos );
+                TopWindow *pWin = pTheme->getWindowById( windowId );
+                if( pWin )
+                {
+                    // Push the "maximized" variable onto the stack
+                    varStack.push_back( &pWin->getMaximizedVar() );
+                }
+                else
+                {
+                    msg_Err( getIntf(), "unknown window (%s)",
+                             windowId.c_str() );
                     return NULL;
                 }
             }
@@ -436,7 +488,8 @@ VarBool *Interpreter::getVarBool( const string &rName, Theme *pTheme )
                 }
                 else
                 {
-                    msg_Err( getIntf(), "unknown layout (%s)", layoutId.c_str() );
+                    msg_Err( getIntf(), "unknown layout (%s)",
+                             layoutId.c_str() );
                     return NULL;
                 }
             }
index 2324185b309fb3ecab139adebfbfeb7c90510b8b..6cac77834fac02e090c352ec612c24041233abea 100644 (file)
@@ -129,13 +129,16 @@ void GenericWindow::toggleOnTop( bool onTop ) const
 
 void GenericWindow::onUpdate( Subject<VarBool> &rVariable, void*arg )
 {
-    if( m_pVarVisible->get() )
+    if (&rVariable == m_pVarVisible )
     {
-        innerShow();
-    }
-    else
-    {
-        innerHide();
+        if( m_pVarVisible->get() )
+        {
+            innerShow();
+        }
+        else
+        {
+            innerHide();
+        }
     }
 }
 
index 5089b6ac3e338e9c822cc30b9d9a1d4605a9bee1..f10b90cacc46e3d93772ced90585cd446c784328 100644 (file)
@@ -58,6 +58,10 @@ TopWindow::TopWindow( intf_thread_t *pIntf, int left, int top,
 {
     // Register as a moving window
     m_rWindowManager.registerWindow( *this );
+
+    // Create the "maximized" variable and register it in the manager
+    m_pVarMaximized = new VarBoolImpl( pIntf );
+    VarManager::instance( pIntf )->registerVar( VariablePtr( m_pVarMaximized ) );
 }
 
 
index a31bfee6901adaf6778408bfbf913eb29644c290..2f06dd2d052363476c932d6dd97a864a6b18e958 100644 (file)
@@ -78,6 +78,9 @@ class TopWindow: public GenericWindow
         /// Called by a control when its tooltip changed
         virtual void onTooltipChange( const CtrlGeneric &rCtrl );
 
+        /// Get the "maximized" variable
+        VarBool &getMaximizedVar() { return *m_pVarMaximized; }
+
         /// Get the initial visibility status
         bool isVisible() const { return m_visible; }
 
@@ -89,8 +92,13 @@ class TopWindow: public GenericWindow
         virtual void innerHide();
 
     private:
+        /**
+         * These methods are only used by the window manager
+         */
+        //@{
         /// Change the active layout
         virtual void setActiveLayout( GenericLayout *pLayout );
+        //@}
 
         /// Initial visibility status
         bool m_visible;
@@ -107,12 +115,19 @@ class TopWindow: public GenericWindow
         /// Current key modifier (also used for mouse)
         int m_currModifier;
 
-        /// Find the uppest control in the layout hit by the mouse, and send
-        /// it an enter event if needed
+        /// Variable for the visibility of the window
+        VarBoolImpl *m_pVarMaximized;
+
+        /**
+         * Find the uppest control in the layout hit by the mouse, and send
+         * it an enter event if needed
+         */
         CtrlGeneric *findHitControl( int xPos, int yPos );
 
-        /// Update the lastHitControl pointer and send a leave event to the
-        /// right control
+        /**
+         * Update the lastHitControl pointer and send a leave event to the
+         * right control
+         */
         void setLastHit( CtrlGeneric *pNewHitControl );
 };
 
index 904e06be9740d87bf07de04fb967b7493d317e4e..f7a268ea6fd6ba27d09d99b39f1bf29a9692d80b 100644 (file)
 #include "anchor.hpp"
 #include "tooltip.hpp"
 #include "var_manager.hpp"
-#include "../utils/position.hpp"
 
 
 WindowManager::WindowManager( intf_thread_t *pIntf ):
     SkinObject( pIntf ), m_magnet( 0 ), m_direction( kNone ),
+    m_maximizeRect(0, 0, 50, 50),
     m_pTooltip( NULL ), m_pPopup( NULL )
 {
     // Create and register a variable for the "on top" status
@@ -317,6 +317,50 @@ void WindowManager::resize( GenericLayout &rLayout,
 }
 
 
+void WindowManager::maximize( TopWindow &rWindow )
+{
+    // Save the current position/size of the window, to be able to restore it
+    m_maximizeRect = Rect( rWindow.getLeft(), rWindow.getTop(),
+                           rWindow.getLeft() + rWindow.getWidth(),
+                           rWindow.getTop() + rWindow.getHeight() );
+
+    Rect workArea = OSFactory::instance( getIntf() )->getWorkArea();
+    // Move the window
+    startMove( rWindow );
+    move( rWindow, workArea.getLeft(), workArea.getTop() );
+    stopMove();
+    // Now resize it
+    // FIXME: Ugly const_cast
+    GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout();
+    startResize( rLayout, kResizeSE );
+    resize( rLayout, workArea.getWidth(), workArea.getHeight() );
+    stopResize();
+    rWindow.m_pVarMaximized->set( true );
+
+    // Make the window unmovable by unregistering it
+//     unregisterWindow( rWindow );
+}
+
+
+void WindowManager::unmaximize( TopWindow &rWindow )
+{
+    // Register the window to allow moving it
+//     registerWindow( rWindow );
+
+    // Resize the window
+    // FIXME: Ugly const_cast
+    GenericLayout &rLayout = (GenericLayout&)rWindow.getActiveLayout();
+    startResize( rLayout, kResizeSE );
+    resize( rLayout, m_maximizeRect.getWidth(), m_maximizeRect.getHeight() );
+    stopResize();
+    // Now move it
+    startMove( rWindow );
+    move( rWindow, m_maximizeRect.getLeft(), m_maximizeRect.getTop() );
+    stopMove();
+    rWindow.m_pVarMaximized->set( false );
+}
+
+
 void WindowManager::synchVisibility() const
 {
     WinSet_t::const_iterator it;
index 8e7b47a7a2ccc572cbbcc6dbce83e106f7c9bd8e..74f839ebca3df6439c49017da6e18e2639211ac8 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "skin_common.hpp"
 #include "top_window.hpp"
+#include "../utils/position.hpp"
 #include <list>
 #include <map>
 #include <set>
@@ -88,13 +89,19 @@ class WindowManager: public SkinObject
         void stopResize();
 
         /**
-         * Resize the rWindow window to (width, height), and move all its
+         * Resize the rLayout layout to (width, height), and move all its
          * anchored windows, if some anchors are moved during the resizing.
          * If a new anchoring is detected, the windows will move (or resize)
          * accordingly.
          */
         void resize( GenericLayout &rLayout, int width, int height ) const;
 
+        /// Maximize the given window
+        void maximize( TopWindow &rWindow );
+
+        /// Unmaximize the given window
+        void unmaximize( TopWindow &rWindow );
+
         /// Raise all the registered windows
         void raiseAll() const;
 
@@ -201,6 +208,8 @@ class WindowManager: public SkinObject
         int m_moveAlpha;
         /// Direction of the current resizing
         Direction_t m_direction;
+        /// Rect of the last maximized window
+        Rect m_maximizeRect;
         /// Tooltip
         Tooltip *m_pTooltip;
         /// Active popup, if any
index 106e4b675d4b32798b13532341227bc8f6017911..a1ae5737fde97f000328934ce6452d21c76dd547 100644 (file)
@@ -59,6 +59,8 @@ class Rect: public GenericRect
 
         virtual int getLeft() const { return m_left; }
         virtual int getTop() const { return m_top; }
+        virtual int getRight() const { return m_right; }
+        virtual int getBottom() const { return m_bottom; }
         virtual int getWidth() const { return m_right - m_left; }
         virtual int getHeight() const { return m_bottom - m_top; }