From fe57fdcd862deca3243b1f90bdfaa0a3d00be673 Mon Sep 17 00:00:00 2001
From: kjolnyr <kjolnyr@protonmail.com>
Date: Fri, 2 Dec 2022 20:47:27 +0100
Subject: [PATCH] make rsx macro return the root entity

---
 examples/bevy_scene.rs           | 2 +-
 examples/clipping.rs             | 2 +-
 examples/conditional_widget.rs   | 4 ++--
 examples/context.rs              | 8 ++++----
 examples/hello_world.rs          | 2 +-
 examples/image.rs                | 2 +-
 examples/main_menu.rs            | 4 ++--
 examples/nine_patch.rs           | 2 +-
 examples/quads.rs                | 2 +-
 examples/render_target.rs        | 4 ++--
 examples/scrolling.rs            | 2 +-
 examples/simple_state.rs         | 4 ++--
 examples/tabs/tab.rs             | 2 +-
 examples/tabs/tab_button.rs      | 2 +-
 examples/tabs/tabs.rs            | 2 +-
 examples/test_no_startup.rs      | 2 +-
 examples/text.rs                 | 2 +-
 examples/text_box.rs             | 4 ++--
 examples/texture_atlas.rs        | 2 +-
 examples/todo/input.rs           | 2 +-
 examples/todo/items.rs           | 2 +-
 examples/todo/todo.rs            | 2 +-
 examples/vec.rs                  | 4 ++--
 kayak_ui_macros/src/widget.rs    | 3 ++-
 src/widgets/app.rs               | 2 +-
 src/widgets/button.rs            | 2 +-
 src/widgets/scroll/scroll_bar.rs | 2 +-
 src/widgets/scroll/scroll_box.rs | 2 +-
 src/widgets/text_box.rs          | 2 +-
 src/widgets/window.rs            | 2 +-
 30 files changed, 40 insertions(+), 39 deletions(-)

diff --git a/examples/bevy_scene.rs b/examples/bevy_scene.rs
index 7e77f0c..bf8439b 100644
--- a/examples/bevy_scene.rs
+++ b/examples/bevy_scene.rs
@@ -253,7 +253,7 @@ fn startup(
                 />
             </WindowBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn((UICameraBundle::new(widget_context), GameUI));
 }
diff --git a/examples/clipping.rs b/examples/clipping.rs
index 322a0ed..9eeb058 100644
--- a/examples/clipping.rs
+++ b/examples/clipping.rs
@@ -54,7 +54,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed tellus neque.
                 </ClipBundle>
             </NinePatchBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/conditional_widget.rs b/examples/conditional_widget.rs
index 42476e4..1791f08 100644
--- a/examples/conditional_widget.rs
+++ b/examples/conditional_widget.rs
@@ -98,7 +98,7 @@ fn my_widget_render(
                     }
                 }}
             </ElementBundle>
-        }
+        };
     }
 
     true
@@ -128,7 +128,7 @@ fn startup(
         <KayakAppBundle>
             <MyWidgetBundle />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/context.rs b/examples/context.rs
index 9523f64..a712519 100644
--- a/examples/context.rs
+++ b/examples/context.rs
@@ -124,7 +124,7 @@ fn update_theme_button(
                             },
                         )}
                     />
-                }
+                };
             }
         }
     }
@@ -182,7 +182,7 @@ fn update_theme_selector(
                 <ThemeButtonBundle theme_button={ThemeButton { theme: solar_theme }} />
                 <ThemeButtonBundle theme_button={ThemeButton { theme: vector_theme }} />
             </ElementBundle>
-        }
+        };
     }
 
     true
@@ -312,7 +312,7 @@ fn update_theme_demo(
                             }
                         </BackgroundBundle>
                     </ElementBundle>
-                }
+                };
             }
         }
     }
@@ -375,7 +375,7 @@ fn startup(
                 />
             </WindowBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/hello_world.rs b/examples/hello_world.rs
index e57e6f3..caf0660 100644
--- a/examples/hello_world.rs
+++ b/examples/hello_world.rs
@@ -21,7 +21,7 @@ fn startup(
                 }}
             />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/image.rs b/examples/image.rs
index 1b490ee..ae984f6 100644
--- a/examples/image.rs
+++ b/examples/image.rs
@@ -28,7 +28,7 @@ fn startup(
                 }}
             />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/main_menu.rs b/examples/main_menu.rs
