new UI system

This commit is contained in:
Jorijn van der Graaf 2026-05-01 23:35:37 +02:00
commit 216972e73a
82 changed files with 4837 additions and 3243 deletions

View file

@ -1,32 +0,0 @@
# HelloWindow Example
## Description
This example demonstrates how to draw pixels to a window.
## Expected Result
A window with a green and blue colored square, when clicking on the square it logs the coordinates relative to the square.
## Highlighted Code Snippet
```cpp
UiElement& element = window.elements.emplace_back(
0.5,
0.5,
2,
1,
0.5f,
0.5f,
0.5,
0.5,
0,
false
);
```
## How to Run
```bash
crafter-build build executable -r
```

View file

@ -1,40 +0,0 @@
import Crafter.Event;
import Crafter.Graphics;
import std;
using namespace Crafter;
int main() {
Device::Initialize();
Window window(1280, 720, "Hello Drawing!");
RenderingElement2D<true, true, false> element(
{
0.5, //anchorX: relative position where this elements x anchor (top-left) is placed to its parent x anchor
0.5, //anchorY: relative position where this elements y anchor (top-left) is placed to its parent y anchor
0.5, //relativeSizeX: the relative x size this element should be scaled to compared to its parent
0.5, //relativeSizeY: the relative y size this element should be scaled to compared to its parent
0.5, //anchorOffsetX: the amount this element's anchor should be offset from the top left corner (0.5 to in the middle)
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.renderer.elements.push_back(&element);
element.scalingBuffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
element.UpdatePosition(window.renderer);
EventListener<void> clickListener(&mouse.onMouseLeftClick, [&window]() {
std::println("Clicked on X:{} Y:{}!",
window.currentMousePos.x, window.currentMousePos.y
);
});
window.Render();
window.StartSync();
}

View file

@ -1,16 +0,0 @@
{
"name": "crafter-graphics",
"configurations": [
{
"name": "executable",
"implementations": ["main"],
"dependencies": [
{
"path":"../../project.json",
"configuration":"lib-wayland-debug"
}
],
"debug": true
}
]
}