TODO(Wassim): we now just take the ms frame time from the game but this should be part of platform code at some point and the UI lib should take its own measurements.
| 763 | // be part of platform code at some point and the UI lib should take |
| 764 | // its own measurements. |
| 765 | void UI_begin_frame(UI_Context *ctx, u64 ms_since_last_frame) { |
| 766 | UI_assert(ctx != nullptr && "UI context *ctx is a null pointer!"); |
| 767 | UI_assert(ctx->initialized && "UI context wasn't initialized!"); |
| 768 | UI_assert(ctx->parents.count == 0); |
| 769 | // Manage previous frame:///////////////////// |
| 770 | v2 mouse = UI_get_mouse(); |
| 771 | v2 mouse_delta = UI_get_mouse_delta(); |
| 772 | ctx->want_capture_keyboard = false; |
| 773 | ctx->want_capture_mouse = false; |
| 774 | ctx->last_frame_time = ms_since_last_frame; |
| 775 | bool touched_a_block = false; |
| 776 | i32 current_focused_block_id = 0; |
| 777 | int freed = 0; |
| 778 | |
| 779 | |
| 780 | // New frame:////////////////////////////////// |
| 781 | //UI_set_cursor(Cursor_Type_arrow); |
| 782 | ctx->buffer_index = 1 - ctx->buffer_index; |
| 783 | ctx->frame_id++; |
| 784 | ctx->unique_counter = 0; |
| 785 | ctx->strings.count = 0; |
| 786 | UI_get_current_frame_buffer(ctx)->count = 0; |
| 787 | |
| 788 | // Reset the tree |
| 789 | ctx->viewport = _v2(get_client_size()); |
| 790 | ctx->vertices.reset_count(); |
| 791 | } |
| 792 | |
| 793 | void UI_preorder_traversal( |
| 794 | UI_Block* block, |
no test coverage detected