index 7310a64..40949d6 100644
--- a/examples/main_menu.rs
+++ b/examples/main_menu.rs
@@ -107,7 +107,7 @@ fn menu_button_render(
                     }}
                 />
             </NinePatchBundle>
-        }
+        };
     }
     true
 }
@@ -216,7 +216,7 @@ fn startup(
                 />
             </NinePatchBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/nine_patch.rs b/examples/nine_patch.rs
index 5ff1e0d..1aeeada 100644
--- a/examples/nine_patch.rs
+++ b/examples/nine_patch.rs
@@ -49,7 +49,7 @@ fn startup(
                 }}
             />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/quads.rs b/examples/quads.rs
index 9bd7722..33216d6 100644
--- a/examples/quads.rs
+++ b/examples/quads.rs
@@ -132,7 +132,7 @@ fn startup(
                 });
             }
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/render_target.rs b/examples/render_target.rs
index 52760fc..d17bb3b 100644
--- a/examples/render_target.rs
+++ b/examples/render_target.rs
@@ -80,7 +80,7 @@ fn startup(
                 }}
             />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle {
         camera: Camera {
@@ -147,7 +147,7 @@ fn startup(
                 }}
             />
         </KayakAppBundle>
-    }
+    };
     commands.spawn((UICameraBundle::new(widget_context), MainUI));
 }
 
diff --git a/examples/scrolling.rs b/examples/scrolling.rs
index 078f3ce..cac9c08 100644
--- a/examples/scrolling.rs
+++ b/examples/scrolling.rs
@@ -58,7 +58,7 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed tellus neque.
                 </ScrollContextProviderBundle>
             </WindowBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/simple_state.rs b/examples/simple_state.rs
index a427a40..2e27896 100644
--- a/examples/simple_state.rs
+++ b/examples/simple_state.rs
@@ -74,7 +74,7 @@ fn current_count_render(
                     )}
                 />
             </ElementBundle>
-        }
+        };
     }
 
     true
@@ -127,7 +127,7 @@ fn startup(
                 </WindowBundle>
             </WindowContextProviderBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/tabs/tab.rs b/examples/tabs/tab.rs
index f6f2827..ea37d2d 100644
--- a/examples/tabs/tab.rs
+++ b/examples/tabs/tab.rs
@@ -52,7 +52,7 @@ pub fn tab_render(
             if tab_context.current_index == tab.index {
                 rsx! {
                     <BackgroundBundle styles={styles} children={children.clone()} />
-                }
+                };
             }
         }
     }
diff --git a/examples/tabs/tab_button.rs b/examples/tabs/tab_button.rs
index 440afd8..2741684 100644
--- a/examples/tabs/tab_button.rs
+++ b/examples/tabs/tab_button.rs
@@ -86,7 +86,7 @@ pub fn tab_button_render(
                     }}
                     on_event={on_event}
                 />
-            }
+            };
         }
     }
     true
diff --git a/examples/tabs/tabs.rs b/examples/tabs/tabs.rs
index 677c1e3..2539aec 100644
--- a/examples/tabs/tabs.rs
+++ b/examples/tabs/tabs.rs
@@ -85,7 +85,7 @@ fn startup(
                 </TabContextProviderBundle>
             </WindowBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/test_no_startup.rs b/examples/test_no_startup.rs
index 8567aa2..060081e 100644
--- a/examples/test_no_startup.rs
+++ b/examples/test_no_startup.rs
@@ -32,7 +32,7 @@ fn second_sys(
                 }}
             />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/text.rs b/examples/text.rs
index 325c756..fa49287 100644
--- a/examples/text.rs
+++ b/examples/text.rs
@@ -90,7 +90,7 @@ fn startup(
     );
     rsx! {
         <KayakAppBundle><MyWidgetBundle props={MyWidgetProps { foo: 0 }} /></KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/text_box.rs b/examples/text_box.rs
index 4894d90..72b2731 100644
--- a/examples/text_box.rs
+++ b/examples/text_box.rs
@@ -78,7 +78,7 @@ fn update_text_box_example(
                     on_change={on_change2}
                 />
             </ElementBundle>
-        }
+        };
     }
     true
 }
@@ -118,7 +118,7 @@ fn startup(
                 <TextBoxExampleBundle />
             </WindowBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/texture_atlas.rs b/examples/texture_atlas.rs
index 87298e0..d4e311a 100644
--- a/examples/texture_atlas.rs
+++ b/examples/texture_atlas.rs
@@ -66,7 +66,7 @@ fn startup(
                 styles={atlas_styles}
             />
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/todo/input.rs b/examples/todo/input.rs
index 8080596..38b2da7 100644
--- a/examples/todo/input.rs
+++ b/examples/todo/input.rs
@@ -111,6 +111,6 @@ pub fn render_todo_input(
                 on_event={handle_click}
             />
         </ElementBundle>
-    }
+    };
     true
 }
