]> git.decadent.org.uk Git - ion3.git/blobdiff - mod_tiling/split.c
[svn-upgrade] Integrating new upstream version, ion3 (20070506)
[ion3.git] / mod_tiling / split.c
index 381bbb3ea4e2d499c9b066a9bd278792a6475884..d05cc587153731cb46dd95a212756a4ac003c041 100644 (file)
@@ -3,10 +3,7 @@
  *
  * Copyright (c) Tuomo Valkonen 1999-2007. 
  *
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
  */
 
 #include <limits.h>
@@ -1341,6 +1338,11 @@ WSplit *split_current_todir(WSplit *node, WPrimn hprimn, WPrimn vprimn,
 }
 
 
+/* Note: both hprimn and vprimn are inverted when descending.  Therefore
+ * one should be either PRIMN_NONE or PRIMN_ANY for sensible geometric 
+ * navigation. (Both are PRIMN_TL or PRIMN_BR for pseudo-linear 
+ * next/previous navigation.)
+ */
 WSplit *splitsplit_nextto(WSplitSplit *node, WSplit *child,
                           WPrimn hprimn, WPrimn vprimn, 
                           WSplitFilter *filter)
@@ -1348,26 +1350,21 @@ WSplit *splitsplit_nextto(WSplitSplit *node, WSplit *child,
     WPrimn primn=(node->dir==SPLIT_HORIZONTAL ? hprimn : vprimn);
     WSplit *split=NULL, *nnode=NULL;
     
-    if(node->tl==child && (primn==PRIMN_BR || primn==PRIMN_ANY)){
+    if(node->tl==child && (primn==PRIMN_BR || primn==PRIMN_ANY))
         split=node->br;
-        primn=PRIMN_TL;
-    }else if(node->br==child && (primn==PRIMN_TL || primn==PRIMN_ANY)){
+    else if(node->br==child && (primn==PRIMN_TL || primn==PRIMN_ANY))
         split=node->tl;
-        primn=PRIMN_BR;
-    }
     
     if(split!=NULL){
-        if(node->dir==SPLIT_HORIZONTAL){
-            hprimn=primn;
-            vprimn=primn_none2any(vprimn);
-        }else{
-            vprimn=primn;
-            hprimn=primn_none2any(vprimn);
-        }
-        
-        nnode=split_current_todir(split, hprimn, vprimn, filter);
+        nnode=split_current_todir(split, 
+                                  primn_none2any(primn_invert(hprimn)),
+                                  primn_none2any(primn_invert(vprimn)),
+                                  filter);
     }
-   
+    
+    if(nnode==NULL)
+        nnode=split_nextto((WSplit*)node, hprimn, vprimn, filter);
+        
     return nnode;
 }
 
@@ -1818,8 +1815,8 @@ WSplit *splitsplit_br(WSplitSplit *split)
 }
 
 /*EXTL_DOC
- * Returns the direction of \var{split}; either ''vertical'' or
- * ''horizontal''.
+ * Returns the direction of \var{split}; either \codestr{vertical} or
+ * \codestr{horizontal}.
  */
 EXTL_SAFE
 EXTL_EXPORT_MEMBER