Fix T38602: Aligned layout breaks if panel too wide
[blender.git] / source / blender / editors / interface / interface.c
index 99d97e9d500ed2d5eca43c50a5a4802c087513cd..8751741a58a690285a6219d4dee67b0145c08f3e 100644 (file)
@@ -2671,9 +2671,17 @@ void uiBlockBeginAlign(uiBlock *block)
 static bool buts_are_horiz(uiBut *but1, uiBut *but2)
 {
        float dx, dy;
-       
-       dx = fabs(but1->rect.xmax - but2->rect.xmin);
-       dy = fabs(but1->rect.ymin - but2->rect.ymax);
+
+       /* simple case which can fail if buttons shift apart
+        * with proportional layouts, see: [#38602] */
+       if ((but1->rect.ymin == but2->rect.ymin) &&
+           (but1->rect.xmin != but2->rect.xmin))
+       {
+               return true;
+       }
+
+       dx = fabsf(but1->rect.xmax - but2->rect.xmin);
+       dy = fabsf(but1->rect.ymin - but2->rect.ymax);
        
        return (dx <= dy);
 }