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