55 lines
No EOL
1.8 KiB
C++
55 lines
No EOL
1.8 KiB
C++
#pragma once
|
|
|
|
#include <string_view>
|
|
#include <filesystem>
|
|
#include <functional>
|
|
|
|
#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<void(std::string)> 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<void(std::string)> 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<void(std::string)> return_function;
|
|
};
|
|
|
|
dialog_data open_dialog_data;
|
|
dialog_data save_dialog_data;
|
|
};
|
|
} |