载入中...
搜索中...
未找到
UiMotionSinks.cpp
浏览该文件的文档.
1#include "ui/UiMotionSinks.h"
2
3#include "common/Diagnostic.h"
4
5#include <algorithm>
6
7namespace eve::ui {
8namespace {
9
10} // namespace
11
13 auto host = UIHost::resolve(host_);
15 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, std::string("UiHostPosSink") + ".write: host handle is stale"));
16 auto m = host->get().meta();
17 m->hasPos = true;
18 m->animDrivePos = true;
19 m->posX = value.x;
20 m->posY = value.y;
22}
23
25 auto host = UIHost::resolve(host_);
27 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, std::string("UiHostSizeSink") + ".write: host handle is stale"));
28 auto m = host->get().meta();
29 m->hasSize = true;
30 m->animDriveSize = true;
31 m->sizeX = value.x;
32 m->sizeY = value.y;
34}
35
37 auto host = UIHost::resolve(host_);
39 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, std::string("UiHostOverlayAlphaSink") + ".write: host handle is stale"));
40 host->get().meta()->overlayBgAlpha = std::clamp(value, 0.f, 1.f);
42}
43
45 auto host = UIHost::resolve(host_);
47 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, std::string("UiNodeOpacitySink") + ".write: host handle is stale"));
48 auto node = host->get().findById(nodeId_);
50 eve::DiagnosticCode::NotFound, std::string("UiNodeOpacitySink") + ".write: node '" + nodeId_ + "' not found"));
51 node->get().opacity = std::clamp(value, 0.f, 1.f);
53}
54
56 auto host = UIHost::resolve(host_);
58 eve::Diagnostic::error(eve::DiagnosticCode::StaleHandle, std::string("UiNodePosSink") + ".write: host handle is stale"));
59 auto node = host->get().findById(nodeId_);
61 eve::DiagnosticCode::NotFound, std::string("UiNodePosSink") + ".write: node '" + nodeId_ + "' not found"));
62 auto &n = node->get();
63 n.absolute = true;
64 n.posX = value.x;
65 n.posY = value.y;
67}
68
69} // namespace eve::ui
double value
Stable, structured diagnostics shared by engine modules.
glm::vec3 n
Definition Grass.cpp:63
const RoadNode * node
UIHostHandle host
UI-owned Motion push binders (optional animation bridge).
float m[16]
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
static eve::OptionalRef< UIHost > resolve(UIHostHandle handle) noexcept
Resolves a UI host handle with ECS generation checking.
Definition UIHost.cpp:61
eve::Result< void > write(float value) override
Writes .
eve::Result< void > write(eve::animation::MotionVec2 value) override
Write interpolated host position in pixels.
eve::Result< void > write(eve::animation::MotionVec2 value) override
Writes .
eve::Result< void > write(float value) override
Writes .
eve::Result< void > write(eve::animation::MotionVec2 value) override
Writes .
Compact float2 used by motion adapters (avoids graphics math deps).
Definition MotionTypes.h:39