Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/core/include/imgui_backend.hpp

59 lines
1.9 KiB
C++
Raw Normal View History

2021-04-20 10:37:56 -04:00
#pragma once
2021-10-11 13:39:15 -04:00
#include <filesystem>
#include <functional>
2022-08-15 11:04:11 -04:00
#include <string_view>
#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);
void render();
void process_move(platform::window_ptr identifier);
void process_resize(platform::window_ptr identifier);
2021-04-20 10:37:56 -04:00
void process_mouse_down(int button);
2021-04-20 10:37:56 -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);
void process_text_input(std::string_view string);
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.
*/
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);
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;
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