| 338 | /////////////////////////////////////////// |
| 339 | |
| 340 | void ui_layout_pop() { |
| 341 | ui_layout_t* layout = &skui_layouts.last(); |
| 342 | |
| 343 | // Some tools for debugging layouts |
| 344 | /*static int32_t idx = 0; |
| 345 | static int32_t idx_show = 0; |
| 346 | static uint64_t last_frame = 0; |
| 347 | if (last_frame != time_frame()) { |
| 348 | idx = 0; |
| 349 | last_frame = time_frame(); |
| 350 | |
| 351 | if (input_key(key_left ) & button_state_just_active) idx_show--; |
| 352 | if (input_key(key_right) & button_state_just_active) idx_show++; |
| 353 | } |
| 354 | else { |
| 355 | idx++; |
| 356 | } |
| 357 | if (idx == idx_show) |
| 358 | idx = idx_show;*/ |
| 359 | |
| 360 | |
| 361 | // Move to next line if we're still on a previous line |
| 362 | if (layout->offset.x != layout->offset_initial.x) |
| 363 | ui_nextline(); |
| 364 | |
| 365 | float min_x = fminf(layout->child_min.x, layout->furthest.x ) - layout->margin; |
| 366 | float max_x = fmaxf(layout->child_max.x, layout->offset_initial.x) + layout->margin; |
| 367 | float min_y = fminf(layout->child_min.y, layout->furthest.y ) - layout->margin; |
| 368 | float max_y = fmaxf(layout->child_max.y, layout->offset_initial.y) + layout->margin; |
| 369 | if (layout->parent != -1) { |
| 370 | ui_layout_t* parent = &skui_layouts[layout->parent]; |
| 371 | if (min_x < parent->child_min.x) parent->child_min.x = min_x; |
| 372 | if (max_x > parent->child_max.x) parent->child_max.x = max_x; |
| 373 | if (max_y > parent->child_max.y) parent->child_max.y = max_y; |
| 374 | if (min_y < parent->child_min.y) parent->child_min.y = min_y; |
| 375 | } |
| 376 | |
| 377 | if (layout->window != -1) { |
| 378 | ui_window_t* win = &skui_windows[layout->window]; |
| 379 | vec2 final_size = { |
| 380 | layout->size.x == 0 ? layout->offset_initial.x - layout->furthest.x : layout->size.x, |
| 381 | layout->size.y == 0 ? layout->offset_initial.y - layout->furthest.y : layout->size.y }; |
| 382 | if (win->layout_size.x == 0) { |
| 383 | win->curr_size.x = fmaxf(win->curr_size.x, (max_x - min_x)); |
| 384 | } |
| 385 | if (win->layout_size.y == 0) { |
| 386 | win->curr_size.y = fmaxf(win->curr_size.y, (max_y - min_y)); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | // Store this as the most recent layout |
| 391 | ui_override_recent_layout( |
| 392 | { layout->offset_initial.x + layout->margin, layout->offset_initial.y + layout->margin, layout->offset_initial.z }, |
| 393 | { max_x - min_x, max_y - min_y }); |
| 394 | |
| 395 | // Other part of the tools for viewing layouts |
| 396 | //if (idx == idx_show) |
| 397 | // _ui_visualize_layout(layout); |
no test coverage detected