]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/sizepolicy.c
Imported Upstream version 20090110
[ion3.git] / ioncore / sizepolicy.c
index 8801df7efc150bbf8b56fae87af1127710ae2bd3..8c42327669236d6e5b56f08f1dd733e4b130bf14 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ion/ioncore/sizepolicy.c
  *
- * Copyright (c) Tuomo Valkonen 1999-2008
+ * Copyright (c) Tuomo Valkonen 1999-2009
  *
  * See the included file LICENSE for details.
  */
@@ -268,9 +268,24 @@ void sizepolicy(WSizePolicy *szplcy, WRegion *reg,
         break;
         
     case SIZEPOLICY_FREE:
+        if(reg!=NULL)
+            region_size_hints_correct(reg, &tmp.w, &tmp.h, FALSE);
         rectangle_constrain(&tmp, &(fp->g));
+        fp->g=tmp;
+        break;
+        
+    case SIZEPOLICY_VISIBILITY_CONSTRAINED:
         if(reg!=NULL)
             region_size_hints_correct(reg, &tmp.w, &tmp.h, FALSE);
+        { 
+            /* Constraint such that at least min(size, CF_VISIBILITY_CONSTRAINT) 
+             * much is visible at each border.
+             */
+            int dx=maxof(0, tmp.w-CF_VISIBILITY_CONSTRAINT);
+            int dy=maxof(0, tmp.h-CF_VISIBILITY_CONSTRAINT);
+            tmp.x=maxof(fp->g.x-dx, minof(tmp.x, fp->g.x+fp->g.w+dx-tmp.w));
+            tmp.y=maxof(fp->g.y-dy, minof(tmp.y, fp->g.y+fp->g.h+dy-tmp.h));
+        }
         fp->g=tmp;
         break;
         
@@ -321,6 +336,8 @@ static StringIntMap szplcy_specs[] = {
     {"free_glue_southwest",  SIZEPOLICY_FREE_GLUE__SOUTHWEST},
     {"free_glue_south",      SIZEPOLICY_FREE_GLUE__SOUTH},
     {"free_glue_southeast",  SIZEPOLICY_FREE_GLUE__SOUTHEAST},
+    {"visibility_constrained",   SIZEPOLICY_VISIBILITY_CONSTRAINED},
+    {"unconstrained",   SIZEPOLICY_UNCONSTRAINED},
     { NULL,             SIZEPOLICY_DEFAULT}   /* end marker */
 };