@@ -165,7 +165,7 @@ contains |
| 165 | 165 | pivot_area%x = bounds%x |
| 166 | 166 | pivot_area%y = bounds%y |
| 167 | 167 | pivot_area%width = bounds%width |
| 168 | | - pivot_area%height = int((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%height, real64)) |
| 168 | + pivot_area%height = nint((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%height, real64)) |
| 169 | 169 | pivot_area%height = max(30, min(pivot_area%height, bounds%height - 30)) |
| 170 | 170 | |
| 171 | 171 | remaining_area%x = bounds%x |
@@ -175,7 +175,7 @@ contains |
| 175 | 175 | |
| 176 | 176 | else if (spiral_direction == 1) then |
| 177 | 177 | ! RIGHT: Pivot on right, remaining on left |
| 178 | | - pivot_area%width = int((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%width, real64)) |
| 178 | + pivot_area%width = nint((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%width, real64)) |
| 179 | 179 | pivot_area%width = max(30, min(pivot_area%width, bounds%width - 30)) |
| 180 | 180 | pivot_area%x = bounds%x + bounds%width - pivot_area%width |
| 181 | 181 | pivot_area%y = bounds%y |
@@ -188,7 +188,7 @@ contains |
| 188 | 188 | |
| 189 | 189 | else if (spiral_direction == 2) then |
| 190 | 190 | ! BOTTOM: Pivot at bottom, remaining above |
| 191 | | - pivot_area%height = int((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%height, real64)) |
| 191 | + pivot_area%height = nint((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%height, real64)) |
| 192 | 192 | pivot_area%height = max(30, min(pivot_area%height, bounds%height - 30)) |
| 193 | 193 | pivot_area%x = bounds%x |
| 194 | 194 | pivot_area%y = bounds%y + bounds%height - pivot_area%height |
@@ -203,7 +203,7 @@ contains |
| 203 | 203 | ! LEFT: Pivot on left, remaining on right |
| 204 | 204 | pivot_area%x = bounds%x |
| 205 | 205 | pivot_area%y = bounds%y |
| 206 | | - pivot_area%width = int((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%width, real64)) |
| 206 | + pivot_area%width = nint((real(pivot_size, real64) / real(total_size, real64)) * real(bounds%width, real64)) |
| 207 | 207 | pivot_area%width = max(30, min(pivot_area%width, bounds%width - 30)) |
| 208 | 208 | pivot_area%height = bounds%height |
| 209 | 209 | |
@@ -277,21 +277,26 @@ contains |
| 277 | 277 | ! Calculate dynamic minimum based on available space |
| 278 | 278 | ! If we have N items and W width, ensure each item gets at most W/N |
| 279 | 279 | available_space = bounds%width |
| 280 | | - dynamic_min = max(2, available_space / actual_num_nodes) ! At least 2 pixels |
| 281 | | - dynamic_min = min(dynamic_min, 10) ! But prefer 10 if space allows |
| 280 | + dynamic_min = max(1, available_space / actual_num_nodes) ! At least 1 pixel per item |
| 282 | 281 | |
| 283 | 282 | ! Stack left-to-right |
| 284 | 283 | offset = bounds%x |
| 285 | 284 | do i = 1, actual_num_nodes |
| 286 | 285 | if (i < actual_num_nodes) then |
| 287 | | - item_size = int((real(nodes(i)%size, real64) / real(actual_total_size, real64)) * real(bounds%width, real64)) |
| 286 | + ! Calculate proportional size |
| 287 | + item_size = nint((real(nodes(i)%size, real64) / real(actual_total_size, real64)) * real(bounds%width, real64)) |
| 288 | + ! Apply minimum, but check we won't overflow |
| 288 | 289 | item_size = max(dynamic_min, item_size) |
| 290 | + ! Ensure we don't exceed remaining space |
| 291 | + item_size = min(item_size, (bounds%x + bounds%width) - offset - (actual_num_nodes - i)) |
| 289 | 292 | else |
| 290 | | - ! Last item gets remaining space (prevents overflow) |
| 291 | | - item_size = bounds%x + bounds%width - offset |
| 292 | | - item_size = max(1, item_size) ! Ensure at least 1 pixel |
| 293 | + ! Last item gets ALL remaining space (prevents gaps/overlaps) |
| 294 | + item_size = (bounds%x + bounds%width) - offset |
| 293 | 295 | end if |
| 294 | 296 | |
| 297 | + ! Ensure at least 1 pixel |
| 298 | + item_size = max(1, item_size) |
| 299 | + |
| 295 | 300 | nodes(i)%bounds%x = offset |
| 296 | 301 | nodes(i)%bounds%y = bounds%y |
| 297 | 302 | nodes(i)%bounds%width = item_size |
@@ -302,21 +307,26 @@ contains |
| 302 | 307 | else |
| 303 | 308 | ! Calculate dynamic minimum based on available space |
| 304 | 309 | available_space = bounds%height |
| 305 | | - dynamic_min = max(1, available_space / actual_num_nodes) ! At least 1 pixel |
| 306 | | - dynamic_min = min(dynamic_min, 3) ! But prefer 3 if space allows |
| 310 | + dynamic_min = max(1, available_space / actual_num_nodes) ! At least 1 pixel per item |
| 307 | 311 | |
| 308 | 312 | ! Stack top-to-bottom |
| 309 | 313 | offset = bounds%y |
| 310 | 314 | do i = 1, actual_num_nodes |
| 311 | 315 | if (i < actual_num_nodes) then |
| 312 | | - item_size = int((real(nodes(i)%size, real64) / real(actual_total_size, real64)) * real(bounds%height, real64)) |
| 316 | + ! Calculate proportional size |
| 317 | + item_size = nint((real(nodes(i)%size, real64) / real(actual_total_size, real64)) * real(bounds%height, real64)) |
| 318 | + ! Apply minimum, but check we won't overflow |
| 313 | 319 | item_size = max(dynamic_min, item_size) |
| 320 | + ! Ensure we don't exceed remaining space |
| 321 | + item_size = min(item_size, (bounds%y + bounds%height) - offset - (actual_num_nodes - i)) |
| 314 | 322 | else |
| 315 | | - ! Last item gets remaining space (prevents overflow) |
| 316 | | - item_size = bounds%y + bounds%height - offset |
| 317 | | - item_size = max(1, item_size) ! Ensure at least 1 pixel |
| 323 | + ! Last item gets ALL remaining space (prevents gaps/overlaps) |
| 324 | + item_size = (bounds%y + bounds%height) - offset |
| 318 | 325 | end if |
| 319 | 326 | |
| 327 | + ! Ensure at least 1 pixel |
| 328 | + item_size = max(1, item_size) |
| 329 | + |
| 320 | 330 | nodes(i)%bounds%x = bounds%x |
| 321 | 331 | nodes(i)%bounds%y = offset |
| 322 | 332 | nodes(i)%bounds%width = bounds%width |