diff --git a/examples/todo/items.rs b/examples/todo/items.rs
index 4af3366..8892ece 100644
--- a/examples/todo/items.rs
+++ b/examples/todo/items.rs
@@ -104,6 +104,6 @@ pub fn render_todo_items(
                 }
             })}
         </ElementBundle>
-    }
+    };
     true
 }
diff --git a/examples/todo/todo.rs b/examples/todo/todo.rs
index 0e50bea..4f62b88 100644
--- a/examples/todo/todo.rs
+++ b/examples/todo/todo.rs
@@ -97,7 +97,7 @@ fn startup(
                 </ScrollContextProviderBundle>
             </WindowBundle>
         </KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/examples/vec.rs b/examples/vec.rs
index 98c6142..fa362a7 100644
--- a/examples/vec.rs
+++ b/examples/vec.rs
@@ -28,7 +28,7 @@ fn my_widget_1_update(
                     }
                 })}
             </ElementBundle>
-        }
+        };
         return true;
     }
 
@@ -70,7 +70,7 @@ fn startup(
     );
     rsx! {
         <KayakAppBundle><MyWidgetBundle /></KayakAppBundle>
-    }
+    };
 
     commands.spawn(UICameraBundle::new(widget_context));
 }
diff --git a/kayak_ui_macros/src/widget.rs b/kayak_ui_macros/src/widget.rs
index 65691a2..9283070 100644
--- a/kayak_ui_macros/src/widget.rs
+++ b/kayak_ui_macros/src/widget.rs
@@ -71,11 +71,12 @@ impl Widget {
                     let widget_block =
                         build_widget_stream(quote! { built_widget }, constructor, 0, false);
                     (
-                        entity_id,
+                        entity_id.clone(),
                         quote! {{
                             let parent_org = parent_id;
                             #props
                             #widget_block
+                            #entity_id
                         }},
                     )
                 } else {
diff --git a/src/widgets/app.rs b/src/widgets/app.rs
index 67b9062..6a0ba11 100644
--- a/src/widgets/app.rs
+++ b/src/widgets/app.rs
@@ -125,7 +125,7 @@ pub fn app_render(
             <ClipBundle
                 children={children.clone()}
             />
-        }
+        };
     }
 
     true
diff --git a/src/widgets/button.rs b/src/widgets/button.rs
index 9187d90..96dee97 100644
--- a/src/widgets/button.rs
+++ b/src/widgets/button.rs
@@ -138,7 +138,7 @@ pub fn button_render(
                         }}
                     />
                 </ElementBundle>
-            }
+            };
         }
     }
 
diff --git a/src/widgets/scroll/scroll_bar.rs b/src/widgets/scroll/scroll_bar.rs
index 27ffec4..e45f3a1 100644
--- a/src/widgets/scroll/scroll_bar.rs
+++ b/src/widgets/scroll/scroll_bar.rs
@@ -307,7 +307,7 @@ pub fn scroll_bar_render(
                             <BackgroundBundle styles={thumb_style} />
                         </ClipBundle>
                     </BackgroundBundle>
-                }
+                };
             }
         }
     }
diff --git a/src/widgets/scroll/scroll_box.rs b/src/widgets/scroll/scroll_box.rs
index 3a28578..5d4643c 100644
--- a/src/widgets/scroll/scroll_box.rs
+++ b/src/widgets/scroll/scroll_box.rs
@@ -263,7 +263,7 @@ pub fn scroll_box_render(
                             }
                         }}
                     </ElementBundle>
-                }
+                };
             }
         }
     }
diff --git a/src/widgets/text_box.rs b/src/widgets/text_box.rs
index 031a204..e45cc09 100644
--- a/src/widgets/text_box.rs
+++ b/src/widgets/text_box.rs
@@ -371,7 +371,7 @@ pub fn text_box_render(
                         </ElementBundle>
                     </ClipBundle>
                 </BackgroundBundle>
-            }
+            };
         }
     }
 
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index 3358245..dd00fd4 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -281,7 +281,7 @@ pub fn window_render(
                         children={window_children.clone()}
                     />
                 </ElementBundle>
-            }
+            };
         }
     }
 
-- 
GitLab