[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kwin-tiling/tilinglayouts/spiral
From:       Nikhil Shantanu Marathe <nsm.nikhil () gmail ! com>
Date:       2009-12-20 15:49:50
Message-ID: 1261324190.744616.5194.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1064308 by nikhilm:

Implemented working spiral layout with floating support. Or rather, committed what I \
should have committed some time ago, and did it after adding floating support

 M  +38 -41    spiral.cpp  
 M  +4 -5      spiral.h  


--- branches/work/kwin-tiling/tilinglayouts/spiral/spiral.cpp #1064307:1064308
@@ -26,56 +26,53 @@
 namespace KWin
 {
 
-Spiral::Spiral() : TilingLayout()
+Spiral::Spiral( const Workspace *w )
+    : TilingLayout( w )
     {
-    m_split = NULL;
-    m_orientation = Qt::Vertical;
-    m_cycle = 2;
     }
-        
-void Spiral::addTile( Tile *t )
+
+Spiral::~Spiral()
     {
-    if( root() == NULL )
-        {
-        setRoot( t );
-        return;
-        }
+    }
 
-    if( m_split == NULL )
-        m_split = root();
+void Spiral::arrange( QRect wgeom )
+    {
+    int i = 1;
+    int n = tiles().length();
 
-    if( m_cycle == 0 || m_cycle == 1 )
+    /* TODO Can be made much better */
+    foreach( Tile *t, tiles() )
+        if( t->floating() )
+            n--;
+
+    foreach( Tile *t, tiles() )
         {
-        m_split->split( t, m_orientation, 0.5, Tile::Left );
-        m_split = m_split->left();
-        }
-    else
-        {
-        m_split->split( t, m_orientation, 0.5, Tile::Right );
-        m_split = m_split->right();
-        }
+        if( t->floating() )
+            continue;
 
-    if( t->floating() )
-        return;
+        if( i < n )
+            {
+            if( i % 2 == 0 )
+                wgeom.setHeight( wgeom.height() / 2 );
+            else
+                wgeom.setWidth( wgeom.width() / 2 );
+            }
 
-    m_cycle++;
-    m_cycle %= 4;
-    if( m_orientation == Qt::Vertical )
-        m_orientation = Qt::Horizontal;
-    else
-        m_orientation = Qt::Vertical;
-    }
+        if( i % 4 == 0 )
+            wgeom.moveLeft( wgeom.x() - wgeom.width() );
+        else if( i % 2 == 0 || ( i % 4 == 3 && i < n ) )
+            wgeom.moveLeft( wgeom.x() + wgeom.width() );
 
-void Spiral::removeTile( Tile *t )
-    {
-    m_split = t->parent();
+        if( i % 4 == 1 && i != 1 )
+            wgeom.moveTop( wgeom.y() - wgeom.height() );
+        else if( i % 2 == 1 && i != 1 
+                || ( i % 4 == 0 && i < n ) )
+            wgeom.moveTop( wgeom.y() + wgeom.height() );
 
-    if( !m_split || t->floating() )
-        return;
-
-    m_cycle--;
-    m_cycle = ( 4 + m_cycle )%4;
-    m_orientation = m_split->orientation();
+        kDebug(1212) << "Setting geom of " << t->client()->caption() << "to" << \
wgeom; +        t->setGeometry( wgeom );
+        t->commit();
+        i++;
+        }
     }
-        
 }
--- branches/work/kwin-tiling/tilinglayouts/spiral/spiral.h #1064307:1064308
@@ -27,23 +27,22 @@
 
 namespace KWin
 {
+class Workspace;
 class Tile;
 class Client;
 
 class Spiral : public TilingLayout
     {
     public:
-        Spiral();
+        Spiral( const Workspace * );
+        ~Spiral();
         
         void addTile( Tile *t );
         void removeTile( Tile *t );
         
     private:
-        Tile *m_split;
+        void arrange( QRect wgeom );
 
-        int m_cycle; // between 0-3, 0 & 1 split left, 2 & 3, split right
-        Qt::Orientation m_orientation; // toggles between vertical and horizontal
-
     };
 } // end namespace
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic