Add LunaSVG

This commit is contained in:
Isuru Samarathunga
2025-10-18 09:26:01 +05:30
parent 4597d0a4aa
commit 57bc80f4f9
187 changed files with 12435 additions and 24 deletions

View File

@ -419,8 +419,16 @@ namespace ia::iae
g_context->Render();
}
static Rml::TouchList TouchEventToTouchList(SDL_Event &ev, Rml::Context *context, SDL_FingerID finger_id)
{
const Rml::Vector2f position =
Rml::Vector2f{ev.tfinger.x, ev.tfinger.y} * Rml::Vector2f{context->GetDimensions()};
return {Rml::Touch{static_cast<Rml::TouchId>(finger_id), position}};
}
VOID UI::OnSDLEvent(IN PVOID _event)
{
auto GetFingerId = [](const SDL_Event &event) { return event.tfinger.fingerID; };
const auto keymods = GetKeyModifierState();
const auto event = (SDL_Event *) _event;
switch (event->type)
@ -443,12 +451,26 @@ namespace ia::iae
case SDL_EventType::SDL_EVENT_TEXT_INPUT:
g_context->ProcessTextInput(Rml::String(&event->text.text[0]));
break;
case SDL_EventType::SDL_EVENT_FINGER_DOWN: {
const Rml::TouchList touches = TouchEventToTouchList(*event, g_context, GetFingerId(*event));
g_context->ProcessTouchStart(touches, GetKeyModifierState());
}
break;
case SDL_EventType::SDL_EVENT_FINGER_MOTION: {
const Rml::TouchList touches = TouchEventToTouchList(*event, g_context, GetFingerId(*event));
g_context->ProcessTouchMove(touches, GetKeyModifierState());
}
break;
case SDL_EventType::SDL_EVENT_FINGER_UP: {
const Rml::TouchList touches = TouchEventToTouchList(*event, g_context, GetFingerId(*event));
g_context->ProcessTouchEnd(touches, GetKeyModifierState());
}
}
}
VOID UI::OnScreenResize(IN INT32 newWidth, IN INT32 newHeight)
{
//g_context->SetDimensions(Rml::Vector2i{newWidth, newHeight});
g_context->SetDimensions(Rml::Vector2i{newWidth, newHeight});
}
VOID UI::AddFontFromFile(IN CONST String &path)
@ -460,8 +482,8 @@ namespace ia::iae
{
g_styleSheetContainer = Rml::Factory::InstanceStyleSheetString(styles.c_str());
g_markup = BuildString("<body style=\"display: block; width: 100vw; height: 100vh;\">", markup, "</body>");
//g_document->SetStyleSheetContainer(g_styleSheetContainer);
//g_document->SetInnerRML(g_markup.c_str());
g_document->SetStyleSheetContainer(g_styleSheetContainer);
g_document->SetInnerRML(g_markup.c_str());
}
VOID UI::AddClickEvent(IN PCCHAR elementId, IN std::function<VOID()> callback)