AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
SVGScriptElement.hpp
Go to the documentation of this file.
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*/
20#ifndef AEONGUI_SVGSCRIPTELEMENT_H
21#define AEONGUI_SVGSCRIPTELEMENT_H
22
23#include <string>
24#include <vector>
25#include <memory>
26#include "SVGElement.hpp"
27#include "aeongui/PluginAPI.h"
28
29namespace AeonGUI
30{
31 namespace DOM
32 {
33 class CallbackEventListener;
34
53 {
54 public:
60 SVGScriptElement ( const DOMString& aTagName, AttributeMap&& aAttributes, Node* aParent );
61
63 ~SVGScriptElement() override;
64
68 bool IsDrawEnabled() const override;
69
71 void OnLoad() override;
72
74 void OnUnload() override;
75
76 private:
81 std::vector<std::string> BuildLibraryPaths ( const std::string& aHref ) const;
82
86 void LoadLibrary ( const std::string& aPath );
87
89 void UnloadLibrary();
90
91 // Static C API callbacks (implementations delegate to C++ DOM)
92 static AeonGUI_Element* API_getElementById ( AeonGUI_Document* doc, const char* id );
93 static void API_addEventListener ( AeonGUI_Element* element, const char* type, AeonGUI_EventCallback callback, void* userData );
94 static void API_removeEventListener ( AeonGUI_Element* element, const char* type, AeonGUI_EventCallback callback, void* userData );
95 static const char* API_getAttribute ( AeonGUI_Element* element, const char* name );
96 static void API_setAttribute ( AeonGUI_Element* element, const char* name, const char* value );
97 static const char* API_getEventType ( AeonGUI_Event* event );
98 static AeonGUI_Element* API_querySelector ( AeonGUI_Element* element, const char* selector );
99
100 void* mLibHandle {nullptr};
101 AeonGUI_OnLoadFunc mOnLoadFunc {nullptr};
102 AeonGUI_OnUnloadFunc mOnUnloadFunc{nullptr};
103 AeonGUI_PluginContext mContext{};
104
106 struct RegisteredCallback
107 {
108 Element* element;
109 std::string eventType;
110 std::unique_ptr<CallbackEventListener> listener;
111 };
112 std::vector<RegisteredCallback> mCallbacks;
113
115 static thread_local SVGScriptElement* sActiveScriptElement;
116 };
117 }
118}
119#endif
C API for AeonGUI native plugins.
void(* AeonGUI_OnLoadFunc)(AeonGUI_PluginContext *ctx)
Plugin entry point — called after the document is loaded.
Definition PluginAPI.h:152
struct AeonGUI_Document_s AeonGUI_Document
Opaque handle to a Document.
Definition PluginAPI.h:67
struct AeonGUI_Element_s AeonGUI_Element
Opaque handle to an Element.
Definition PluginAPI.h:69
struct AeonGUI_Event_s AeonGUI_Event
Opaque handle to an Event.
Definition PluginAPI.h:71
void(* AeonGUI_EventCallback)(AeonGUI_Event *event, void *userData)
Callback type for event listeners.
Definition PluginAPI.h:77
void(* AeonGUI_OnUnloadFunc)(AeonGUI_PluginContext *ctx)
Plugin cleanup — called before the document is unloaded.
Definition PluginAPI.h:162
Base class for DOM elements.
Definition Element.hpp:46
Base class for all nodes in the DOM tree.
Definition Node.hpp:42
SVGElement(const DOMString &aTagName, AttributeMap &&aAttributes, Node *aParent)
Construct an SVGElement.
Definition SVGElement.cpp:22
void OnLoad() override
Called after document load — loads the native plugin.
Definition SVGScriptElement.cpp:216
SVGScriptElement(const DOMString &aTagName, AttributeMap &&aAttributes, Node *aParent)
Construct an SVGScriptElement.
Definition SVGScriptElement.cpp:102
~SVGScriptElement() override
Destructor. Unloads the plugin if loaded.
Definition SVGScriptElement.cpp:107
void OnUnload() override
Called before document unload — unloads the native plugin.
Definition SVGScriptElement.cpp:297
bool IsDrawEnabled() const override
Not drawable.
Definition SVGScriptElement.cpp:112
Plugin context passed to OnLoad and OnUnload.
Definition PluginAPI.h:87