Files
waylight/src/ImGui.cpp

51 lines
1.0 KiB
C++
Raw Normal View History

#include "ImGui.hpp"
#include <cassert>
#include <raylib.h>
ImGui::ImGui(std::shared_ptr<TextRenderer> text_renderer)
: m_text_renderer(text_renderer)
{
}
void ImGui::begin(u32 const rune, bool ctrl, bool shift)
{
m_rune = rune;
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>
{
assert(id != 0);
bool submitted { false };
bool changed { false };
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();
return std::bitset<2> { static_cast<unsigned long long>(
(submitted ? 1 : 0) | (changed ? 2 : 0)) };
}