]> granicus.if.org Git - graphviz/commitdiff
consistently use float literals in glCompCalcWidget
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 19 May 2021 03:17:38 +0000 (20:17 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 29 May 2021 01:51:23 +0000 (18:51 -0700)
This is more reliable and predictable than the mixture of floats and implicit
conversion from ints that was happening previously.

lib/glcomp/glutils.c

index 5c7f15fecd9605c2a11c2986516b78d6f939334b..bea79c49aa9189f643cd9cea7525d35c49dafe73 100644 (file)
@@ -316,15 +316,15 @@ void glCompCalcWidget(glCompCommon * parent, glCompCommon * child,
        return;
     }
     if (parent->borderType == glBorderNone)
-       borderWidth = 0;
+       borderWidth = 0.0f;
     else
        borderWidth = parent->borderWidth;
     if (child->align != glAlignNone)   //if alignment, make sure width and height is no greater than parent
     {
        if (child->width > parent->width)
-           ref->width = parent->width - (float) 2.0 *borderWidth;
+           ref->width = parent->width - 2.0f *borderWidth;
        if (child->height > parent->height)
-           ref->height = parent->height - (float) 2.0 *borderWidth;;
+           ref->height = parent->height - 2.0f *borderWidth;;
 
     }
 
@@ -336,13 +336,13 @@ void glCompCalcWidget(glCompCommon * parent, glCompCommon * child,
     case glAlignLeft:
        ref->pos.x = parent->refPos.x + borderWidth;
        ref->pos.y = parent->refPos.y + borderWidth;
-       ref->height = parent->height - 2 * borderWidth;
+       ref->height = parent->height - 2.0f * borderWidth;
        break;
     case glAlignRight:
        ref->pos.x =
            parent->refPos.x + parent->width - child->width - borderWidth;
        ref->pos.y = parent->refPos.y + borderWidth;
-       ref->height = parent->height - 2 * borderWidth;
+       ref->height = parent->height - 2.0f * borderWidth;
        break;
 
     case glAlignTop:
@@ -350,19 +350,19 @@ void glCompCalcWidget(glCompCommon * parent, glCompCommon * child,
            parent->refPos.y + parent->height - child->height -
            borderWidth;
        ref->pos.x = parent->refPos.x;
-       ref->width = parent->width - 2 * borderWidth;
+       ref->width = parent->width - 2.0f * borderWidth;
        break;
 
     case glAlignBottom:
        ref->pos.y = parent->refPos.y + borderWidth;
        ref->pos.x = parent->refPos.x + borderWidth;
-       ref->width = parent->width - 2 * borderWidth;
+       ref->width = parent->width - 2.0f * borderWidth;
        break;
     case glAlignParent:
        ref->pos.y = parent->refPos.y + borderWidth;
        ref->pos.x = parent->refPos.x + borderWidth;;
-       ref->width = parent->width - 2 * borderWidth;;
-       ref->height = parent->height - 2 * borderWidth;
+       ref->width = parent->width - 2.0f * borderWidth;;
+       ref->height = parent->height - 2.0f * borderWidth;
        break;
     case glAlignCenter:
     case glAlignNone: