Skip to content

Commit d172d2b

Browse files
committed
Implement field rendering using GenerateRml()
Now actually rendering fields when editors open! view.lua changes: - OpenEditor() now calls field.GenerateRml() for each field - Concatenates all field RML into editor HTML - Sets mainContent.inner_rml to display fields - Added BindFieldEvents() to wire up input change events - Field changes call editor:OnFieldChange() springboard.rcss additions: - .editor-container, .editor-title styling - .field-row flex layout (label + input side-by-side) - .field-label min-width for alignment - .field-input styling with focus state - .field-button for Browse/Pick buttons - .field-separator for visual breaks - .field-group for horizontal field groups All RmlUi field classes already have GenerateRml(): - StringField → text input - NumericField → number input with min/max/step - BooleanField → checkbox - ChoiceField → dropdown select - ColorField, AssetField, MaterialField → input + button Editors should now show actual working fields!
1 parent 0820678 commit d172d2b

File tree

2 files changed

+112
-7
lines changed

2 files changed

+112
-7
lines changed

scen_edit/view/rcss/springboard.rcss

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,69 @@ body#springboard {
120120
color: #cccccc;
121121
overflow-y: auto;
122122
}
123+
124+
/* Editor field styles */
125+
.editor-container {
126+
padding: 10dp;
127+
}
128+
129+
.editor-title {
130+
font-size: 16dp;
131+
color: #ffffff;
132+
margin-bottom: 15dp;
133+
padding-bottom: 5dp;
134+
border-bottom: 1dp #555555;
135+
}
136+
137+
.field-row {
138+
display: flex;
139+
flex-direction: row;
140+
align-items: center;
141+
margin-bottom: 10dp;
142+
gap: 10dp;
143+
}
144+
145+
.field-label {
146+
min-width: 120dp;
147+
color: #cccccc;
148+
font-size: 13dp;
149+
}
150+
151+
.field-input {
152+
flex: 1;
153+
background-color: #3a3a3a;
154+
color: #ffffff;
155+
border: 1dp #555555;
156+
padding: 5dp;
157+
font-size: 13dp;
158+
}
159+
160+
.field-input:focus {
161+
border-color: #3a7ebf;
162+
background-color: #2a2a2a;
163+
}
164+
165+
.field-button {
166+
background-color: #3a7ebf;
167+
color: #ffffff;
168+
border: 1dp #2a5f8f;
169+
padding: 5dp 10dp;
170+
cursor: pointer;
171+
}
172+
173+
.field-button:hover {
174+
background-color: #4a8ecf;
175+
}
176+
177+
.field-separator {
178+
height: 1dp;
179+
background-color: #555555;
180+
margin: 15dp 0dp;
181+
}
182+
183+
.field-group {
184+
display: flex;
185+
flex-direction: row;
186+
gap: 5dp;
187+
margin-bottom: 10dp;
188+
}

scen_edit/view/view.lua

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,12 @@ end
421421

422422
function View:OpenEditor(editorName)
423423
Log.Notice("Opening editor: " .. editorName)
424-
424+
425425
-- Create editor instance if not exists
426426
if not SB.editors then
427427
SB.editors = {}
428428
end
429-
429+
430430
if not SB.editors[editorName] then
431431
local editorCfg = SB.editorRegistry[editorName]
432432
if editorCfg and editorCfg.editor then
@@ -436,19 +436,58 @@ function View:OpenEditor(editorName)
436436
return
437437
end
438438
end
439-
439+
440440
local editor = SB.editors[editorName]
441+
local editorCfg = SB.editorRegistry[editorName]
441442
local mainContent = self.mainDocument:GetElementById("main-content")
442443
if mainContent and editor then
443-
-- For now, just show a placeholder
444-
-- TODO: Implement full editor rendering with fields
445-
mainContent.inner_rml = "<h3>Editor: " .. editorName .. "</h3><p>Fields will be rendered here</p>"
444+
-- Render all fields to RML
445+
local html = '<div class="editor-container"><h3 class="editor-title">' .. (editorCfg and editorCfg.caption or editorName) .. '</h3>'
446+
447+
-- Generate RML for each field in order
448+
for _, fieldName in ipairs(editor.fieldOrder) do
449+
local field = editor.fields[fieldName]
450+
if field and field.GenerateRml then
451+
html = html .. field:GenerateRml()
452+
elseif field then
453+
-- Fallback for fields without GenerateRml (like separators)
454+
html = html .. '<div class="field-separator"></div>'
455+
end
456+
end
457+
458+
html = html .. '</div>'
459+
mainContent.inner_rml = html
460+
461+
-- Bind field events
462+
self:BindFieldEvents(editor)
446463
end
447-
464+
448465
-- Highlight pressed button
449466
self:UpdateEditorButtonStates(editorName)
450467
end
451468

469+
function View:BindFieldEvents(editor)
470+
if not self.mainDocument or not editor or not editor.fields then
471+
return
472+
end
473+
474+
-- Bind change events for each field
475+
for fieldName, field in pairs(editor.fields) do
476+
local inputElement = self.mainDocument:GetElementById("field-" .. fieldName)
477+
if inputElement then
478+
inputElement:AddEventListener("change", function(event)
479+
local value = inputElement.value
480+
-- Update field value
481+
field.value = value
482+
-- Notify editor
483+
if editor.OnFieldChange then
484+
editor:OnFieldChange(fieldName, value)
485+
end
486+
end)
487+
end
488+
end
489+
end
490+
452491
function View:UpdateEditorButtonStates(activeEditorName)
453492
-- Remove pressed state from all buttons
454493
for name, _ in pairs(SB.editorRegistry) do

0 commit comments

Comments
 (0)