Adding template project
This commit is contained in:
17
assets/main.rml
Normal file
17
assets/main.rml
Normal file
@@ -0,0 +1,17 @@
|
||||
<rml>
|
||||
<head>
|
||||
<title>RmlUi Temaplate</title>
|
||||
<link type="text/rcss" href="styles/main.rcss" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="navbar">
|
||||
<h1>RmlUi App Template</h1>
|
||||
<div class="nav-buttons">
|
||||
<button id="nav-home">Home</button>
|
||||
<button id="nav-test">C++ Test Page</button>
|
||||
<button id="nav-lua-test" onclick="NavigateTo('lua-test')">Lua Test</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="page-content"></div>
|
||||
</body>
|
||||
</rml>
|
||||
14
assets/pages/home.rml
Normal file
14
assets/pages/home.rml
Normal file
@@ -0,0 +1,14 @@
|
||||
<div id="page-root" class="page">
|
||||
<h1>Home</h1>
|
||||
<p>This is an RmlUi template project with some nice built in features such as:</p>
|
||||
<ul>
|
||||
<li>- Lua and SVG plugins enabled</li>
|
||||
<li>- A shell + page loading system with scoped stylesheets and lua functionality</li>
|
||||
<li>- Hot reload when pressing F5</li>
|
||||
<li>- Basic application state management</li>
|
||||
<li>- A basic stylesheet for common elements</li>
|
||||
<li>- Easy custom controls system</li>
|
||||
<li>- Optional Raylib context</li>
|
||||
<li>- Nix flake for easy development/building</li>
|
||||
</ul>
|
||||
</div>
|
||||
17
assets/pages/lua-test.lua
Normal file
17
assets/pages/lua-test.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
LuaTest = {}
|
||||
|
||||
local counter = 0
|
||||
|
||||
function LuaTest.Test(event)
|
||||
counter = counter + 1
|
||||
|
||||
local document = event.current_element.owner_document
|
||||
|
||||
local target = document:GetElementById("lua-counter")
|
||||
if target then
|
||||
target.inner_rml = "Lua Counter: " .. counter
|
||||
end
|
||||
|
||||
print("Lua counter incremented to: " .. counter)
|
||||
|
||||
end
|
||||
0
assets/pages/lua-test.rcss
Normal file
0
assets/pages/lua-test.rcss
Normal file
11
assets/pages/lua-test.rml
Normal file
11
assets/pages/lua-test.rml
Normal file
@@ -0,0 +1,11 @@
|
||||
<div id="page-root">
|
||||
<h1>Lua test page</h1>
|
||||
<p>This button uses <code>NavigateTo('about')</code> lua code instead of being harcoded in a C++ PageBase class:</p>
|
||||
<button onclick="NavigateTo('about')">Go to About Page</button>
|
||||
|
||||
<p>If you have a .lua file with the same name as the page in the pages directory, it will be loaded at runtime so you can add functionality to a page like this:</p>
|
||||
|
||||
<p>This button calls <code>LuaTest.Test()</code> from the scoped `lua-test.lua` file</p>
|
||||
<button onclick="LuaTest.Test(event)">Click me!</button>
|
||||
<p id="lua-counter"></p>
|
||||
</div>
|
||||
28
assets/pages/test-page.lua
Normal file
28
assets/pages/test-page.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
TestPage = {}
|
||||
|
||||
local maxHp = 100
|
||||
local currentHp = 100
|
||||
|
||||
function TestPage.Damage(event)
|
||||
|
||||
currentHp = currentHp - 5
|
||||
|
||||
local document = event.current_element.owner_document
|
||||
local target = document:GetElementById("hp-bar")
|
||||
|
||||
if target then
|
||||
target:SetAttribute("current", currentHp)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function TestPage.Heal(event)
|
||||
currentHp = currentHp + 5
|
||||
|
||||
local document = event.current_element.owner_document
|
||||
local target = document:GetElementById("hp-bar")
|
||||
|
||||
if target then
|
||||
target:SetAttribute("current", currentHp)
|
||||
end
|
||||
end
|
||||
17
assets/pages/test-page.rcss
Normal file
17
assets/pages/test-page.rcss
Normal file
@@ -0,0 +1,17 @@
|
||||
#page-root h1 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.healthbar-track {
|
||||
display: block;
|
||||
width: 200px;
|
||||
height: 16px;
|
||||
background-color: #3c3c3c;
|
||||
border: 1px #666666;
|
||||
}
|
||||
|
||||
.healthbar-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
13
assets/pages/test-page.rml
Normal file
13
assets/pages/test-page.rml
Normal file
@@ -0,0 +1,13 @@
|
||||
<div id="page-root" data-model="test-page" class="page">
|
||||
<h1>Test page</h1>
|
||||
<p>{{greeting}}</p>
|
||||
<button id="test-btn">Button clicked: {{counter}} times</button>
|
||||
|
||||
<p>If you have a .rcss file with the same name as the page in the pages directory, it will be loaded at runtime so you can add custom styling to a page, which is why the header is red on this page only.</p>
|
||||
|
||||
<p>This next section demonstates two things, the custom <code>"healthbar"</code> rml element, and scoped lua with the damage and heal buttons</p>
|
||||
|
||||
<healthbar id="hp-bar" current="100" max="100"></healthbar>
|
||||
<button onclick="TestPage.Damage(event)">Damage</button>
|
||||
<button onclick="TestPage.Heal(event)">Heal</button>
|
||||
</div>
|
||||
314
assets/styles/main.rcss
Normal file
314
assets/styles/main.rcss
Normal file
@@ -0,0 +1,314 @@
|
||||
/* ==========================================================================
|
||||
RCSS User Agent Defaults (Plain HTML Style)
|
||||
========================================================================== */
|
||||
|
||||
/* Core Application Window Foundation */
|
||||
body {
|
||||
display: block;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
font-family: "rmlui-debugger-font";
|
||||
font-size: 16px;
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
/* Generic Structural Layout Defaults */
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div, section, article, header, footer, main, nav, aside {
|
||||
display: block;
|
||||
}
|
||||
|
||||
span, em, strong, a {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* Typographic Defaults */
|
||||
p {
|
||||
display: block;
|
||||
margin: 1em 0px;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin: 0.83em 0px;
|
||||
}
|
||||
|
||||
h1 { font-size: 2em; }
|
||||
h2 { font-size: 1.5em; }
|
||||
h3 { font-size: 1.17em; }
|
||||
h4 { font-size: 1em; }
|
||||
h5 { font-size: 0.83em; }
|
||||
h6 { font-size: 0.67em; }
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0000ee;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #551a8b;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
display: block;
|
||||
margin: 1em 40px;
|
||||
padding-left: 10px;
|
||||
border-left: 2px #cccccc;
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
font-family: "rmlui-debugger-font";
|
||||
background-color: #606060;
|
||||
color: #000000;
|
||||
padding: 3px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
margin: 1em 0px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
/* Lists */
|
||||
ul, ol {
|
||||
display: block;
|
||||
margin: 1em 0px;
|
||||
padding-left: 40px;
|
||||
}
|
||||
|
||||
li {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Tables
|
||||
========================================================================== */
|
||||
table {
|
||||
display: table;
|
||||
}
|
||||
|
||||
tr {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
td, th {
|
||||
display: table-cell;
|
||||
padding: 4px 8px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
font-weight: bold;
|
||||
background-color: #eaeaea;
|
||||
}
|
||||
|
||||
col {
|
||||
display: table-column;
|
||||
}
|
||||
|
||||
colgroup {
|
||||
display: table-column-group;
|
||||
}
|
||||
|
||||
thead, tbody, tfoot {
|
||||
display: table-row-group;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Form Inputs & Interactive UI Components
|
||||
========================================================================== */
|
||||
button, input, select, textarea {
|
||||
display: inline-block;
|
||||
font-family: "rmlui-debugger-font";
|
||||
font-size: 14px;
|
||||
margin: 2px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Traditional gray bevel button style */
|
||||
button, input[type="submit"], input[type="button"] {
|
||||
padding: 4px 12px;
|
||||
min-width: 40px;
|
||||
background-color: #e1e1e1;
|
||||
color: #000000;
|
||||
border: 1px #767676;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button:hover, input[type="submit"]:hover, input[type="button"]:hover {
|
||||
background-color: #d0d0d0;
|
||||
border: 1px #4f4f4f;
|
||||
}
|
||||
|
||||
button:active, input[type="submit"]:active, input[type="button"]:active {
|
||||
background-color: #b5b5b5;
|
||||
border: 1px #000000;
|
||||
}
|
||||
|
||||
/* Standard text field styling */
|
||||
input[type="text"], input[type="password"], textarea {
|
||||
padding: 4px;
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
border: 1px #767676;
|
||||
}
|
||||
|
||||
input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
|
||||
border: 1px #005aff;
|
||||
}
|
||||
|
||||
textarea {
|
||||
display: block;
|
||||
white-space: pre-wrap;
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
/* Select Box & Dropdowns */
|
||||
select {
|
||||
padding: 4px;
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
border: 1px #767676;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
RmlUi Specific Elements (Tabsets, Progress Bars, etc.)
|
||||
========================================================================== */
|
||||
tabset {
|
||||
display: block;
|
||||
}
|
||||
|
||||
tabset tabs {
|
||||
display: block;
|
||||
border-bottom: 1px #cccccc;
|
||||
}
|
||||
|
||||
/* Simple default layout style for built-in tabs */
|
||||
tab {
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
background-color: #f0f0f0;
|
||||
border: 1px #cccccc;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
tab:selected {
|
||||
background-color: #ffffff;
|
||||
border-bottom: 1px #ffffff; /* Overlap the bottom border line */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
panel {
|
||||
display: block;
|
||||
padding: 10px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* Standard HTML5 / RmlUi Progress Bar Fallback */
|
||||
progress {
|
||||
display: inline-block;
|
||||
width: 160px;
|
||||
height: 20px;
|
||||
background-color: #e6e6e6;
|
||||
border: 1px #b0b0b0;
|
||||
}
|
||||
|
||||
progress-value {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background-color: #0078d7; /* Classic Windows Blue fill */
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Utility & Modern Layout Helpers
|
||||
========================================================================== */
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-row {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.align-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#navbar {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
padding: 0px 20px;
|
||||
background-color: #2b2baa;
|
||||
}
|
||||
|
||||
#navbar h1 {
|
||||
color: #ffffff;
|
||||
font-size: 24px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#navbar .nav-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
#navbar button {
|
||||
padding: 8px 16px;
|
||||
background-color: #3c3c3c;
|
||||
color: #e0e0e0;
|
||||
border: 1px #666666;
|
||||
}
|
||||
|
||||
#navbar button:hover {
|
||||
background-color: #55555a;
|
||||
}
|
||||
|
||||
/* Page Content Base */
|
||||
#page-content {
|
||||
display: block;
|
||||
padding: 20px;
|
||||
background-color: #1a1a1a;
|
||||
color: #f0f0f0;
|
||||
}
|
||||
Reference in New Issue
Block a user