mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-09 12:37:41 +03:00
added hellwal and matugen generators (WIP)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "input_dialog.hpp"
|
||||
#include "imgui.h"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
namespace clrsync::gui::widgets
|
||||
{
|
||||
@@ -41,6 +42,21 @@ bool input_dialog::render()
|
||||
IM_ARRAYSIZE(m_input_buffer),
|
||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Browse"))
|
||||
{
|
||||
if (m_on_browse)
|
||||
{
|
||||
std::string initial = m_input_buffer;
|
||||
std::string res = m_on_browse(initial);
|
||||
if (!res.empty())
|
||||
{
|
||||
std::strncpy(m_input_buffer, res.c_str(), IM_ARRAYSIZE(m_input_buffer) - 1);
|
||||
m_input_buffer[IM_ARRAYSIZE(m_input_buffer) - 1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
ImGui::Spacing();
|
||||
@@ -108,4 +124,9 @@ void input_dialog::set_on_cancel(const std::function<void()> &callback)
|
||||
m_on_cancel = callback;
|
||||
}
|
||||
|
||||
void input_dialog::set_path_browse_callback(const std::function<std::string(const std::string &)> &callback)
|
||||
{
|
||||
m_on_browse = callback;
|
||||
}
|
||||
|
||||
} // namespace clrsync::gui::widgets
|
||||
@@ -18,6 +18,7 @@ class input_dialog
|
||||
|
||||
void set_on_submit(const std::function<void(const std::string &)> &callback);
|
||||
void set_on_cancel(const std::function<void()> &callback);
|
||||
void set_path_browse_callback(const std::function<std::string(const std::string &)> &callback);
|
||||
|
||||
bool is_open() const { return m_is_open; }
|
||||
|
||||
@@ -31,6 +32,7 @@ class input_dialog
|
||||
|
||||
std::function<void(const std::string &)> m_on_submit;
|
||||
std::function<void()> m_on_cancel;
|
||||
std::function<std::string(const std::string &)> m_on_browse;
|
||||
};
|
||||
|
||||
} // namespace clrsync::gui::widgets
|
||||
|
||||
Reference in New Issue
Block a user