oh yeah its rewrite time
This commit is contained in:
parent
02a6a64c56
commit
1c4f476f18
7 changed files with 183 additions and 154 deletions
|
|
@ -6,7 +6,7 @@ using namespace Crafter;
|
|||
int main() {
|
||||
WindowWayland window(1280, 720, "Hello Input!");
|
||||
|
||||
UiElement* element = new UiElement(
|
||||
RenderingMouseElement element(
|
||||
2, //bufferWidth: the width of this elements pixel buffer
|
||||
1, //bufferHeight: the height of this elements pixel buffer
|
||||
FractionalToMapped(0.5), //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor
|
||||
|
|
@ -19,14 +19,13 @@ int main() {
|
|||
false //ignoreScaling: wether this element ignores the scaling of the window, if true its size will be scaled according to the window scale
|
||||
);
|
||||
|
||||
window.elements.push_back(element);
|
||||
window.mouseElements.push_back(element);
|
||||
window.elements.push_back(&element.rendering);
|
||||
window.mouseElements.push_back(&element.mouse);
|
||||
|
||||
element->buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
|
||||
element->UpdatePosition(window);
|
||||
window.ScaleMouse(element->mouseTransform, element->transform);
|
||||
element.rendering.buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
|
||||
element.UpdatePosition(window);
|
||||
|
||||
EventListener<MousePoint> clickListener(&element->onMouseLeftClick, [element, &window](MousePoint point){
|
||||
EventListener<MousePoint> clickListener(&element.mouse.onMouseLeftClick, [&element, &window](MousePoint point){
|
||||
// Print the coordinates where the user clicked relative to the element's top left corner.
|
||||
|
||||
//Mapped space
|
||||
|
|
@ -36,7 +35,7 @@ int main() {
|
|||
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->mouseTransform.scaled.width, window.width)), MappedToPixelBoundless(point.y, window.height)) << std::endl;
|
||||
std::cout << std::format("Clicked on Screen X:{} Y:{}!\n", MappedToPixelBoundless(point.x, MappedToPixelBoundless(element.mouse.transform.scaled.width, window.width)), MappedToPixelBoundless(point.y, MappedToPixelBoundless(element.mouse.transform.scaled.width, window.height))) << std::endl;
|
||||
});
|
||||
|
||||
window.Render();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue