AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
SVGAnimationElement.hpp
1/*
2Copyright (C) 2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_SVGANIMATIONELEMENT_H
17#define AEONGUI_SVGANIMATIONELEMENT_H
18
19#include "SVGElement.hpp"
20#include "EventListener.hpp"
21#include <vector>
22#include <string>
23#include <limits>
24
25namespace AeonGUI
26{
27 class Canvas;
28 namespace DOM
29 {
39 {
40 public:
46 SVGAnimationElement ( const DOMString& aTagName, AttributeMap&& aAttributes, Node* aParent );
48 ~SVGAnimationElement() override;
52 void handleEvent ( Event& event ) override;
56 DLL bool IsDrawEnabled() const override final;
58 DLL void Update ( double aDocumentTime ) override;
62 virtual void ApplyToCanvas ( Canvas& aCanvas ) const = 0;
66 bool IsActive() const;
70 const std::string& GetAttributeName() const
71 {
72 return mAttributeName;
73 }
74 protected:
79 static double ParseDuration ( const std::string& aDuration );
84 static std::vector<std::string> SplitValues ( const std::string& aValues );
85 std::string mAttributeName;
86 double mDuration{0.0};
87 double mBeginTime{0.0};
88 double mRepeatCount{1.0};
89 bool mFreezeOnEnd{false};
90 bool mIsActive{false};
91 double mProgress{0.0};
92 std::string mBeginEventType;
93 double mLastDocumentTime{0.0};
94 };
95 }
96}
97#endif
Abstract 2D rendering surface.
Definition Canvas.hpp:40
Represents a DOM event.
Definition Event.hpp:47
Interface for objects that handle DOM events.
Definition EventListener.hpp:32
Base class for all nodes in the DOM tree.
Definition Node.hpp:42
double mProgress
Normalised progress within one cycle [0,1].
Definition SVGAnimationElement.hpp:91
static double ParseDuration(const std::string &aDuration)
Parse a SMIL duration or clock value string.
Definition SVGAnimationElement.cpp:128
std::string mAttributeName
Target attribute name from the attributeName attribute.
Definition SVGAnimationElement.hpp:85
bool mIsActive
Current activation state.
Definition SVGAnimationElement.hpp:90
bool IsActive() const
Check whether the animation is currently active.
Definition SVGAnimationElement.cpp:88
double mDuration
Animation duration in seconds.
Definition SVGAnimationElement.hpp:86
void handleEvent(Event &event) override
Handle a DOM event (implements EventListener).
Definition SVGAnimationElement.cpp:93
double mBeginTime
Begin time in document seconds.
Definition SVGAnimationElement.hpp:87
bool IsDrawEnabled() const override final
Animation elements are never drawn directly.
Definition SVGAnimationElement.cpp:83
void Update(double aDocumentTime) override
Update animation state for this node.
Definition SVGAnimationElement.cpp:101
~SVGAnimationElement() override
Destructor.
Definition SVGAnimationElement.cpp:75
double mRepeatCount
Number of times to repeat (indefinite = infinity).
Definition SVGAnimationElement.hpp:88
static std::vector< std::string > SplitValues(const std::string &aValues)
Split a semicolon-separated value list.
Definition SVGAnimationElement.cpp:160
bool mFreezeOnEnd
Whether fill="freeze" is set.
Definition SVGAnimationElement.hpp:89
std::string mBeginEventType
Event type for event-based begin, or empty.
Definition SVGAnimationElement.hpp:92
SVGAnimationElement(const DOMString &aTagName, AttributeMap &&aAttributes, Node *aParent)
Construct an SVGAnimationElement.
Definition SVGAnimationElement.cpp:26
const std::string & GetAttributeName() const
Get the target attribute name.
Definition SVGAnimationElement.hpp:70
virtual void ApplyToCanvas(Canvas &aCanvas) const =0
Apply this animation's effect to the canvas.
double mLastDocumentTime
Last document time seen by Update.
Definition SVGAnimationElement.hpp:93
SVGElement(const DOMString &aTagName, AttributeMap &&aAttributes, Node *aParent)
Construct an SVGElement.
Definition SVGElement.cpp:22