@@ -18,9 +18,9 @@ export enum struct ResizeHandle {
1818
1919struct Resizable : Ui::ProxyNode<Resizable> {
2020 Math::Vec2i _size;
21- Ui::Send<Math::Vec2i> _onChange;
21+ Opt< Ui::Send<Math::Vec2i> > _onChange;
2222
23- Resizable (Ui::Child child, Math::Vec2i size, Ui::Send<Math::Vec2i> onChange)
23+ Resizable (Ui::Child child, Math::Vec2i size, Opt< Ui::Send<Math::Vec2i> > onChange)
2424 : ProxyNode<Resizable>(child),
2525 _size (size),
2626 _onChange (std::move(onChange)) {}
@@ -37,7 +37,11 @@ struct Resizable : Ui::ProxyNode<Resizable> {
3737 _size = _size + de->delta ;
3838 auto minSize = child ().size ({}, Ui::Hint::MIN);
3939 _size = _size.max (minSize);
40- _onChange (*this , _size);
40+ if (_onChange) {
41+ _onChange (*this , _size);
42+ } else {
43+ Ui::shouldLayout (*this );
44+ }
4145 e.accept ();
4246 }
4347 }
@@ -52,11 +56,11 @@ struct Resizable : Ui::ProxyNode<Resizable> {
5256 }
5357};
5458
55- export Ui::Child resizable (Ui::Child child, Math::Vec2i size, Ui::Send<Math::Vec2i> onChange) {
59+ export Ui::Child resizable (Ui::Child child, Math::Vec2i size, Opt< Ui::Send<Math::Vec2i> > onChange) {
5660 return makeRc<Resizable>(child, size, std::move (onChange));
5761}
5862
59- export auto resizable (Math::Vec2i size, Ui::Send<Math::Vec2i> onChange) {
63+ export auto resizable (Math::Vec2i size, Opt< Ui::Send<Math::Vec2i> > onChange) {
6064 return [size, onChange = std::move (onChange)](Ui::Child child) mutable -> Ui::Child {
6165 return resizable (child, size, std::move (onChange));
6266 };
@@ -70,7 +74,7 @@ static Ui::Child _resizeHandle(Math::Vec2i dir) {
7074 Ui::dragRegion (dir);
7175}
7276
73- export Ui::Child resizable (Ui::Child child, ResizeHandle handlePosition, Math::Vec2i size, Ui::Send<Math::Vec2i> onChange) {
77+ export Ui::Child resizable (Ui::Child child, ResizeHandle handlePosition, Math::Vec2i size, Opt< Ui::Send<Math::Vec2i> > onChange) {
7478 if (handlePosition == ResizeHandle::TOP) {
7579 return Ui::stack (
7680 child,
@@ -110,9 +114,9 @@ export Ui::Child resizable(Ui::Child child, ResizeHandle handlePosition, Math::V
110114 }
111115}
112116
113- export auto resizable (ResizeHandle handlePosition, Math::Vec2i size, Ui::Send<Math::Vec2i> onChange) {
114- return [handlePosition, size, onChange = std::move (onChange) ](Ui::Child child) mutable -> Ui::Child {
115- return resizable (child, handlePosition, size, std::move ( onChange) );
117+ export auto resizable (ResizeHandle handlePosition, Math::Vec2i size, Opt< Ui::Send<Math::Vec2i> > onChange) {
118+ return [handlePosition, size, onChange](Ui::Child child) mutable -> Ui::Child {
119+ return resizable (child, handlePosition, size, onChange);
116120 };
117121}
118122
0 commit comments