2025-10-09 11:47:07 +03:00
|
|
|
#include "ImGui.hpp"
|
|
|
|
|
|
2025-10-10 02:50:34 +03:00
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
|
|
#include <raylib.h>
|
|
|
|
|
|
2025-10-09 11:47:07 +03:00
|
|
|
ImGui::ImGui(std::shared_ptr<TextRenderer> text_renderer)
|
|
|
|
|
: m_text_renderer(text_renderer)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-10 02:50:34 +03:00
|
|
|
void ImGui::begin(u32 const rune, bool ctrl, bool shift)
|
2025-10-09 11:47:07 +03:00
|
|
|
{
|
2025-10-10 02:50:34 +03:00
|
|
|
m_rune = rune;
|
2025-10-09 11:47:07 +03:00
|
|
|
m_ctrl = ctrl;
|
|
|
|
|
m_shift = shift;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImGui::end() { }
|
|
|
|
|
|
|
|
|
|
auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec,
|
|
|
|
|
TextInputOptions options) -> std::bitset<2>
|
|
|
|
|
{
|
2025-10-10 02:50:34 +03:00
|
|
|
assert(id != 0);
|
|
|
|
|
|
2025-10-09 11:47:07 +03:00
|
|
|
bool submitted { false };
|
|
|
|
|
bool changed { false };
|
|
|
|
|
|
2025-10-10 02:50:34 +03:00
|
|
|
if (!m_ti_states.contains(id)) {
|
|
|
|
|
m_ti_states[id] = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(!options.multiline && "Multiline not yet implemented.");
|
|
|
|
|
|
|
|
|
|
if (options.font_size > rec.height) {
|
|
|
|
|
TraceLog(LOG_WARNING,
|
|
|
|
|
std::format("Text size for text input {} is bigger than height ({} "
|
|
|
|
|
"> {}). Clipping will occur.",
|
|
|
|
|
id, options.font_size, rec.height)
|
|
|
|
|
.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BeginScissorMode(rec.x, rec.y, rec.width, rec.height);
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
EndScissorMode();
|
|
|
|
|
|
2025-10-09 11:47:07 +03:00
|
|
|
return std::bitset<2> { static_cast<unsigned long long>(
|
|
|
|
|
(submitted ? 1 : 0) | (changed ? 2 : 0)) };
|
|
|
|
|
}
|