wayland rewrite complete

This commit is contained in:
Jorijn van der Graaf 2025-11-24 01:47:49 +01:00
commit 721ff8f42f
8 changed files with 134 additions and 87 deletions

View file

@ -9,8 +9,8 @@ int main() {
// Listen for left mouse click events on the window
// The callback receives the MousePoint struct containing the click coordinates in float pixels from the top left corner
EventListener<MousePoint> clickListener(&window.onMouseLeftClick, [&window](MousePoint point){
// Print the coordinates where the user clicked
std::cout << std::format("Clicked on X:{} Y:{}!", MappedToPixel(point.x, window.width), MappedToPixel(point.y, window.height)) << std::endl;
// Print the coordinates where the user clicked, we recieve the point in mapped space so we must convert it to pixels first
std::cout << std::format("Clicked on X:{} Y:{}!", MappedToPixelBoundless(point.x, window.width), MappedToPixelBoundless(point.y, window.height)) << std::endl;
});
// Listen specifically for the 'a' key being pressed down

View file

@ -20,13 +20,24 @@ int main() {
);
window.elements.push_back(element);
window.mouseElements.push_back(element);
element->UpdatePosition(window);
window.ScaleMouse(element->UiElementMouse::transform, element->UiElement::transform);
EventListener<MousePoint> clickListener(&element.onMouseLeftClick, [](MousePoint point){
EventListener<MousePoint> clickListener(&element->onMouseLeftClick, [element, &window](MousePoint point){
// Print the coordinates where the user clicked relative to the element's top left corner.
std::cout << std::format("Clicked on X:{} Y:{}!", point.x, point.y) << std::endl;
//Mapped space
std::cout << std::format("Clicked on Mapped X:{} Y:{}!", point.x, point.y) << std::endl;
// Fraction space
std::cout << std::format("Clicked on Fraction X:{} Y:{}!", MappedToFractionalBoundless(point.x), MappedToFractionalBoundless(point.y)) << std::endl;
// Screen space
std::cout << std::format("Clicked on Screen X:{} Y:{}!\n", MappedToPixelBoundless(point.x, MappedToPixelBoundless(element->UiElementMouse::transform.scaled.width, window.width)), MappedToPixelBoundless(element->UiElementMouse::transform.scaled.height, window.height)) << std::endl;
});
element->buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
window.Render();