Map QA selector input through public RmlUI projection (by Codex)
This commit is contained in:
1 parent
d8beaecd6f
commit
9061123c7e
6 files changed
+169
-3
No files matched your search
@@ -12,6 +12,7 @@ Implementierung in der Spiel-Engine.
|
|||||||
| Nativer Stand | [Unterbau, erster Durchlauf und noch offene Übertragungen](NATIVE_STATUS.md) |
|
| Nativer Stand | [Unterbau, erster Durchlauf und noch offene Übertragungen](NATIVE_STATUS.md) |
|
||||||
| Auswahlmenüs | [Gemeinsame Listen, Tastatur und Übernahme](controls/selects/README.md) |
|
| Auswahlmenüs | [Gemeinsame Listen, Tastatur und Übernahme](controls/selects/README.md) |
|
||||||
| Schrift-QA | [Button-/Dropdown-Ausrichtung und unabhängiger Vergleich](typography-qa.md) |
|
| Schrift-QA | [Button-/Dropdown-Ausrichtung und unabhängiger Vergleich](typography-qa.md) |
|
||||||
|
| QA-Skripte | [Sichtbare Klickpunkte bei CSS-Transformationen](qa-script-locator.md) |
|
||||||
| Menü-QA | [Wiederholbarer Gesamtkatalog und Meilenstein-Abnahme](menu-qa.md) |
|
| Menü-QA | [Wiederholbarer Gesamtkatalog und Meilenstein-Abnahme](menu-qa.md) |
|
||||||
| QA-Befunde | [Offene Abweichungen zur HTML-Referenz](qa-findings.md) |
|
| QA-Befunde | [Offene Abweichungen zur HTML-Referenz](qa-findings.md) |
|
||||||
| Ressourcen | [GUI-Assets, Weltbilder und spätere Paketbereinigung](assets.md) |
|
| Ressourcen | [GUI-Assets, Weltbilder und spätere Paketbereinigung](assets.md) |
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||||
|
# Native QA-Skripte · sichtbare Klickpunkte
|
||||||
|
|
||||||
|
Stand: 27. Oktober 2026. Diese Änderung betrifft ausschließlich den opt-in
|
||||||
|
JSONL-Commanddriver der Modern-UI-Demo. Produktgestaltung, normaler Maus-HitTest,
|
||||||
|
Rendering, Datenquelle und Engine werden nicht verändert.
|
||||||
|
|
||||||
|
`GetAbsoluteOffset(Border)` enthält Layout und Scroll, aber keine CSS-
|
||||||
|
Transformation. Deshalb trafen Selector-Klicks auf einen mit
|
||||||
|
`translate(0,-50%)` zentrierten Nachrichtendialog unterhalb des sichtbaren
|
||||||
|
Schließen-Buttons. Ein echter X11→SDL-Klick auf dessen sichtbare Position
|
||||||
|
funktioniert; die alte erfolglose Selectorprobe war kein Dialogdefekt.
|
||||||
|
|
||||||
|
`script_click_point()` verwendet die öffentliche RmlUI-API `Element::Project`,
|
||||||
|
die dieselbe vollständige inverse Transformation wie der native HitTest nutzt.
|
||||||
|
Der Helper löst die sichtbare Fensterposition der gewünschten Layoutmitte mit
|
||||||
|
höchstens acht begrenzten Korrekturen. Nicht endliche Werte, singuläre oder
|
||||||
|
numerisch nicht lösbare Projektionen und Punkte außerhalb des Contexts werden
|
||||||
|
abgelehnt. Abschließend muss der tatsächliche `GetElementAtPoint`-Treffer das
|
||||||
|
gewählte Element oder einen seiner Nachfahren ergeben; verdeckte Elemente
|
||||||
|
werden nicht versehentlich durch einen Klick auf ihre Überlagerung ersetzt.
|
||||||
|
|
||||||
|
Es gibt keine Dialog-ID-Sonderregel, keinen festen Pixelversatz und keinen
|
||||||
|
privaten Vendorheader. Explizite JSONL-Koordinaten `{x,y}` bleiben unverändert.
|
||||||
|
Selector-basierte Klick-, Zeiger-, Rad- und Drag-Startpunkte nutzen denselben
|
||||||
|
Locator. Bei einem nicht anklickbaren sichtbaren Mittelpunkt bricht der
|
||||||
|
QA-Treiber mit einer ausdrücklichen Fehlermeldung ab. Der Helper sucht keine
|
||||||
|
beliebige freie Teilfläche eines teilweise verdeckten Elements.
|
||||||
|
|
||||||
|
Der bestehende `modern_control_layout_tests` prüft in drei Themes bei vier
|
||||||
|
Dichten jeweils untransformierte, verschobene, skalierte und gedrehte Elemente
|
||||||
|
über tatsächlich zugestellte Mausclicks sowie die Ablehnung singulärer und
|
||||||
|
verdeckter Ziele. Der Target und der native App-Link sind unter Linux grün.
|
||||||
|
Ein zusätzlicher nativer Selector-Smoke trifft den sichtbaren Schließen-Button
|
||||||
|
über `:hover`, schließt den transformierten Dialog und erhält Source und
|
||||||
|
Revision. Das ist keine zusätzliche Windows-/macOS-Laufzeitabnahme.
|
||||||
@@ -881,9 +881,10 @@ void App::script() {
|
|||||||
doc_->QuerySelector(command.at("selector").get<std::string>());
|
doc_->QuerySelector(command.at("selector").get<std::string>());
|
||||||
if (!node || !node->IsVisible(true))
|
if (!node || !node->IsVisible(true))
|
||||||
throw editor::Error("UI-Skript: Element nicht sichtbar.");
|
throw editor::Error("UI-Skript: Element nicht sichtbar.");
|
||||||
const auto at = node->GetAbsoluteOffset(Rml::BoxArea::Border),
|
const auto point = script_click_point(*context_, *node);
|
||||||
size = node->GetBox().GetSize(Rml::BoxArea::Border);
|
if (!point)
|
||||||
return Rml::Vector2i{int(at.x + size.x * .5f), int(at.y + size.y * .5f)};
|
throw editor::Error("UI-Skript: Elementmitte ist nicht sichtbar anklickbar oder die Transformation ist singulär.");
|
||||||
|
return *point;
|
||||||
}
|
}
|
||||||
return Rml::Vector2i{command.at("x").get<int>(),
|
return Rml::Vector2i{command.at("x").get<int>(),
|
||||||
command.at("y").get<int>()};
|
command.at("y").get<int>()};
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
#pragma once
|
||||||
|
#include <RmlUi/Core.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
namespace bmh::modern_ui {
|
||||||
|
// QA command driver only. Layout offsets omit CSS transforms; Project applies
|
||||||
|
// the inverse accumulated transform used by RmlUI's own pointer hit testing.
|
||||||
|
inline std::optional<Rml::Vector2i> script_click_point(Rml::Context &context,
|
||||||
|
Rml::Element &node) {
|
||||||
|
if (!node.IsVisible(true))
|
||||||
|
return {};
|
||||||
|
const auto size = node.GetBox().GetSize(Rml::BoxArea::Border);
|
||||||
|
if (size.x <= 0 || size.y <= 0)
|
||||||
|
return {};
|
||||||
|
const auto target = node.GetAbsoluteOffset(Rml::BoxArea::Border) + size * .5f;
|
||||||
|
auto point = target;
|
||||||
|
const auto finite = [](Rml::Vector2f p) {
|
||||||
|
return std::isfinite(p.x) && std::isfinite(p.y);
|
||||||
|
};
|
||||||
|
bool solved = false;
|
||||||
|
// Solve the public inverse projection for the desired layout-space center.
|
||||||
|
// Affine transforms converge in one correction; perspective is bounded too.
|
||||||
|
for (int attempt = 0; attempt < 8; ++attempt) {
|
||||||
|
auto projected = point;
|
||||||
|
if (!finite(point) || !node.Project(projected) || !finite(projected))
|
||||||
|
return {};
|
||||||
|
const auto error = target - projected;
|
||||||
|
if (std::abs(error.x) <= .02f && std::abs(error.y) <= .02f) {
|
||||||
|
solved = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto x = point + Rml::Vector2f{1, 0};
|
||||||
|
auto y = point + Rml::Vector2f{0, 1};
|
||||||
|
if (!node.Project(x) || !node.Project(y) || !finite(x) || !finite(y))
|
||||||
|
return {};
|
||||||
|
x -= projected;
|
||||||
|
y -= projected;
|
||||||
|
const double det = double(x.x) * y.y - double(y.x) * x.y;
|
||||||
|
if (!std::isfinite(det) || std::abs(det) < 1e-8)
|
||||||
|
return {};
|
||||||
|
point += Rml::Vector2f{
|
||||||
|
float((double(error.x) * y.y - double(error.y) * y.x) / det),
|
||||||
|
float((double(x.x) * error.y - double(x.y) * error.x) / det)};
|
||||||
|
}
|
||||||
|
const auto bounds = context.GetDimensions();
|
||||||
|
if (!solved || !finite(point) || point.x < 0 || point.y < 0 ||
|
||||||
|
point.x >= bounds.x || point.y >= bounds.y)
|
||||||
|
return {};
|
||||||
|
const Rml::Vector2i pixel{int(std::lround(point.x)),
|
||||||
|
int(std::lround(point.y))};
|
||||||
|
if (pixel.x < 0 || pixel.y < 0 || pixel.x >= bounds.x || pixel.y >= bounds.y)
|
||||||
|
return {};
|
||||||
|
auto *hit =
|
||||||
|
context.GetElementAtPoint(Rml::Vector2f{float(pixel.x), float(pixel.y)});
|
||||||
|
if (!hit || !node.Contains(hit))
|
||||||
|
return {}; // Never silently click an overlay or another control.
|
||||||
|
return pixel;
|
||||||
|
}
|
||||||
|
} // namespace bmh::modern_ui
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "launch/rml_path.hpp"
|
#include "launch/rml_path.hpp"
|
||||||
#include "launch/rml_video.hpp"
|
#include "launch/rml_video.hpp"
|
||||||
#include "modern/ui/controls.hpp"
|
#include "modern/ui/controls.hpp"
|
||||||
|
#include "modern/ui/script_locator.hpp"
|
||||||
#include "modern/ui/select_menu.hpp"
|
#include "modern/ui/select_menu.hpp"
|
||||||
#include "modern/ui/demo_calendar.hpp"
|
#include "modern/ui/demo_calendar.hpp"
|
||||||
#include "modern/ui/demo_finance.hpp"
|
#include "modern/ui/demo_finance.hpp"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
// Exercise the production control builder and stylesheet with synthetic labels.
|
// Exercise the production control builder and stylesheet with synthetic labels.
|
||||||
#include "modern/ui/controls.hpp"
|
#include "modern/ui/controls.hpp"
|
||||||
|
#include "modern/ui/script_locator.hpp"
|
||||||
#include <RmlUi/Core/ElementText.h>
|
#include <RmlUi/Core/ElementText.h>
|
||||||
#include <RmlUi/Core/Elements/ElementFormControlSelect.h>
|
#include <RmlUi/Core/Elements/ElementFormControlSelect.h>
|
||||||
#include <RmlUi/Core/FontEngineInterface.h>
|
#include <RmlUi/Core/FontEngineInterface.h>
|
||||||
@@ -89,6 +90,69 @@ size_t visible_text_lines(Rml::Element &node) {
|
|||||||
count += visible_text_lines(*node.GetChild(i));
|
count += visible_text_lines(*node.GetChild(i));
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
struct ClickListener final : Rml::EventListener {
|
||||||
|
int clicks = 0;
|
||||||
|
void ProcessEvent(Rml::Event &event) override {
|
||||||
|
if (event.GetType() == "click")
|
||||||
|
++clicks;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
void script_locator_cases(Rml::Context &context, float density) {
|
||||||
|
struct Case {
|
||||||
|
const char *transform;
|
||||||
|
Rml::Vector2f expected;
|
||||||
|
bool blocked;
|
||||||
|
};
|
||||||
|
for (const auto &test :
|
||||||
|
{Case{"none", {700, 730}, false},
|
||||||
|
Case{"translate(70dp,-160dp)", {770, 570}, false},
|
||||||
|
Case{"scale(1.5)", {800, 795}, false},
|
||||||
|
Case{"rotate(90deg)", {370, 800}, false}, Case{"scale(0)", {}, true},
|
||||||
|
Case{"none", {}, true}}) {
|
||||||
|
const bool covered = test.blocked && std::string(test.transform) == "none";
|
||||||
|
auto *doc = context.LoadDocumentFromMemory(
|
||||||
|
"<rml><head><style>body{margin:0;font-family:Modern;font-size:20dp;}"
|
||||||
|
"#parent{position:absolute;left:500dp;top:600dp;width:600dp;height:"
|
||||||
|
"300dp;transform-origin:0 0;transform:" +
|
||||||
|
std::string(test.transform) +
|
||||||
|
";}"
|
||||||
|
"#target{position:absolute;left:100dp;top:80dp;width:200dp;height:"
|
||||||
|
"100dp;margin:0;padding:0;border:0;}"
|
||||||
|
"#label{position:absolute;left:0;right:0;top:0;bottom:0;}"
|
||||||
|
"#cover{position:absolute;left:500dp;top:600dp;width:600dp;height:"
|
||||||
|
"300dp;z-index:999;}"
|
||||||
|
"</style></head><body><div id='parent'><button id='target'><span "
|
||||||
|
"id='label'>Click</span></button></div>" +
|
||||||
|
(covered ? std::string("<div id='cover'></div>") : std::string()) +
|
||||||
|
"</body></rml>");
|
||||||
|
require(doc, "Script locator document missing");
|
||||||
|
doc->Show();
|
||||||
|
context.Update();
|
||||||
|
context.Render();
|
||||||
|
auto *target = doc->GetElementById("target");
|
||||||
|
const auto point = script_click_point(context, *target);
|
||||||
|
if (test.blocked)
|
||||||
|
require(!point,
|
||||||
|
"Singular/covered locator silently clicks another element");
|
||||||
|
else {
|
||||||
|
require(bool(point),
|
||||||
|
"Transformed script locator rejected visible control");
|
||||||
|
require(std::abs(point->x - test.expected.x * density) <= 1.f &&
|
||||||
|
std::abs(point->y - test.expected.y * density) <= 1.f,
|
||||||
|
"Script locator did not map the visible transformed center");
|
||||||
|
ClickListener listener;
|
||||||
|
target->AddEventListener("click", &listener);
|
||||||
|
context.ProcessMouseMove(point->x, point->y, 0);
|
||||||
|
context.ProcessMouseButtonDown(0, 0);
|
||||||
|
context.ProcessMouseButtonUp(0, 0);
|
||||||
|
require(listener.clicks == 1,
|
||||||
|
"Script locator point did not click requested control");
|
||||||
|
target->RemoveEventListener("click", &listener);
|
||||||
|
}
|
||||||
|
doc->Close();
|
||||||
|
context.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
int main(int argc, char **argv) try {
|
int main(int argc, char **argv) try {
|
||||||
require(argc == 2, "Pass the Modern asset directory");
|
require(argc == 2, "Pass the Modern asset directory");
|
||||||
@@ -266,6 +330,8 @@ int main(int argc, char **argv) try {
|
|||||||
context->Update();
|
context->Update();
|
||||||
}
|
}
|
||||||
doc->Close();
|
doc->Close();
|
||||||
|
context->Update();
|
||||||
|
script_locator_cases(*context,density);
|
||||||
Rml::RemoveContext("controls");
|
Rml::RemoveContext("controls");
|
||||||
}
|
}
|
||||||
Rml::Shutdown();
|
Rml::Shutdown();
|
||||||
|
|||||||
Reference in new issue
Block a user