diff options
Diffstat (limited to 'include/gui/FileChooser.hpp')
-rw-r--r-- | include/gui/FileChooser.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/include/gui/FileChooser.hpp b/include/gui/FileChooser.hpp new file mode 100644 index 0000000..b8ea23e --- /dev/null +++ b/include/gui/FileChooser.hpp @@ -0,0 +1,35 @@ +#pragma once + +#include "Widget.hpp" +#include <functional> +#include <vector> + +#include <mglpp/graphics/Text.hpp> +#include <mglpp/system/Clock.hpp> + +// This currently only supports displaying folders +// TODO: Support files as well + +namespace gsr { + class FileChooser : public Widget { + public: + FileChooser(const char *start_directory, mgl::vec2f content_size); + FileChooser(const FileChooser&) = delete; + FileChooser& operator=(const FileChooser&) = delete; + + bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override; + void draw(mgl::Window &window, mgl::vec2f offset) override; + + mgl::vec2f get_size() override; + + void set_current_directory(const char *directory); + private: + mgl::vec2f content_size; + mgl::Text current_directory_text; + int mouse_over_item = -1; + int selected_item = -1; + std::vector<mgl::Text> folders; + mgl::Clock double_click_timer; + int times_clicked_within_timer = 0; + }; +}
\ No newline at end of file |