/*
* ion/mod_tiling/split.c
*
- * Copyright (c) Tuomo Valkonen 1999-2006.
+ * 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>
void splittree_changeroot(WSplit *root, WSplit *node)
{
WTiling *ws=(WTiling*)(root->ws_if_root);
+
assert(ws!=NULL);
assert(ws->split_tree==root);
root->ws_if_root=NULL;
}
+/* 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)
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;
}
}
/*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