feat(notifier): entrada/eixida per temps amb easing, configurable a ui.yaml
This commit is contained in:
1 parent
f816e75cc0
commit
970fe2b4db
6 files changed
+68
-27
No files matched your search
@@ -110,7 +110,9 @@ UiConfig::UiConfig()
|
||||
.line_gap = Defaults::UI::Notifier::LINE_GAP,
|
||||
.margin_top = Defaults::UI::Notifier::MARGIN_TOP,
|
||||
.border_px = Defaults::UI::Notifier::BORDER_PX,
|
||||
.slide_speed = Defaults::UI::Notifier::SLIDE_SPEED,
|
||||
.slide_ms = Defaults::UI::Notifier::SLIDE_MS,
|
||||
.slide_in_curve = curveByName(Defaults::UI::Notifier::SLIDE_IN_CURVE),
|
||||
.slide_out_curve = curveByName(Defaults::UI::Notifier::SLIDE_OUT_CURVE),
|
||||
} {
|
||||
}
|
||||
|
||||
@@ -210,7 +212,9 @@ void UiConfig::load(const std::string& file_path) {
|
||||
readField(n, "line_gap", notifier_.line_gap);
|
||||
readField(n, "margin_top", notifier_.margin_top);
|
||||
readField(n, "border_px", notifier_.border_px);
|
||||
readField(n, "slide_speed", notifier_.slide_speed);
|
||||
readField(n, "slide_ms", notifier_.slide_ms);
|
||||
readCurve(n, "slide_in_curve", notifier_.slide_in_curve);
|
||||
readCurve(n, "slide_out_curve", notifier_.slide_out_curve);
|
||||
}
|
||||
|
||||
std::cout << "UiConfig: carregat des de " << file_path << '\n';
|
||||
|
||||
@@ -20,9 +20,15 @@ class UiConfig {
|
||||
int kerning;
|
||||
};
|
||||
|
||||
// Signatura d'una funció d'easing: t ∈ [0, 1] → valor ∈ [0, 1].
|
||||
// Permet triar corbes des de data/ui.yaml per nom (cadena) i guardar
|
||||
// el punter a la corresponent funció de `utils/easing.hpp`.
|
||||
using CurveFn = auto (*)(float) -> float;
|
||||
|
||||
// Geometria del Notifier (popup superior). Carregada des de
|
||||
// data/ui.yaml secció `notifier:`; els valors per defecte vénen de
|
||||
// Defaults::UI::Notifier.
|
||||
// Defaults::UI::Notifier. El moviment és per temps (slide_ms) i no per
|
||||
// velocitat, perquè una caixa més gran no triga més a entrar/eixir.
|
||||
struct Notifier {
|
||||
int padding_h;
|
||||
int padding_top;
|
||||
@@ -30,7 +36,9 @@ class UiConfig {
|
||||
int line_gap;
|
||||
int margin_top;
|
||||
int border_px;
|
||||
float slide_speed;
|
||||
int slide_ms;
|
||||
CurveFn slide_in_curve;
|
||||
CurveFn slide_out_curve;
|
||||
};
|
||||
|
||||
static auto get() -> UiConfig&;
|
||||
@@ -64,11 +72,6 @@ class UiConfig {
|
||||
[[nodiscard]] auto roomText() const -> Uint8 { return room_text_; }
|
||||
[[nodiscard]] auto roomTextOutline() const -> Uint8 { return room_text_outline_; }
|
||||
|
||||
// Signatura d'una funció d'easing: t ∈ [0, 1] → valor ∈ [0, 1].
|
||||
// Permet triar corbes des de data/ui.yaml per nom (cadena) i guardar
|
||||
// el punter a la corresponent funció de `utils/easing.hpp`.
|
||||
using CurveFn = auto (*)(float) -> float;
|
||||
|
||||
// Timings (ms).
|
||||
[[nodiscard]] auto notificationMs() const -> int { return notification_ms_; }
|
||||
[[nodiscard]] auto exitMs() const -> int { return exit_ms_; }
|
||||
|
||||
Reference in new issue
Block a user