重构渲染流程,使用render_tree来保证嵌套后效正确
This commit is contained in:
60
tests/test_refactor_syntax/test_refactor_syntax.cpp
Normal file
60
tests/test_refactor_syntax/test_refactor_syntax.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "layout/stack.h"
|
||||
#include "button.h"
|
||||
#include "layout/overlay.h"
|
||||
#include "imager.h"
|
||||
#include "post_effect.h"
|
||||
#include "mask/rounded_rect_mask.h"
|
||||
#include "mask/circle_mask.h"
|
||||
#include "mask/mask_widget.h"
|
||||
#include "layout/modifiers/modifiers.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace mirage;
|
||||
using namespace mirage::modifier; // For align, padding, stretch, mask
|
||||
|
||||
void test_syntax() {
|
||||
auto on_click = []() { std::cout << "Clicked!" << std::endl; };
|
||||
uint32_t texture_id_ = 1;
|
||||
vec2i_t texture_size_{100, 100};
|
||||
|
||||
v_stack v{
|
||||
// Standard widget placement
|
||||
button{
|
||||
"Hello",
|
||||
on_click
|
||||
},
|
||||
// Using | pipe operator
|
||||
overlay{
|
||||
// Using pipe syntax for alignment and padding
|
||||
imager{}
|
||||
.texture_id(texture_id_)
|
||||
.fit(image_fit::contain)
|
||||
.set_texture_size(texture_size_)
|
||||
| mask(rounded_rect_mask{}.corner_radius(30.f))
|
||||
| align(alignment::CENTER)
|
||||
| padding(10.f),
|
||||
// Standard post-effect widget
|
||||
post_effect_widget{
|
||||
blur_effect{20.f}
|
||||
},
|
||||
} | stretch(),
|
||||
overlay{
|
||||
imager{}
|
||||
.texture_id(texture_id_)
|
||||
.fit(image_fit::contain)
|
||||
.set_texture_size(texture_size_)
|
||||
| align(alignment::CENTER)
|
||||
| padding(10.f),
|
||||
post_effect_widget{
|
||||
blur_effect{20.f}
|
||||
}
|
||||
} | stretch() | mask(circle_mask{})
|
||||
};
|
||||
|
||||
(void)v; // Suppress unused variable warning
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_syntax();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user