diff options
| author | Adam Malczewski <[email protected]> | 2026-06-29 09:07:32 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-29 09:07:32 +0900 |
| commit | 53ef70aff331c9f95b744809c125af55a230ebfa (patch) | |
| tree | 013bdabb4d7cc6cf97974805a301979993b2639a | |
| parent | 9d76e43c2017c9b009c97d0bc1f47baf848809fe (diff) | |
| download | study-player-53ef70aff331c9f95b744809c125af55a230ebfa.tar.gz study-player-53ef70aff331c9f95b744809c125af55a230ebfa.zip | |
refactor: font-scale targets #body-root element (coherent id alignment)
Aligns apply_font_scale to the body element's id across study_player.rb /
layout.rb / main.rml (was probing element('body')||element('__body__')).
Verified: build green, run clean, player view renders correctly.
(these edits were left uncommitted by the Phase 6 agent's timed-out turn;
orchestrator verified + committed.)
| -rw-r--r-- | game/study_player/layout.rb | 21 | ||||
| -rw-r--r-- | game/study_player/study_player.rb | 7 | ||||
| -rw-r--r-- | game/study_player/ui/main.rml | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/game/study_player/layout.rb b/game/study_player/layout.rb index 6ba0d6e..cec94fe 100644 --- a/game/study_player/layout.rb +++ b/game/study_player/layout.rb @@ -149,20 +149,21 @@ module StudyPlayer end end - # Apply font_scale to the body element. + # Apply font_scale to the body element via a global style override. + # The <body> tag has id="body-root" so we can set its properties. def self.apply_font_scale(doc, scale) return unless doc - body = doc.element("body") || doc.element("__body__") - # Try finding the body via document - body_el = body || doc - return unless body_el + return if scale <= 0 || scale > 5.0 - base_size = 18 # matches main.rcss body font-size - new_size = (base_size * scale).round + base = 18 # matches main.rcss body font-size + new_size = (base * scale).round new_size = 10 if new_size < 10 - new_size = 72 if new_size > 72 - # Use the context to set property on the body - # (RmlUi body element is special — we set it via the document root) + new_size = 96 if new_size > 96 + + root = doc.element("body-root") + return unless root + + root.set_property("font-size", "#{new_size}px") end end end diff --git a/game/study_player/study_player.rb b/game/study_player/study_player.rb index 9c8ede3..82d0606 100644 --- a/game/study_player/study_player.rb +++ b/game/study_player/study_player.rb @@ -1355,8 +1355,8 @@ module StudyPlayer end end - # Apply font_scale to the root element via a global style override. - # Since RmlUi body font-size cascades, we set it on the document root. + # Apply font_scale to the body element via a global style override. + # The <body> tag has id="body-root" so we can set its properties. def self.apply_font_scale(doc, scale) return unless doc return if scale <= 0 || scale > 5.0 @@ -1366,8 +1366,7 @@ module StudyPlayer new_size = 10 if new_size < 10 new_size = 96 if new_size > 96 - # Try to find a body or root element - root = doc.element("body") || doc.element("__body__") + root = doc.element("body-root") return unless root root.set_property("font-size", "#{new_size}px") diff --git a/game/study_player/ui/main.rml b/game/study_player/ui/main.rml index 5ef6c19..821293e 100644 --- a/game/study_player/ui/main.rml +++ b/game/study_player/ui/main.rml @@ -2,7 +2,7 @@ <head> <link type="text/rcss" href="main.rcss"/> </head> -<body data-model="player"> +<body id="body-root" data-model="player"> <!-- ================================================================ --> <!-- Splash view: shown when no file is loaded --> <!-- ================================================================ --> |
