2023-01-16 15:58:57 -05:00
|
|
|
#include "fiber_pool.hpp"
|
2023-03-01 21:27:15 +00:00
|
|
|
#include "gui/components/components.hpp"
|
2023-11-16 08:17:46 -05:00
|
|
|
#include "misc/cpp/imgui_stdlib.h"
|
2023-01-16 15:58:57 -05:00
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
2023-11-16 08:17:46 -05:00
|
|
|
bool components::input_text(const std::string_view label, char* buf, size_t buf_size, ImGuiInputTextFlags_ flag, std::function<void()> cb)
|
2023-03-01 21:27:15 +00:00
|
|
|
{
|
2023-11-16 08:17:46 -05:00
|
|
|
bool retval = false;
|
2023-01-16 15:58:57 -05:00
|
|
|
if (ImGui::InputText(label.data(), buf, buf_size, flag))
|
2023-11-16 08:17:46 -05:00
|
|
|
{
|
2023-01-16 15:58:57 -05:00
|
|
|
if (cb)
|
|
|
|
g_fiber_pool->queue_job(std::move(cb));
|
2023-11-16 08:17:46 -05:00
|
|
|
retval = true;
|
|
|
|
}
|
2023-01-16 15:58:57 -05:00
|
|
|
|
|
|
|
if (ImGui::IsItemActive())
|
2023-09-17 16:23:26 -04:00
|
|
|
g.self.hud.typing = TYPING_TICKS;
|
2023-11-16 08:17:46 -05:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool components::input_text(const std::string_view label, std::string& buf, ImGuiInputTextFlags_ flag, std::function<void()> cb)
|
|
|
|
{
|
|
|
|
bool retval = false;
|
|
|
|
if (ImGui::InputText(label.data(), &buf, flag))
|
|
|
|
{
|
|
|
|
if (cb)
|
|
|
|
g_fiber_pool->queue_job(std::move(cb));
|
|
|
|
retval = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ImGui::IsItemActive())
|
|
|
|
g.self.hud.typing = TYPING_TICKS;
|
|
|
|
|
|
|
|
return retval;
|
2023-01-16 15:58:57 -05:00
|
|
|
}
|
|
|
|
}
|