]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/window_manager.cpp
Qt: iconView delegate: encode PLModel::IsCurrent(QModelIndex) into cache key
[vlc] / modules / gui / skins2 / src / window_manager.cpp
index ccc42ff3bd5917d82f73bbf4444a1291e132c602..ed01b0612b1895d5f801e3f236e09a6450905ece 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
@@ -71,7 +71,6 @@ void WindowManager::startMove( TopWindow &rWindow )
     m_movingWindows.clear();
     buildDependSet( m_movingWindows, &rWindow );
 
-#ifdef WIN32
     if( config_GetInt( getIntf(), "skins2-transparency" ) )
     {
         // Change the opacity of the moving windows
@@ -89,7 +88,6 @@ void WindowManager::startMove( TopWindow &rWindow )
             (*it)->refresh( 0, 0, (*it)->getWidth(), (*it)->getHeight() );
         }
     }
-#endif
 }
 
 
@@ -98,7 +96,6 @@ void WindowManager::stopMove()
     WinSet_t::const_iterator itWin1, itWin2;
     AncList_t::const_iterator itAnc1, itAnc2;
 
-#ifdef WIN32
     if( config_GetInt( getIntf(), "skins2-transparency" ) )
     {
         // Restore the opacity of the moving windows
@@ -108,7 +105,6 @@ void WindowManager::stopMove()
             (*it)->setOpacity( m_alpha );
         }
     }
-#endif
 
     // Delete the dependencies
     m_dependencies.clear();
@@ -317,6 +313,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 = SkinsRect( rWindow.getLeft(), rWindow.getTop(),
+                               rWindow.getLeft() + rWindow.getWidth(),
+                               rWindow.getTop() + rWindow.getHeight() );
+
+    SkinsRect 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;
@@ -385,7 +425,6 @@ void WindowManager::showAll( bool firstTime ) const
         {
             (*it)->show();
         }
-        (*it)->setOpacity( m_alpha );
     }
 }
 
@@ -442,7 +481,7 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
     AncList_t::const_iterator itAncMov, itAncSta;
 
     // Check magnetism with screen edges first (actually it is the work area)
-    Rect workArea = OSFactory::instance( getIntf() )->getWorkArea();
+    SkinsRect workArea = OSFactory::instance( getIntf() )->getWorkArea();
     // Iterate through the moving windows
     for( itMov = m_movingWindows.begin();
          itMov != m_movingWindows.end(); itMov++ )
@@ -465,17 +504,17 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
         {
             yOffset = workArea.getTop() - (*itMov)->getTop();
         }
-        if( newLeft + (*itMov)->getWidth() > workArea.getRight() - m_magnet &&
-            newLeft + (*itMov)->getWidth() < workArea.getRight() + m_magnet )
+        int right = workArea.getLeft() + workArea.getWidth();
+        if( newLeft + (*itMov)->getWidth() > right - m_magnet &&
+            newLeft + (*itMov)->getWidth() < right + m_magnet )
         {
-            xOffset = workArea.getRight() - (*itMov)->getLeft()
-                      - (*itMov)->getWidth();
+            xOffset = right - (*itMov)->getLeft() - (*itMov)->getWidth();
         }
-        if( newTop + (*itMov)->getHeight() > workArea.getBottom() - m_magnet &&
-            newTop + (*itMov)->getHeight() <  workArea.getBottom() + m_magnet )
+        int bottom = workArea.getTop() + workArea.getHeight();
+        if( newTop + (*itMov)->getHeight() > bottom - m_magnet &&
+            newTop + (*itMov)->getHeight() <  bottom + m_magnet )
         {
-            yOffset =  workArea.getBottom() - (*itMov)->getTop()
-                       - (*itMov)->getHeight();
+            yOffset =  bottom - (*itMov)->getTop() - (*itMov)->getHeight();
         }
     }
 
@@ -595,3 +634,4 @@ void WindowManager::setActiveLayout( TopWindow &rWindow,
     // Rebuild the dependencies
     stopMove();
 }
+