save state

This commit is contained in:
2026-01-16 08:15:28 +01:00
parent 4d5b4c2455
commit 77a9579025
11 changed files with 763 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
<head>
<link type="text/rcss" href="html.rcss"/>
<link type="text/rcss" href="phone.rcss"/>
<script src="scripts.lua"></script>
<title>Fullscreen Mobile UI</title>
</head>
<body>
@@ -15,7 +16,12 @@
<div id="content">
<div class="header-section">
<h1>Hello omar 3 hello! and hello LEO 2 Hello!</h1>
<h1>Mosis Service</h1>
</div>
<div class="button-section">
<button id="action-button" class="primary-button" onclick="onButtonClick()">Click Me!</button>
<button id="reset-button" class="secondary-button" onclick="onResetClick()">Reset</button>
</div>
</div>

View File

@@ -105,4 +105,55 @@ h1 {
.nav-item:hover {
background-color: white;
}
/* Button Section */
.button-section {
display: block;
text-align: center;
margin-top: 50px;
}
/* Primary Button Style */
.primary-button {
font-family: LatoLatin;
font-size: 4em;
padding: 30px 60px;
margin: 20px;
background-color: #3498db;
color: white;
border: none;
border-radius: 15px;
cursor: pointer;
min-width: 300px;
}
.primary-button:hover {
background-color: #2980b9;
}
.primary-button:active {
background-color: #1c5a85;
}
/* Secondary Button Style */
.secondary-button {
font-family: LatoLatin;
font-size: 3em;
padding: 20px 40px;
margin: 20px;
background-color: #7f8c8d;
color: white;
border: none;
border-radius: 15px;
cursor: pointer;
min-width: 200px;
}
.secondary-button:hover {
background-color: #95a5a6;
}
.secondary-button:active {
background-color: #5d6d6e;
}

View File

@@ -0,0 +1,36 @@
-- MosisService Lua Scripts
-- Button click handlers and UI logic
-- Counter to track button clicks
click_count = 0
-- Button click handler
function onButtonClick()
click_count = click_count + 1
print("Button clicked! Count: " .. click_count)
-- Update the button text to show click count
local document = rmlui.contexts["default"].documents[1]
if document then
local button = document:GetElementById("action-button")
if button then
button.inner_rml = "Clicked " .. click_count .. " times"
end
end
end
-- Reset counter function
function onResetClick()
click_count = 0
print("Counter reset!")
local document = rmlui.contexts["default"].documents[1]
if document then
local button = document:GetElementById("action-button")
if button then
button.inner_rml = "Click Me!"
end
end
end
print("Lua scripts loaded successfully!")

View File

@@ -8,7 +8,23 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(BINDER_DIR "${ANDROID_SDK}/platforms/android-36/optional/libbinder_ndk_cpp")
set(AIDL_EXE "${ANDROID_SDK}/build-tools/36.1.0/aidl.exe")
find_package(RmlUi CONFIG REQUIRED)
# Find Lua from vcpkg
find_package(Lua REQUIRED)
# Fetch RmlUi from GitHub with Lua bindings enabled
include(FetchContent)
FetchContent_Declare(
rmlui
GIT_REPOSITORY https://github.com/mikke89/RmlUi.git
GIT_TAG master
)
set(RMLUI_LUA_BINDINGS ON CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(RMLUI_SAMPLES OFF CACHE BOOL "" FORCE)
set(RMLUI_TESTS OFF CACHE BOOL "" FORCE)
set(RMLUI_FONT_ENGINE "freetype" CACHE STRING "" FORCE)
set(RMLUI_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(rmlui)
#get_cmake_property(_variableNames VARIABLES)
#list(SORT _variableNames)
@@ -60,7 +76,7 @@ target_include_directories(mosis-service PUBLIC
)
target_link_libraries(mosis-service
android log binder_ndk EGL GLESv2 nativewindow
RmlUi::RmlUi
rmlui rmlui_lua
)
add_library(mosis-test SHARED

View File

@@ -7,6 +7,7 @@
#include <android/hardware_buffer.h>
#include <android/asset_manager.h>
#include <RmlUi/Core.h>
#include <RmlUi/Lua.h>
#include "RmlUi_Renderer_GL3.h"
#include <span>
#include <ranges>
@@ -119,6 +120,8 @@ void Kernel::main_loop()
Rml::SetFileInterface(&AssetFilesInterface::Instance());
Rml::SetSystemInterface(&SystemInterface::Instance());
Rml::Initialise();
Rml::Lua::Initialise();
Logger::Log("RmlUi Lua bindings initialized");
Rml::Context* context = Rml::CreateContext("default", Rml::Vector2i(540, 960));
if (!context)
{
@@ -195,6 +198,11 @@ void Kernel::add_listener(const std::shared_ptr<IMosisListener> &listener)
void Kernel::on_touch_down(float x, float y)
{
Logger::Log(std::format("on_touch_down {} - {}", x, y));
std::lock_guard _lock(m_mutex);
m_tasks.emplace_back([x, y](Rml::Context* context){
context->ProcessMouseMove(static_cast<int>(x * 540), static_cast<int>(y * 960), 0);
context->ProcessMouseButtonDown(0, 0);
});
}
void Kernel::on_touch_move(float x, float y)
@@ -202,13 +210,18 @@ void Kernel::on_touch_move(float x, float y)
Logger::Log(std::format("on_touch_move {} - {}", x, y));
std::lock_guard _lock(m_mutex);
m_tasks.emplace_back([x, y](Rml::Context* context){
context->ProcessMouseMove(x * 540, y * 960, 0);
context->ProcessMouseMove(static_cast<int>(x * 540), static_cast<int>(y * 960), 0);
});
}
void Kernel::on_touch_up(float x, float y)
{
Logger::Log(std::format("on_touch_up {} - {}", x, y));
std::lock_guard _lock(m_mutex);
m_tasks.emplace_back([x, y](Rml::Context* context){
context->ProcessMouseMove(static_cast<int>(x * 540), static_cast<int>(y * 960), 0);
context->ProcessMouseButtonUp(0, 0);
});
}
Kernel::~Kernel() = default;

View File

@@ -2,6 +2,7 @@
"name": "mosis-os",
"version-string": "0.1.0",
"dependencies": [
"rmlui"
"lua",
"freetype"
]
}