2021-04-20 10:37:56 -04:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-11 13:39:15 -04:00
|
|
|
#include <filesystem>
|
2021-10-12 10:27:03 -04:00
|
|
|
#include <functional>
|
2022-08-15 11:04:11 -04:00
|
|
|
#include <string_view>
|
2021-10-07 17:46:28 -04:00
|
|
|
|
2021-10-12 10:22:16 -04:00
|
|
|
#include "platform.hpp"
|
|
|
|
|
2021-04-20 10:37:56 -04:00
|
|
|
namespace prism {
|
|
|
|
class imgui_backend {
|
|
|
|
public:
|
|
|
|
imgui_backend();
|
|
|
|
|
|
|
|
void begin_frame(float delta_time);
|
|
|
|
|
2021-10-12 10:22:16 -04:00
|
|
|
void render();
|
|
|
|
|
|
|
|
void process_move(platform::window_ptr identifier);
|
2021-10-12 11:06:59 -04:00
|
|
|
void process_resize(platform::window_ptr identifier);
|
2021-04-20 10:37:56 -04:00
|
|
|
|
2021-05-11 17:05:29 -04:00
|
|
|
void process_mouse_down(int button);
|
2021-04-20 10:37:56 -04:00
|
|
|
|
2021-05-11 17:05:29 -04:00
|
|
|
void process_key_down(unsigned int key_code);
|
2021-04-20 10:37:56 -04:00
|
|
|
void process_key_up(unsigned int key_code);
|
2021-05-11 17:05:29 -04:00
|
|
|
|
2021-10-12 10:22:16 -04:00
|
|
|
void process_text_input(std::string_view string);
|
2021-10-07 17:46:28 -04:00
|
|
|
|
2021-10-11 13:39:15 -04:00
|
|
|
/**Opens a file dialog to select a file. This will not block.
|
|
|
|
@param existing Whether or not to limit to existing files.
|
2022-08-15 11:04:11 -04:00
|
|
|
@param returnFunction The callback function when a file is selected or the dialog is cancelled. An empy string
|
|
|
|
is returned when cancelled.
|
2021-10-11 13:39:15 -04:00
|
|
|
@param openDirectory Whether or not to allow selecting directories as well.
|
|
|
|
*/
|
2021-10-12 10:22:16 -04:00
|
|
|
void open_dialog(bool existing, std::function<void(std::string)> returnFunction, bool openDirectory = false);
|
2021-10-11 13:39:15 -04:00
|
|
|
|
|
|
|
/**Opens a file dialog to select a save location for a file. This will not block.
|
2022-08-15 11:04:11 -04:00
|
|
|
@param returnFunction The callback function when a file is selected or the dialog is cancelled. An empy string
|
|
|
|
is returned when cancelled.
|
2021-10-11 13:39:15 -04:00
|
|
|
*/
|
|
|
|
void save_dialog(std::function<void(std::string)> returnFunction);
|
|
|
|
|
2021-05-11 17:05:29 -04:00
|
|
|
private:
|
|
|
|
bool mouse_buttons[3] = {};
|
2021-10-11 13:39:15 -04:00
|
|
|
|
|
|
|
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<void(std::string)> return_function;
|
2022-02-01 20:53:47 +00:00
|
|
|
bool select_directory = false;
|
2021-10-11 13:39:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
dialog_data open_dialog_data;
|
|
|
|
dialog_data save_dialog_data;
|
2021-04-20 10:37:56 -04:00
|
|
|
};
|
2022-08-15 11:04:11 -04:00
|
|
|
} // namespace prism
|