rewrite time
This commit is contained in:
parent
d6b9b87da4
commit
4428cfe12c
24 changed files with 1208 additions and 893 deletions
|
|
@ -4,13 +4,13 @@ import std;
|
|||
using namespace Crafter;
|
||||
|
||||
int main() {
|
||||
Window window("HelloWindow", 1280, 720);
|
||||
Window<true, false, false, false> window(1280, 720);
|
||||
|
||||
UiElement& element = window.elements.emplace_back(
|
||||
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
|
||||
UiElement<true, true>& element = window.CreateElement<true, true>(
|
||||
2, //bufferWidth: the width of this elements pixel buffer
|
||||
1, //bufferHeight: the height of this elements pixel buffer
|
||||
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.5f, //relativeSizeX: the relative x size this element should be scaled to compared to its parent
|
||||
0.5f, //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)
|
||||
|
|
@ -19,25 +19,12 @@ 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
|
||||
);
|
||||
|
||||
// UiElement& element = window.elements.emplace_back(
|
||||
// 0.5,
|
||||
// 0.5,
|
||||
// 2,
|
||||
// 1,
|
||||
// uint32_t(100), //absoluteSizeX: the absolute x size in pixels this element should be scaled to
|
||||
// uint32_t(100), //absoluteSizeY: the absolute x size in pixels this element should be scaled to
|
||||
// 0.5,
|
||||
// 0.5,
|
||||
// 0,
|
||||
// false
|
||||
// );
|
||||
// EventListener<MousePoint> clickListener(&element.onMouseLeftClick, [](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;
|
||||
// });
|
||||
|
||||
EventListener<MousePoint> clickListener(&element.onMouseLeftClick, [](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;
|
||||
});
|
||||
|
||||
element.buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
|
||||
window.scale = 1;
|
||||
element.buffer.buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
|
||||
window.framebuffer.Render();
|
||||
window.StartSync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## Description
|
||||
|
||||
This example demonstrates the minimal code needed to create a window and show it on the screen.
|
||||
This example demonstrates the minimal code needed to create a window and show it on the screen. This uses the Framebuffer and Title capability.
|
||||
|
||||
## Expected Result
|
||||
|
||||
|
|
@ -11,7 +11,9 @@ A empty window with the title "HelloWindow" shows onscreen.
|
|||
## Highlighted Code Snippet
|
||||
|
||||
```cpp
|
||||
WindowWaylandWayland window("HelloWindow", 1280, 720);
|
||||
Window<true, true, false, false> window;
|
||||
window.framebuffer.Create(1280, 720);
|
||||
window.title.Set("HelloWindow");
|
||||
window.StartSync();
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -3,18 +3,6 @@ import std;
|
|||
using namespace Crafter;
|
||||
|
||||
int main() {
|
||||
/*
|
||||
This creates a window titled "HelloWindow" with a size of 1280x720 pixels.
|
||||
The WindowWaylandWayland class is a specialized window implementation
|
||||
that uses the Wayland display server protocol and renderer (hence the name "WaylandWayland").
|
||||
*/
|
||||
Window window("HelloWindow", 1280, 720);
|
||||
|
||||
/*
|
||||
This starts the window’s main event loop, allowing it to respond to user input and system events.
|
||||
The window will remain open and responsive until it is closed.
|
||||
You can hook into various events through the event system.
|
||||
This call blocks the current thread; to run the event loop asynchronously, use StartAsync instead.
|
||||
*/
|
||||
Window<true, true, false, false> window(1280, 720, "HelloWindow");
|
||||
window.StartSync();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue