import Crafter.Event; import Crafter.Graphics; import std; using namespace Crafter; int main() { WindowWayland window(1280, 720, "Hello Input!"); RenderingElement element( { FractionalToMapped(0.5), //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor FractionalToMapped(0.5), //anchorY: relative position where this elements y anchor (top-left) is placed to its parent y anchor FractionalToMapped(0.5), //relativeSizeX: the relative x size this element should be scaled to compared to its parent FractionalToMapped(0.5), //relativeSizeY: the relative y size this element should be scaled to compared to its parent FractionalToMapped(0.5), //anchorOffsetX: the amount this element's anchor should be offset from the top left corner (0.5 to in the middle) FractionalToMapped(0.5), //anchorOffsetY: the amount this element's anchor should be offset from the top left corner (0.5 to place it in the middle) 0 //z: this elements Z position }, OpaqueType::FullyOpaque, 2, 1 ); MouseElement mouse(window); element.children.push_back(&mouse); window.elements.push_back(&element); element.scalingBuffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}}; element.UpdatePosition(window); EventListener clickListener(&mouse.onMouseLeftClick, [&mouse, &window](MousePoint point) { // Print the coordinates where the user clicked relative to the element's top left corner. std::println("Clicked on Mapped X:{} Y:{}!\nClicked on Fraction X:{} Y:{}!\nClicked on Screen X:{} Y:{}!\n", //Mapped space point.x, point.y, // Fraction space MappedToFractionalBoundless(point.x), MappedToFractionalBoundless(point.y), // Screen space MappedToAbsoluteBoundless(point.x, MappedToAbsoluteBoundless(mouse.mouseScaled.width, window.width)), MappedToAbsoluteBoundless(point.y, MappedToAbsoluteBoundless(mouse.mouseScaled.width, window.height)) ); }); window.Render(); window.StartSync(); }