summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui/filesel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/filesel.h')
-rw-r--r--src/frontend/mame/ui/filesel.h71
1 files changed, 46 insertions, 25 deletions
diff --git a/src/frontend/mame/ui/filesel.h b/src/frontend/mame/ui/filesel.h
index 3b09244ca20..6ca9cafbe68 100644
--- a/src/frontend/mame/ui/filesel.h
+++ b/src/frontend/mame/ui/filesel.h
@@ -15,6 +15,15 @@
#include "ui/menu.h"
+#include <functional>
+#include <optional>
+#include <string>
+#include <string_view>
+#include <tuple>
+#include <utility>
+#include <vector>
+
+
namespace ui {
// ======================> menu_file_selector
@@ -31,22 +40,26 @@ public:
FILE
};
+ using handler_function = std::function<void (result result, std::string &&directory, std::string &&file)>;
+
menu_file_selector(
mame_ui_manager &mui,
render_container &container,
device_image_interface *image,
- std::string &current_directory,
- std::string &current_file,
+ std::string_view directory,
+ std::string_view file,
bool has_empty,
bool has_softlist,
bool has_create,
- result &result);
+ handler_function &&handler);
virtual ~menu_file_selector() override;
protected:
- virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
- virtual bool custom_ui_cancel() override { return !m_filename.empty(); }
- virtual bool custom_mouse_down() override;
+ virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override;
+ virtual void custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
+ virtual bool custom_ui_back() override { return !m_filename.empty(); }
+ virtual std::tuple<int, bool, bool> custom_pointer_updated(bool changed, ui_event const &uievt) override;
+ virtual void menu_activated() override;
private:
enum file_selector_entry_type
@@ -71,19 +84,22 @@ private:
};
// internal state
- device_image_interface *const m_image;
- std::string & m_current_directory;
- std::string & m_current_file;
- bool const m_has_empty;
- bool const m_has_softlist;
- bool const m_has_create;
- result & m_result;
+ handler_function const m_handler;
+ device_image_interface *const m_image;
+ std::string m_current_directory;
+ std::string m_current_file;
+ std::optional<text_layout> m_path_layout;
+ std::pair<float, float> m_path_position;
+ result m_result;
+ bool const m_has_empty;
+ bool const m_has_softlist;
+ bool const m_has_create;
std::vector<file_selector_entry> m_entrylist;
- std::string m_hover_directory;
- std::string m_filename;
+ std::string m_filename;
+ std::pair<size_t, size_t> m_clicked_directory;
- virtual void populate(float &customtop, float &custombottom) override;
- virtual void handle(event const *ev) override;
+ virtual void populate() override;
+ virtual bool handle(event const *ev) override;
// methods
file_selector_entry &append_entry(file_selector_entry_type entry_type, const std::string &entry_basename, const std::string &entry_fullpath);
@@ -91,7 +107,8 @@ private:
file_selector_entry *append_dirent_entry(const osd::directory::entry *dirent);
void append_entry_menu_item(const file_selector_entry *entry);
void select_item(const file_selector_entry &entry);
- void type_search_char(char32_t ch);
+ void update_search();
+ std::pair<size_t, size_t> get_directory_range(float x, float y);
};
@@ -108,23 +125,27 @@ public:
WRITE_OTHER,
WRITE_DIFF
};
+
+ using handler_function = std::function<void (result result)>;
+
menu_select_rw(
mame_ui_manager &mui,
render_container &container,
bool can_in_place,
- result &result);
+ handler_function &&handler);
virtual ~menu_select_rw() override;
+private:
+ virtual void populate() override;
+ virtual bool handle(event const *ev) override;
+
static void *itemref_from_result(result result);
static result result_from_itemref(void *itemref);
-private:
- virtual void populate(float &customtop, float &custombottom) override;
- virtual void handle(event const *ev) override;
-
// internal state
- bool m_can_in_place;
- result & m_result;
+ handler_function const m_handler;
+ bool const m_can_in_place;
+ result m_result;
};
} // namespace ui