#pragma once #include #include #include #include "platform.hpp" namespace prism { class imgui_backend { public: imgui_backend(); void begin_frame(float delta_time); void render(); void process_move(platform::window_ptr identifier); void process_resize(platform::window_ptr identifier); void process_mouse_down(int button); void process_key_down(unsigned int key_code); void process_key_up(unsigned int key_code); void process_text_input(std::string_view string); /**Opens a file dialog to select a file. This will not block. @param existing Whether or not to limit to existing files. @param returnFunction The callback function when a file is selected or the dialog is cancelled. An empy string is returned when cancelled. @param openDirectory Whether or not to allow selecting directories as well. */ void open_dialog(bool existing, std::function returnFunction, bool openDirectory = false); /**Opens a file dialog to select a save location for a file. This will not block. @param returnFunction The callback function when a file is selected or the dialog is cancelled. An empy string is returned when cancelled. */ void save_dialog(std::function returnFunction); private: bool mouse_buttons[3] = {}; bool open_dialog_next_frame = false; bool save_dialog_next_frame = false; struct dialog_data { std::filesystem::path current_path; std::filesystem::path selected_path; std::function return_function; bool select_directory = false; }; dialog_data open_dialog_data; dialog_data save_dialog_data; }; } // namespace prism