lifecycle update
This commit is contained in:
parent
84ce42f106
commit
0b7a43efbd
14 changed files with 950 additions and 490 deletions
|
|
@ -5,82 +5,82 @@ import :BindingsImport;
|
|||
|
||||
export namespace Crafter::CppDOMBindings {
|
||||
std::int32_t clickHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* clickHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> clickHandlers;
|
||||
|
||||
std::int32_t mouseOverHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseOverHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseOverHandlers;
|
||||
|
||||
std::int32_t mouseOutHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseOutHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseOutHandlers;
|
||||
|
||||
std::int32_t mouseMoveHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseMoveHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseMoveHandlers;
|
||||
|
||||
std::int32_t mouseDownHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseDownHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseDownHandlers;
|
||||
|
||||
std::int32_t mouseUpHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* mouseUpHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> mouseUpHandlers;
|
||||
|
||||
std::int32_t focusHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>* focusHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>> focusHandlers;
|
||||
|
||||
std::int32_t blurHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>* blurHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::FocusEvent)>> blurHandlers;
|
||||
|
||||
std::int32_t keyDownHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>* keyDownHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>> keyDownHandlers;
|
||||
|
||||
std::int32_t keyUpHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>* keyUpHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>> keyUpHandlers;
|
||||
|
||||
std::int32_t keyPressHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>* keyPressHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::KeyboardEvent)>> keyPressHandlers;
|
||||
|
||||
std::int32_t changeHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ChangeEvent)>>* changeHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::ChangeEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ChangeEvent)>> changeHandlers;
|
||||
|
||||
std::int32_t submitHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(void)>>* submitHandlers = new std::unordered_map<std::int32_t, std::function<void(void)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(void)>> submitHandlers;
|
||||
|
||||
std::int32_t inputHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::InputEvent)>>* inputHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::InputEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::InputEvent)>> inputHandlers;
|
||||
|
||||
std::int32_t resizeHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ResizeEvent)>>* resizeHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::ResizeEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ResizeEvent)>> resizeHandlers;
|
||||
|
||||
std::int32_t scrollHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ScrollEvent)>>* scrollHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::ScrollEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::ScrollEvent)>> scrollHandlers;
|
||||
|
||||
std::int32_t contextMenuHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* contextMenuHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> contextMenuHandlers;
|
||||
|
||||
std::int32_t dragStartHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragStartHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragStartHandlers;
|
||||
|
||||
std::int32_t dragEndHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragEndHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragEndHandlers;
|
||||
|
||||
std::int32_t dropHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dropHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dropHandlers;
|
||||
|
||||
std::int32_t wheelHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::WheelEvent)>>* wheelHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::WheelEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::WheelEvent)>> wheelHandlers;
|
||||
|
||||
std::int32_t dragOverHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragOverHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragOverHandlers;
|
||||
|
||||
std::int32_t dragEnterHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragEnterHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragEnterHandlers;
|
||||
|
||||
std::int32_t dragLeaveHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>* dragLeaveHandlers = new std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(Crafter::MouseEvent)>> dragLeaveHandlers;
|
||||
|
||||
std::int32_t popStateHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(void)>>* popStateHandlers = new std::unordered_map<std::int32_t, std::function<void(void)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(void)>> popStateHandlers;
|
||||
|
||||
std::int32_t fetchHandlerMaxId = 0;
|
||||
std::unordered_map<std::int32_t, std::function<void(std::string)>>* fetchHandlers = new std::unordered_map<std::int32_t, std::function<void(std::string)>>();
|
||||
std::unordered_map<std::int32_t, std::function<void(std::string)>> fetchHandlers;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
@ -92,114 +92,110 @@ extern "C" {
|
|||
std::free(ptr);
|
||||
}
|
||||
|
||||
__attribute__((export_name("deleteElement"))) void DeleteElement(void* ptr) {
|
||||
// This will be implemented in JavaScript
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteClickHandler"))) void ExecuteClickHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::clickHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::clickHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseOverHandler"))) void ExecuteMouseOverHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::mouseOverHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::mouseOverHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseOutHandler"))) void ExecuteMouseOutHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::mouseOutHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::mouseOutHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseMoveHandler"))) void ExecuteMouseMoveHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::mouseMoveHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::mouseMoveHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseDownHandler"))) void ExecuteMouseDownHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button,std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::mouseDownHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::mouseDownHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseUpHandler"))) void ExecuteMouseUpHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::mouseUpHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::mouseUpHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteFocusHandler"))) void ExecuteFocusHandler(std::int32_t handlerID, void* target, void* relatedTarget) {
|
||||
Crafter::CppDOMBindings::focusHandlers->find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
||||
Crafter::CppDOMBindings::focusHandlers.find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteBlurHandler"))) void ExecuteBlurHandler(std::int32_t handlerID, void* target, void* relatedTarget) {
|
||||
Crafter::CppDOMBindings::blurHandlers->find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
||||
Crafter::CppDOMBindings::blurHandlers.find(handlerID)->second(Crafter::FocusEvent(target, relatedTarget));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteKeyDownHandler"))) void ExecuteKeyDownHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::keyDownHandlers->find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::keyDownHandlers.find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteKeyUpHandler"))) void ExecuteKeyUpHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::keyUpHandlers->find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::keyUpHandlers.find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteKeyPressHandler"))) void ExecuteKeyPressHandler(std::int32_t handlerID, const char* key, std::int32_t keyCode, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::keyPressHandlers->find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::keyPressHandlers.find(handlerID)->second(Crafter::KeyboardEvent(key, keyCode, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteChangeHandler"))) void ExecuteChangeHandler(std::int32_t handlerID, const char* value) {
|
||||
Crafter::CppDOMBindings::changeHandlers->find(handlerID)->second(Crafter::ChangeEvent(value));
|
||||
Crafter::CppDOMBindings::changeHandlers.find(handlerID)->second(Crafter::ChangeEvent(value));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteSubmitHandler"))) void ExecuteSubmitHandler(std::int32_t handlerID) {
|
||||
Crafter::CppDOMBindings::submitHandlers->find(handlerID)->second();
|
||||
Crafter::CppDOMBindings::submitHandlers.find(handlerID)->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteInputHandler"))) void ExecuteInputHandler(std::int32_t handlerID, const char* data, bool isComposing) {
|
||||
Crafter::CppDOMBindings::inputHandlers->find(handlerID)->second(Crafter::InputEvent(data, isComposing));
|
||||
Crafter::CppDOMBindings::inputHandlers.find(handlerID)->second(Crafter::InputEvent(data, isComposing));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteResizeHandler"))) void ExecuteResizeHandler(std::int32_t handlerID, std::int32_t width, std::int32_t height) {
|
||||
Crafter::CppDOMBindings::resizeHandlers->find(handlerID)->second(Crafter::ResizeEvent(width, height));
|
||||
Crafter::CppDOMBindings::resizeHandlers.find(handlerID)->second(Crafter::ResizeEvent(width, height));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteScrollHandler"))) void ExecuteScrollHandler(std::int32_t handlerID, double scrollX, double scrollY) {
|
||||
Crafter::CppDOMBindings::scrollHandlers->find(handlerID)->second(Crafter::ScrollEvent(scrollX, scrollY));
|
||||
Crafter::CppDOMBindings::scrollHandlers.find(handlerID)->second(Crafter::ScrollEvent(scrollX, scrollY));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteContextMenuHandler"))) void ExecuteContextMenuHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::contextMenuHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::contextMenuHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragStartHandler"))) void ExecuteDragStartHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::dragStartHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::dragStartHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragEndHandler"))) void ExecuteDragEndHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::dragEndHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::dragEndHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDropHandler"))) void ExecuteDropHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::dropHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::dropHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteWheelHandler"))) void ExecuteWheelHandler(std::int32_t handlerID, double deltaX, double deltaY, double deltaZ, std::int32_t deltaMode, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::wheelHandlers->find(handlerID)->second(Crafter::WheelEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey, deltaX, deltaY, deltaZ));
|
||||
Crafter::CppDOMBindings::wheelHandlers.find(handlerID)->second(Crafter::WheelEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey, deltaX, deltaY, deltaZ));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragOverHandler"))) void ExecuteDragOverHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::dragOverHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::dragOverHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragEnterHandler"))) void ExecuteDragEnterHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::dragEnterHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::dragEnterHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragLeaveHandler"))) void ExecuteDragLeaveHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
|
||||
Crafter::CppDOMBindings::dragLeaveHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
Crafter::CppDOMBindings::dragLeaveHandlers.find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteFetchHandler"))) void ExecuteFetchHandler(std::int32_t handlerID, const char* response) {
|
||||
std::cout << handlerID << std::endl;
|
||||
Crafter::CppDOMBindings::fetchHandlers->find(handlerID)->second(response);
|
||||
Crafter::CppDOMBindings::fetchHandlers->erase(handlerID);
|
||||
Crafter::CppDOMBindings::fetchHandlers.find(handlerID)->second(response);
|
||||
Crafter::CppDOMBindings::fetchHandlers.erase(handlerID);
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecutePopStateHandler"))) void ExecutePopStateHandler(std::int32_t handlerID) {
|
||||
Crafter::CppDOMBindings::popStateHandlers->find(handlerID)->second();
|
||||
Crafter::CppDOMBindings::popStateHandlers.find(handlerID)->second();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,12 +204,12 @@ export namespace Crafter::CppDOMBindings {
|
|||
__attribute__((import_module("env"), import_name("fetchWithBody"))) void FetchWithBody(const char* url, std::int32_t urlLenght, const char* body, std::int32_t bodyLength, std::int32_t handlerID);
|
||||
void Fetch(const std::string_view url, std::function<void(std::string)> callback) {
|
||||
std::int32_t id = fetchHandlerMaxId++;
|
||||
CppDOMBindings::fetchHandlers->insert({id, callback});
|
||||
CppDOMBindings::fetchHandlers.insert({id, callback});
|
||||
Fetch(url.data(), url.size(), id);
|
||||
}
|
||||
void Fetch(const std::string_view url, const std::string_view body, std::function<void(std::string)> callback) {
|
||||
std::int32_t id = fetchHandlerMaxId++;
|
||||
CppDOMBindings::fetchHandlers->insert({id, callback});
|
||||
CppDOMBindings::fetchHandlers.insert({id, callback});
|
||||
FetchWithBody(url.data(), url.size(), body.data(), body.size(), id);
|
||||
}
|
||||
|
||||
|
|
@ -225,14 +221,14 @@ export namespace Crafter::CppDOMBindings {
|
|||
|
||||
std::int32_t AddPopStateListener(std::function<void(void)> callback) {
|
||||
std::int32_t id = popStateHandlerMaxId++;
|
||||
popStateHandlers->insert({id, callback});
|
||||
popStateHandlers.insert({id, callback});
|
||||
AddPopStateListener(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemovePopStateListener(std::int32_t id) {
|
||||
RemovePopStateListener(id);
|
||||
popStateHandlers->erase(id);
|
||||
popStateHandlers.erase(id);
|
||||
}
|
||||
|
||||
void PushState(const std::string_view data, const std::string_view title, const std::string_view url) {
|
||||
|
|
|
|||
|
|
@ -23,131 +23,131 @@ import std;
|
|||
import :EventTypes;
|
||||
|
||||
export namespace Crafter::CppDOMBindings {
|
||||
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr);
|
||||
__attribute__((import_module("env"), import_name("getElementById"))) void* GetElementById(const char* id, std::int32_t idLenght);
|
||||
void* GetElementById(const std::string_view id) {
|
||||
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(std::int32_t ptr);
|
||||
__attribute__((import_module("env"), import_name("getElementById"))) std::int32_t GetElementById(const char* id, std::int32_t idLenght);
|
||||
std::int32_t GetElementById(const std::string_view id) {
|
||||
return GetElementById(id.data(), id.size());
|
||||
}
|
||||
__attribute__((import_module("env"), import_name("setInnerHTML"))) void SetInnerHTML(void* ptr, const char* html, std::int32_t htmlLenght);
|
||||
void SetInnerHTML(void* ptr, const std::string_view html) {
|
||||
__attribute__((import_module("env"), import_name("setInnerHTML"))) void SetInnerHTML(std::int32_t ptr, const char* html, std::int32_t htmlLenght);
|
||||
void SetInnerHTML(std::int32_t ptr, const std::string_view html) {
|
||||
std::cout << "bind" << std::endl;
|
||||
SetInnerHTML(ptr, html.data(), html.size());
|
||||
}
|
||||
|
||||
// Event handling functions
|
||||
__attribute__((import_module("env"), import_name("addClickListener"))) void AddClickListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeClickListener"))) void RemoveClickListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addClickListener"))) void AddClickListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeClickListener"))) void RemoveClickListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseOverListener"))) void AddMouseOverListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseOverListener"))) void RemoveMouseOverListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addMouseOverListener"))) void AddMouseOverListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseOverListener"))) void RemoveMouseOverListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseOutListener"))) void AddMouseOutListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseOutListener"))) void RemoveMouseOutListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addMouseOutListener"))) void AddMouseOutListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseOutListener"))) void RemoveMouseOutListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseMoveListener"))) void AddMouseMoveListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseMoveListener"))) void RemoveMouseMoveListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addMouseMoveListener"))) void AddMouseMoveListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseMoveListener"))) void RemoveMouseMoveListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseDownListener"))) void AddMouseDownListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseDownListener"))) void RemoveMouseDownListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addMouseDownListener"))) void AddMouseDownListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseDownListener"))) void RemoveMouseDownListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseUpListener"))) void AddMouseUpListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseUpListener"))) void RemoveMouseUpListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addMouseUpListener"))) void AddMouseUpListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseUpListener"))) void RemoveMouseUpListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addFocusListener"))) void AddFocusListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeFocusListener"))) void RemoveFocusListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addFocusListener"))) void AddFocusListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeFocusListener"))) void RemoveFocusListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addBlurListener"))) void AddBlurListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeBlurListener"))) void RemoveBlurListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addBlurListener"))) void AddBlurListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeBlurListener"))) void RemoveBlurListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addKeyDownListener"))) void AddKeyDownListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyDownListener"))) void RemoveKeyDownListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addKeyDownListener"))) void AddKeyDownListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyDownListener"))) void RemoveKeyDownListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addKeyUpListener"))) void AddKeyUpListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyUpListener"))) void RemoveKeyUpListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addKeyUpListener"))) void AddKeyUpListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyUpListener"))) void RemoveKeyUpListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addKeyPressListener"))) void AddKeyPressListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyPressListener"))) void RemoveKeyPressListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addKeyPressListener"))) void AddKeyPressListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyPressListener"))) void RemoveKeyPressListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addChangeListener"))) void AddChangeListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeChangeListener"))) void RemoveChangeListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addChangeListener"))) void AddChangeListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeChangeListener"))) void RemoveChangeListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addSubmitListener"))) void AddSubmitListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeSubmitListener"))) void RemoveSubmitListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addSubmitListener"))) void AddSubmitListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeSubmitListener"))) void RemoveSubmitListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addInputListener"))) void AddInputListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeInputListener"))) void RemoveInputListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addInputListener"))) void AddInputListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeInputListener"))) void RemoveInputListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addResizeListener"))) void AddResizeListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeResizeListener"))) void RemoveResizeListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addResizeListener"))) void AddResizeListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeResizeListener"))) void RemoveResizeListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addScrollListener"))) void AddScrollListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeScrollListener"))) void RemoveScrollListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addScrollListener"))) void AddScrollListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeScrollListener"))) void RemoveScrollListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addContextMenuListener"))) void AddContextMenuListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeContextMenuListener"))) void RemoveContextMenuListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addContextMenuListener"))) void AddContextMenuListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeContextMenuListener"))) void RemoveContextMenuListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragStartListener"))) void AddDragStartListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragStartListener"))) void RemoveDragStartListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addDragStartListener"))) void AddDragStartListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeDragStartListener"))) void RemoveDragStartListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragEndListener"))) void AddDragEndListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragEndListener"))) void RemoveDragEndListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addDragEndListener"))) void AddDragEndListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeDragEndListener"))) void RemoveDragEndListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDropListener"))) void AddDropListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDropListener"))) void RemoveDropListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addDropListener"))) void AddDropListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeDropListener"))) void RemoveDropListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addWheelListener"))) void AddWheelListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeWheelListener"))) void RemoveWheelListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addWheelListener"))) void AddWheelListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeWheelListener"))) void RemoveWheelListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragOverListener"))) void AddDragOverListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragOverListener"))) void RemoveDragOverListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addDragOverListener"))) void AddDragOverListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeDragOverListener"))) void RemoveDragOverListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragEnterListener"))) void AddDragEnterListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragEnterListener"))) void RemoveDragEnterListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addDragEnterListener"))) void AddDragEnterListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeDragEnterListener"))) void RemoveDragEnterListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragLeaveListener"))) void AddDragLeaveListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragLeaveListener"))) void RemoveDragLeaveListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("addDragLeaveListener"))) void AddDragLeaveListener(std::int32_t ptr, std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removeDragLeaveListener"))) void RemoveDragLeaveListener(std::int32_t ptr, std::int32_t id);
|
||||
|
||||
// Style functions
|
||||
__attribute__((import_module("env"), import_name("setStyle"))) void SetStyle(void* ptr, const char* style, std::int32_t styleLength);
|
||||
void SetStyle(void* ptr, const std::string_view style) {
|
||||
__attribute__((import_module("env"), import_name("setStyle"))) void SetStyle(std::int32_t ptr, const char* style, std::int32_t styleLength);
|
||||
void SetStyle(std::int32_t ptr, const std::string_view style) {
|
||||
SetStyle(ptr, style.data(), style.size());
|
||||
}
|
||||
|
||||
__attribute__((import_module("env"), import_name("setProperty"))) void SetProperty(void* ptr, const char* property, std::int32_t propertyLength, const char* value, std::int32_t valueLength);
|
||||
void SetProperty(void* ptr, const std::string_view property, const std::string_view value) {
|
||||
__attribute__((import_module("env"), import_name("setProperty"))) void SetProperty(std::int32_t ptr, const char* property, std::int32_t propertyLength, const char* value, std::int32_t valueLength);
|
||||
void SetProperty(std::int32_t ptr, const std::string_view property, const std::string_view value) {
|
||||
SetProperty(ptr, property.data(), property.size(), value.data(), value.size());
|
||||
}
|
||||
|
||||
__attribute__((import_module("env"), import_name("addClass"))) void AddClass(void* ptr, const char* className, std::int32_t classNameLength);
|
||||
void AddClass(void* ptr, const std::string_view className) {
|
||||
__attribute__((import_module("env"), import_name("addClass"))) void AddClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||
void AddClass(std::int32_t ptr, const std::string_view className) {
|
||||
AddClass(ptr, className.data(), className.size());
|
||||
}
|
||||
|
||||
__attribute__((import_module("env"), import_name("removeClass"))) void RemoveClass(void* ptr, const char* className, std::int32_t classNameLength);
|
||||
void RemoveClass(void* ptr, const std::string_view className) {
|
||||
__attribute__((import_module("env"), import_name("removeClass"))) void RemoveClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||
void RemoveClass(std::int32_t ptr, const std::string_view className) {
|
||||
RemoveClass(ptr, className.data(), className.size());
|
||||
}
|
||||
|
||||
__attribute__((import_module("env"), import_name("toggleClass"))) void ToggleClass(void* ptr, const char* className, std::int32_t classNameLength);
|
||||
void ToggleClass(void* ptr, const std::string_view className) {
|
||||
__attribute__((import_module("env"), import_name("toggleClass"))) void ToggleClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||
void ToggleClass(std::int32_t ptr, const std::string_view className) {
|
||||
ToggleClass(ptr, className.data(), className.size());
|
||||
}
|
||||
|
||||
__attribute__((import_module("env"), import_name("hasClass"))) bool HasClass(void* ptr, const char* className, std::int32_t classNameLength);
|
||||
bool HasClass(void* ptr, const std::string_view className) {
|
||||
__attribute__((import_module("env"), import_name("hasClass"))) bool HasClass(std::int32_t ptr, const char* className, std::int32_t classNameLength);
|
||||
bool HasClass(std::int32_t ptr, const std::string_view className) {
|
||||
return HasClass(ptr, className.data(), className.size());
|
||||
}
|
||||
|
||||
__attribute__((import_module("env"), import_name("deleteElement"))) void DeleteElement(void* ptr);
|
||||
__attribute__((import_module("env"), import_name("deleteElement"))) void DeleteElement(std::int32_t ptr);
|
||||
|
||||
// Value property functions
|
||||
__attribute__((import_module("env"), import_name("getValue"))) const char* GetValue(void* ptr);
|
||||
__attribute__((import_module("env"), import_name("getValue"))) const char* GetValue(std::int32_t ptr);
|
||||
__attribute__((import_module("env"), import_name("getPathName"))) const char* GetPathName();
|
||||
__attribute__((import_module("env"), import_name("addPopStateListener"))) void AddPopStateListener(int id);
|
||||
__attribute__((import_module("env"), import_name("removePopStateListener"))) void RemovePopStateListener(int id);
|
||||
__attribute__((import_module("env"), import_name("addPopStateListener"))) void AddPopStateListener(std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("removePopStateListener"))) void RemovePopStateListener(std::int32_t id);
|
||||
__attribute__((import_module("env"), import_name("pushState"))) void PushState(const char* data, std::int32_t dataLength, const char* title, std::int32_t titleLength, const char* url, std::int32_t urlLength);
|
||||
__attribute__((import_module("env"), import_name("setValue"))) void SetValue(void* ptr, const char* value, std::int32_t valueLength);
|
||||
void SetValue(void* ptr, const std::string_view value) {
|
||||
__attribute__((import_module("env"), import_name("setValue"))) void SetValue(std::int32_t ptr, const char* value, std::int32_t valueLength);
|
||||
void SetValue(std::int32_t ptr, const std::string_view value) {
|
||||
SetValue(ptr, value.data(), value.size());
|
||||
}
|
||||
}
|
||||
|
|
@ -25,40 +25,16 @@ import :BindingsImport;
|
|||
import :EventTypes;
|
||||
|
||||
namespace Crafter {
|
||||
export class HtmlElementView {
|
||||
export class HtmlElementPtr {
|
||||
public:
|
||||
void* ptr;
|
||||
std::vector<std::int32_t> clickHandlers;
|
||||
std::vector<std::int32_t> mouseOverHandlers;
|
||||
std::vector<std::int32_t> mouseOutHandlers;
|
||||
std::vector<std::int32_t> mouseMoveHandlers;
|
||||
std::vector<std::int32_t> mouseDownHandlers;
|
||||
std::vector<std::int32_t> mouseUpHandlers;
|
||||
std::vector<std::int32_t> focusHandlers;
|
||||
std::vector<std::int32_t> blurHandlers;
|
||||
std::vector<std::int32_t> keyDownHandlers;
|
||||
std::vector<std::int32_t> keyUpHandlers;
|
||||
std::vector<std::int32_t> keyPressHandlers;
|
||||
std::vector<std::int32_t> changeHandlers;
|
||||
std::vector<std::int32_t> submitHandlers;
|
||||
std::vector<std::int32_t> inputHandlers;
|
||||
std::vector<std::int32_t> resizeHandlers;
|
||||
std::vector<std::int32_t> scrollHandlers;
|
||||
std::vector<std::int32_t> contextMenuHandlers;
|
||||
std::vector<std::int32_t> dragStartHandlers;
|
||||
std::vector<std::int32_t> dragEndHandlers;
|
||||
std::vector<std::int32_t> dropHandlers;
|
||||
std::vector<std::int32_t> dragOverHandlers;
|
||||
std::vector<std::int32_t> dragEnterHandlers;
|
||||
std::vector<std::int32_t> dragLeaveHandlers;
|
||||
std::vector<std::int32_t> wheelHandlers;
|
||||
|
||||
HtmlElementView(const std::string_view id);
|
||||
HtmlElementView(const std::string_view id, const std::string_view html);
|
||||
HtmlElementView(HtmlElementView&&);
|
||||
HtmlElementView(const HtmlElementView&) = delete;
|
||||
HtmlElementView& operator=(const HtmlElementView&) = delete;
|
||||
~HtmlElementView();
|
||||
std::int32_t ptr;
|
||||
HtmlElementPtr(const std::string_view id);
|
||||
HtmlElementPtr(const std::string_view id, const std::string_view html);
|
||||
HtmlElementPtr(HtmlElementPtr&&);
|
||||
HtmlElementPtr(const HtmlElementPtr&) = delete;
|
||||
HtmlElementPtr& operator=(const HtmlElementPtr&) = delete;
|
||||
~HtmlElementPtr();
|
||||
|
||||
void SetInnerHTML(const std::string_view html);
|
||||
void SetStyle(const std::string_view style);
|
||||
void SetProperty(const std::string_view property, const std::string_view value);
|
||||
|
|
@ -67,7 +43,6 @@ namespace Crafter {
|
|||
void ToggleClass(const std::string_view className);
|
||||
bool HasClass(const std::string_view className);
|
||||
|
||||
// Value property accessors
|
||||
std::string GetValue();
|
||||
void SetValue(const std::string_view value);
|
||||
|
||||
|
|
@ -144,13 +119,117 @@ namespace Crafter {
|
|||
void RemoveWheelListener(std::int32_t id);
|
||||
};
|
||||
|
||||
export class HtmlElementView : public HtmlElementPtr {
|
||||
public:
|
||||
HtmlElementView(const std::string_view id);
|
||||
HtmlElementView(const std::string_view id, const std::string_view html);
|
||||
HtmlElementView(HtmlElementView&&);
|
||||
~HtmlElementView();
|
||||
|
||||
std::int32_t AddClickListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||
void RemoveClickListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddMouseOverListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||
void RemoveMouseOverListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddMouseOutListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||
void RemoveMouseOutListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddMouseMoveListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||
void RemoveMouseMoveListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddMouseDownListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||
void RemoveMouseDownListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddMouseUpListener(std::function<void(Crafter::MouseEvent)> callback);
|
||||
void RemoveMouseUpListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddFocusListener(std::function<void(Crafter::FocusEvent)> callback);
|
||||
void RemoveFocusListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddBlurListener(std::function<void(Crafter::FocusEvent)> callback);
|
||||
void RemoveBlurListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddKeyDownListener(std::function<void(KeyboardEvent)> callback);
|
||||
void RemoveKeyDownListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddKeyUpListener(std::function<void(KeyboardEvent)> callback);
|
||||
void RemoveKeyUpListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddKeyPressListener(std::function<void(KeyboardEvent)> callback);
|
||||
void RemoveKeyPressListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddChangeListener(std::function<void(ChangeEvent)> callback);
|
||||
void RemoveChangeListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddSubmitListener(std::function<void(void)> callback);
|
||||
void RemoveSubmitListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddInputListener(std::function<void(InputEvent)> callback);
|
||||
void RemoveInputListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddResizeListener(std::function<void(ResizeEvent)> callback);
|
||||
void RemoveResizeListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddScrollListener(std::function<void(ScrollEvent)> callback);
|
||||
void RemoveScrollListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddContextMenuListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveContextMenuListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddDragStartListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveDragStartListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddDragEndListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveDragEndListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddDropListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveDropListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddDragOverListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveDragOverListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddDragEnterListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveDragEnterListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddDragLeaveListener(std::function<void(MouseEvent)> callback);
|
||||
void RemoveDragLeaveListener(std::int32_t id);
|
||||
|
||||
std::int32_t AddWheelListener(std::function<void(WheelEvent)> callback);
|
||||
void RemoveWheelListener(std::int32_t id);
|
||||
|
||||
private:
|
||||
std::vector<std::int32_t> clickHandlers;
|
||||
std::vector<std::int32_t> mouseOverHandlers;
|
||||
std::vector<std::int32_t> mouseOutHandlers;
|
||||
std::vector<std::int32_t> mouseMoveHandlers;
|
||||
std::vector<std::int32_t> mouseDownHandlers;
|
||||
std::vector<std::int32_t> mouseUpHandlers;
|
||||
std::vector<std::int32_t> focusHandlers;
|
||||
std::vector<std::int32_t> blurHandlers;
|
||||
std::vector<std::int32_t> keyDownHandlers;
|
||||
std::vector<std::int32_t> keyUpHandlers;
|
||||
std::vector<std::int32_t> keyPressHandlers;
|
||||
std::vector<std::int32_t> changeHandlers;
|
||||
std::vector<std::int32_t> submitHandlers;
|
||||
std::vector<std::int32_t> inputHandlers;
|
||||
std::vector<std::int32_t> resizeHandlers;
|
||||
std::vector<std::int32_t> scrollHandlers;
|
||||
std::vector<std::int32_t> contextMenuHandlers;
|
||||
std::vector<std::int32_t> dragStartHandlers;
|
||||
std::vector<std::int32_t> dragEndHandlers;
|
||||
std::vector<std::int32_t> dropHandlers;
|
||||
std::vector<std::int32_t> dragOverHandlers;
|
||||
std::vector<std::int32_t> dragEnterHandlers;
|
||||
std::vector<std::int32_t> dragLeaveHandlers;
|
||||
std::vector<std::int32_t> wheelHandlers;
|
||||
};
|
||||
|
||||
export class HtmlElement : public HtmlElementView {
|
||||
public:
|
||||
HtmlElement(const std::string_view id);
|
||||
HtmlElement(const std::string_view id, const std::string_view html);
|
||||
HtmlElement(HtmlElement&&);
|
||||
HtmlElement(const HtmlElement&) = delete;
|
||||
HtmlElement& operator=(const HtmlElement&) = delete;
|
||||
~HtmlElement();
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue