add data model
This commit is contained in:
@@ -8,8 +8,10 @@
|
||||
#include <android/asset_manager.h>
|
||||
#include <RmlUi/Core.h>
|
||||
#include "RmlUi_Renderer_GL3.h"
|
||||
#include <ranges>
|
||||
#include <span>
|
||||
#include <ranges>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
|
||||
using namespace aidl::com::omixlab::mosis;
|
||||
using namespace aidl::android::hardware;
|
||||
@@ -128,6 +130,14 @@ void Kernel::main_loop()
|
||||
Rml::LoadFontFace("LatoLatin-Regular.ttf");
|
||||
Rml::LoadFontFace("NotoEmoji-Regular.ttf", true);
|
||||
|
||||
std::string status_time = "0";
|
||||
Rml::DataModelHandle status_time_handle;
|
||||
if (Rml::DataModelConstructor status_data_ctor = context->CreateDataModel("status-data"))
|
||||
{
|
||||
status_data_ctor.Bind("time", &status_time);
|
||||
status_time_handle = status_data_ctor.GetModelHandle();
|
||||
}
|
||||
|
||||
// Now we are ready to load our document.
|
||||
Rml::ElementDocument* document = context->LoadDocument("demo.rml");
|
||||
document->Show();
|
||||
@@ -147,6 +157,10 @@ void Kernel::main_loop()
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glViewport(0, 0, 540, 960);
|
||||
|
||||
status_time = std::format("{:%H:%M:%S}",
|
||||
std::chrono::floor<std::chrono::seconds>(std::chrono::system_clock::now()));
|
||||
status_time_handle.DirtyAllVariables();
|
||||
|
||||
context->Update();
|
||||
rmlui_render_interface.SetViewport(540, 960);
|
||||
rmlui_render_interface.BeginFrame();
|
||||
|
||||
Reference in New Issue
Block a user