component from component function

This commit is contained in:
BlackMATov
2020-04-15 21:52:18 +07:00
parent eda66d3dd5
commit dfb5c06601
14 changed files with 135 additions and 108 deletions

View File

@@ -94,6 +94,12 @@ namespace e2d
gobject owner() const noexcept; gobject owner() const noexcept;
explicit operator bool() const noexcept; explicit operator bool() const noexcept;
template < typename U >
gcomponent<U> component() noexcept;
template < typename U >
const_gcomponent<U> component() const noexcept;
private: private:
gobject owner_; gobject owner_;
}; };
@@ -116,6 +122,9 @@ namespace e2d
gobject owner() const noexcept; gobject owner() const noexcept;
explicit operator bool() const noexcept; explicit operator bool() const noexcept;
template < typename U >
const_gcomponent<U> component() const noexcept;
private: private:
gobject owner_; gobject owner_;
}; };
@@ -239,6 +248,18 @@ namespace e2d
gcomponent<T>::operator bool() const noexcept { gcomponent<T>::operator bool() const noexcept {
return exists(); return exists();
} }
template < typename T >
template < typename U >
gcomponent<U> gcomponent<T>::component() noexcept {
return owner_.component<U>();
}
template < typename T >
template < typename U >
const_gcomponent<U> gcomponent<T>::component() const noexcept {
return owner_.component<U>();
}
} }
namespace e2d namespace e2d
@@ -294,4 +315,10 @@ namespace e2d
const_gcomponent<T>::operator bool() const noexcept { const_gcomponent<T>::operator bool() const noexcept {
return exists(); return exists();
} }
template < typename T >
template < typename U >
const_gcomponent<U> const_gcomponent<T>::component() const noexcept {
return owner_.component<U>();
}
} }

View File

@@ -17,35 +17,35 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<behaviour>& c){ "enable", [](gcomponent<behaviour>& c){
c.owner().component<disabled<behaviour>>().remove(); c.component<disabled<behaviour>>().remove();
}, },
"disable", [](gcomponent<behaviour>& c){ "disable", [](gcomponent<behaviour>& c){
c.owner().component<disabled<behaviour>>().ensure(); c.component<disabled<behaviour>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<behaviour>& c) -> bool { [](const gcomponent<behaviour>& c) -> bool {
return !c.owner().component<disabled<behaviour>>().exists(); return !c.component<disabled<behaviour>>().exists();
}, },
[](gcomponent<behaviour>& c, bool yesno){ [](gcomponent<behaviour>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<behaviour>>().remove(); c.component<disabled<behaviour>>().remove();
} else { } else {
c.owner().component<disabled<behaviour>>().ensure(); c.component<disabled<behaviour>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<behaviour>& c) -> bool { [](const gcomponent<behaviour>& c) -> bool {
return c.owner().component<disabled<behaviour>>().exists(); return c.component<disabled<behaviour>>().exists();
}, },
[](gcomponent<behaviour>& c, bool yesno){ [](gcomponent<behaviour>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<behaviour>>().ensure(); c.component<disabled<behaviour>>().ensure();
} else { } else {
c.owner().component<disabled<behaviour>>().remove(); c.component<disabled<behaviour>>().remove();
} }
} }
), ),

View File

@@ -17,61 +17,61 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<camera>& c){ "enable", [](gcomponent<camera>& c){
c.owner().component<disabled<camera>>().remove(); c.component<disabled<camera>>().remove();
}, },
"disable", [](gcomponent<camera>& c){ "disable", [](gcomponent<camera>& c){
c.owner().component<disabled<camera>>().ensure(); c.component<disabled<camera>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<camera>& c) -> bool { [](const gcomponent<camera>& c) -> bool {
return !c.owner().component<disabled<camera>>().exists(); return !c.component<disabled<camera>>().exists();
}, },
[](gcomponent<camera>& c, bool yesno){ [](gcomponent<camera>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<camera>>().remove(); c.component<disabled<camera>>().remove();
} else { } else {
c.owner().component<disabled<camera>>().ensure(); c.component<disabled<camera>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<camera>& c) -> bool { [](const gcomponent<camera>& c) -> bool {
return c.owner().component<disabled<camera>>().exists(); return c.component<disabled<camera>>().exists();
}, },
[](gcomponent<camera>& c, bool yesno){ [](gcomponent<camera>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<camera>>().ensure(); c.component<disabled<camera>>().ensure();
} else { } else {
c.owner().component<disabled<camera>>().remove(); c.component<disabled<camera>>().remove();
} }
} }
), ),
"input", sol::property( "input", sol::property(
[](const gcomponent<camera>& c) -> bool { [](const gcomponent<camera>& c) -> bool {
return c.owner().component<camera::input>().exists(); return c.component<camera::input>().exists();
}, },
[](gcomponent<camera>& c, bool yesno){ [](gcomponent<camera>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<camera::input>().ensure(); c.component<camera::input>().ensure();
} else { } else {
c.owner().component<camera::input>().remove(); c.component<camera::input>().remove();
} }
} }
), ),
"gizmos", sol::property( "gizmos", sol::property(
[](const gcomponent<camera>& c) -> bool { [](const gcomponent<camera>& c) -> bool {
return c.owner().component<camera::gizmos>().exists(); return c.component<camera::gizmos>().exists();
}, },
[](gcomponent<camera>& c, bool yesno){ [](gcomponent<camera>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<camera::gizmos>().ensure(); c.component<camera::gizmos>().ensure();
} else { } else {
c.owner().component<camera::gizmos>().remove(); c.component<camera::gizmos>().remove();
} }
} }
), ),

View File

@@ -19,35 +19,35 @@ namespace
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<rect_collider>& c){ "enable", [](gcomponent<rect_collider>& c){
c.owner().component<disabled<rect_collider>>().remove(); c.component<disabled<rect_collider>>().remove();
}, },
"disable", [](gcomponent<rect_collider>& c){ "disable", [](gcomponent<rect_collider>& c){
c.owner().component<disabled<rect_collider>>().ensure(); c.component<disabled<rect_collider>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<rect_collider>& c) -> bool { [](const gcomponent<rect_collider>& c) -> bool {
return !c.owner().component<disabled<rect_collider>>().exists(); return !c.component<disabled<rect_collider>>().exists();
}, },
[](gcomponent<rect_collider>& c, bool yesno){ [](gcomponent<rect_collider>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<rect_collider>>().remove(); c.component<disabled<rect_collider>>().remove();
} else { } else {
c.owner().component<disabled<rect_collider>>().ensure(); c.component<disabled<rect_collider>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<rect_collider>& c) -> bool { [](const gcomponent<rect_collider>& c) -> bool {
return c.owner().component<disabled<rect_collider>>().exists(); return c.component<disabled<rect_collider>>().exists();
}, },
[](gcomponent<rect_collider>& c, bool yesno){ [](gcomponent<rect_collider>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<rect_collider>>().ensure(); c.component<disabled<rect_collider>>().ensure();
} else { } else {
c.owner().component<disabled<rect_collider>>().remove(); c.component<disabled<rect_collider>>().remove();
} }
} }
), ),
@@ -75,35 +75,35 @@ namespace
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<circle_collider>& c){ "enable", [](gcomponent<circle_collider>& c){
c.owner().component<disabled<circle_collider>>().remove(); c.component<disabled<circle_collider>>().remove();
}, },
"disable", [](gcomponent<circle_collider>& c){ "disable", [](gcomponent<circle_collider>& c){
c.owner().component<disabled<circle_collider>>().ensure(); c.component<disabled<circle_collider>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<circle_collider>& c) -> bool { [](const gcomponent<circle_collider>& c) -> bool {
return !c.owner().component<disabled<circle_collider>>().exists(); return !c.component<disabled<circle_collider>>().exists();
}, },
[](gcomponent<circle_collider>& c, bool yesno){ [](gcomponent<circle_collider>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<circle_collider>>().remove(); c.component<disabled<circle_collider>>().remove();
} else { } else {
c.owner().component<disabled<circle_collider>>().ensure(); c.component<disabled<circle_collider>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<circle_collider>& c) -> bool { [](const gcomponent<circle_collider>& c) -> bool {
return c.owner().component<disabled<circle_collider>>().exists(); return c.component<disabled<circle_collider>>().exists();
}, },
[](gcomponent<circle_collider>& c, bool yesno){ [](gcomponent<circle_collider>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<circle_collider>>().ensure(); c.component<disabled<circle_collider>>().ensure();
} else { } else {
c.owner().component<disabled<circle_collider>>().remove(); c.component<disabled<circle_collider>>().remove();
} }
} }
), ),
@@ -131,35 +131,35 @@ namespace
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<polygon_collider>& c){ "enable", [](gcomponent<polygon_collider>& c){
c.owner().component<disabled<polygon_collider>>().remove(); c.component<disabled<polygon_collider>>().remove();
}, },
"disable", [](gcomponent<polygon_collider>& c){ "disable", [](gcomponent<polygon_collider>& c){
c.owner().component<disabled<polygon_collider>>().ensure(); c.component<disabled<polygon_collider>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<polygon_collider>& c) -> bool { [](const gcomponent<polygon_collider>& c) -> bool {
return !c.owner().component<disabled<polygon_collider>>().exists(); return !c.component<disabled<polygon_collider>>().exists();
}, },
[](gcomponent<polygon_collider>& c, bool yesno){ [](gcomponent<polygon_collider>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<polygon_collider>>().remove(); c.component<disabled<polygon_collider>>().remove();
} else { } else {
c.owner().component<disabled<polygon_collider>>().ensure(); c.component<disabled<polygon_collider>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<polygon_collider>& c) -> bool { [](const gcomponent<polygon_collider>& c) -> bool {
return c.owner().component<disabled<polygon_collider>>().exists(); return c.component<disabled<polygon_collider>>().exists();
}, },
[](gcomponent<polygon_collider>& c, bool yesno){ [](gcomponent<polygon_collider>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<polygon_collider>>().ensure(); c.component<disabled<polygon_collider>>().ensure();
} else { } else {
c.owner().component<disabled<polygon_collider>>().remove(); c.component<disabled<polygon_collider>>().remove();
} }
} }
), ),

View File

@@ -17,24 +17,24 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<layout>& c){ "enable", [](gcomponent<layout>& c){
c.owner().component<disabled<layout>>().remove(); c.component<disabled<layout>>().remove();
layouts::mark_dirty(c); layouts::mark_dirty(c);
}, },
"disable", [](gcomponent<layout>& c){ "disable", [](gcomponent<layout>& c){
c.owner().component<disabled<layout>>().ensure(); c.component<disabled<layout>>().ensure();
layouts::mark_dirty(c); layouts::mark_dirty(c);
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<layout>& c) -> bool { [](const gcomponent<layout>& c) -> bool {
return !c.owner().component<disabled<layout>>().exists(); return !c.component<disabled<layout>>().exists();
}, },
[](gcomponent<layout>& c, bool yesno){ [](gcomponent<layout>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<layout>>().remove(); c.component<disabled<layout>>().remove();
} else { } else {
c.owner().component<disabled<layout>>().ensure(); c.component<disabled<layout>>().ensure();
} }
layouts::mark_dirty(c); layouts::mark_dirty(c);
} }
@@ -42,13 +42,13 @@ namespace e2d::bindings::high
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<layout>& c) -> bool { [](const gcomponent<layout>& c) -> bool {
return c.owner().component<disabled<layout>>().exists(); return c.component<disabled<layout>>().exists();
}, },
[](gcomponent<layout>& c, bool yesno){ [](gcomponent<layout>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<layout>>().ensure(); c.component<disabled<layout>>().ensure();
} else { } else {
c.owner().component<disabled<layout>>().remove(); c.component<disabled<layout>>().remove();
} }
layouts::mark_dirty(c); layouts::mark_dirty(c);
} }

View File

@@ -17,35 +17,35 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<renderer>& c){ "enable", [](gcomponent<renderer>& c){
c.owner().component<disabled<renderer>>().remove(); c.component<disabled<renderer>>().remove();
}, },
"disable", [](gcomponent<renderer>& c){ "disable", [](gcomponent<renderer>& c){
c.owner().component<disabled<renderer>>().ensure(); c.component<disabled<renderer>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<renderer>& c) -> bool { [](const gcomponent<renderer>& c) -> bool {
return !c.owner().component<disabled<renderer>>().exists(); return !c.component<disabled<renderer>>().exists();
}, },
[](gcomponent<renderer>& c, bool yesno){ [](gcomponent<renderer>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<renderer>>().remove(); c.component<disabled<renderer>>().remove();
} else { } else {
c.owner().component<disabled<renderer>>().ensure(); c.component<disabled<renderer>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<renderer>& c) -> bool { [](const gcomponent<renderer>& c) -> bool {
return c.owner().component<disabled<renderer>>().exists(); return c.component<disabled<renderer>>().exists();
}, },
[](gcomponent<renderer>& c, bool yesno){ [](gcomponent<renderer>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<renderer>>().ensure(); c.component<disabled<renderer>>().ensure();
} else { } else {
c.owner().component<disabled<renderer>>().remove(); c.component<disabled<renderer>>().remove();
} }
} }
), ),

View File

@@ -17,35 +17,35 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<scene>& c){ "enable", [](gcomponent<scene>& c){
c.owner().component<disabled<scene>>().remove(); c.component<disabled<scene>>().remove();
}, },
"disable", [](gcomponent<scene>& c){ "disable", [](gcomponent<scene>& c){
c.owner().component<disabled<scene>>().ensure(); c.component<disabled<scene>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<scene>& c) -> bool { [](const gcomponent<scene>& c) -> bool {
return !c.owner().component<disabled<scene>>().exists(); return !c.component<disabled<scene>>().exists();
}, },
[](gcomponent<scene>& c, bool yesno){ [](gcomponent<scene>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<scene>>().remove(); c.component<disabled<scene>>().remove();
} else { } else {
c.owner().component<disabled<scene>>().ensure(); c.component<disabled<scene>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<scene>& c) -> bool { [](const gcomponent<scene>& c) -> bool {
return c.owner().component<disabled<scene>>().exists(); return c.component<disabled<scene>>().exists();
}, },
[](gcomponent<scene>& c, bool yesno){ [](gcomponent<scene>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<scene>>().ensure(); c.component<disabled<scene>>().ensure();
} else { } else {
c.owner().component<disabled<scene>>().remove(); c.component<disabled<scene>>().remove();
} }
} }
), ),

View File

@@ -17,35 +17,35 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<touchable>& c){ "enable", [](gcomponent<touchable>& c){
c.owner().component<disabled<touchable>>().remove(); c.component<disabled<touchable>>().remove();
}, },
"disable", [](gcomponent<touchable>& c){ "disable", [](gcomponent<touchable>& c){
c.owner().component<disabled<touchable>>().ensure(); c.component<disabled<touchable>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<touchable>& c) -> bool { [](const gcomponent<touchable>& c) -> bool {
return !c.owner().component<disabled<touchable>>().exists(); return !c.component<disabled<touchable>>().exists();
}, },
[](gcomponent<touchable>& c, bool yesno){ [](gcomponent<touchable>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<touchable>>().remove(); c.component<disabled<touchable>>().remove();
} else { } else {
c.owner().component<disabled<touchable>>().ensure(); c.component<disabled<touchable>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<touchable>& c) -> bool { [](const gcomponent<touchable>& c) -> bool {
return c.owner().component<disabled<touchable>>().exists(); return c.component<disabled<touchable>>().exists();
}, },
[](gcomponent<touchable>& c, bool yesno){ [](gcomponent<touchable>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<touchable>>().ensure(); c.component<disabled<touchable>>().ensure();
} else { } else {
c.owner().component<disabled<touchable>>().remove(); c.component<disabled<touchable>>().remove();
} }
} }
), ),

View File

@@ -17,35 +17,35 @@ namespace e2d::bindings::high
sol::no_constructor, sol::no_constructor,
"enable", [](gcomponent<widget>& c){ "enable", [](gcomponent<widget>& c){
c.owner().component<disabled<widget>>().remove(); c.component<disabled<widget>>().remove();
}, },
"disable", [](gcomponent<widget>& c){ "disable", [](gcomponent<widget>& c){
c.owner().component<disabled<widget>>().ensure(); c.component<disabled<widget>>().ensure();
}, },
"enabled", sol::property( "enabled", sol::property(
[](const gcomponent<widget>& c) -> bool { [](const gcomponent<widget>& c) -> bool {
return !c.owner().component<disabled<widget>>().exists(); return !c.component<disabled<widget>>().exists();
}, },
[](gcomponent<widget>& c, bool yesno){ [](gcomponent<widget>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<widget>>().remove(); c.component<disabled<widget>>().remove();
} else { } else {
c.owner().component<disabled<widget>>().ensure(); c.component<disabled<widget>>().ensure();
} }
} }
), ),
"disabled", sol::property( "disabled", sol::property(
[](const gcomponent<widget>& c) -> bool { [](const gcomponent<widget>& c) -> bool {
return c.owner().component<disabled<widget>>().exists(); return c.component<disabled<widget>>().exists();
}, },
[](gcomponent<widget>& c, bool yesno){ [](gcomponent<widget>& c, bool yesno){
if ( yesno ) { if ( yesno ) {
c.owner().component<disabled<widget>>().ensure(); c.component<disabled<widget>>().ensure();
} else { } else {
c.owner().component<disabled<widget>>().remove(); c.component<disabled<widget>>().remove();
} }
} }
), ),

View File

@@ -185,25 +185,25 @@ namespace e2d
const char* component_inspector<camera>::title = ICON_FA_VIDEO " camera"; const char* component_inspector<camera>::title = ICON_FA_VIDEO " camera";
void component_inspector<camera>::operator()(gcomponent<camera>& c) const { void component_inspector<camera>::operator()(gcomponent<camera>& c) const {
if ( bool input = c.owner().component<camera::input>().exists(); if ( bool input = c.component<camera::input>().exists();
ImGui::Checkbox("input", &input) ) ImGui::Checkbox("input", &input) )
{ {
if ( input ) { if ( input ) {
c.owner().component<camera::input>().ensure(); c.component<camera::input>().ensure();
} else { } else {
c.owner().component<camera::input>().remove(); c.component<camera::input>().remove();
} }
} }
ImGui::SameLine(); ImGui::SameLine();
if ( bool gizmos = c.owner().component<camera::gizmos>().exists(); if ( bool gizmos = c.component<camera::gizmos>().exists();
ImGui::Checkbox("gizmos", &gizmos) ) ImGui::Checkbox("gizmos", &gizmos) )
{ {
if ( gizmos ) { if ( gizmos ) {
c.owner().component<camera::gizmos>().ensure(); c.component<camera::gizmos>().ensure();
} else { } else {
c.owner().component<camera::gizmos>().remove(); c.component<camera::gizmos>().remove();
} }
} }

View File

@@ -201,7 +201,7 @@ namespace e2d
const char* component_inspector<label>::title = ICON_FA_PARAGRAPH " label"; const char* component_inspector<label>::title = ICON_FA_PARAGRAPH " label";
void component_inspector<label>::operator()(gcomponent<label>& c) const { void component_inspector<label>::operator()(gcomponent<label>& c) const {
if ( bool dirty = c.owner().component<label::dirty>().exists(); if ( bool dirty = c.component<label::dirty>().exists();
ImGui::Checkbox("dirty", &dirty) ) ImGui::Checkbox("dirty", &dirty) )
{ {
if ( dirty ) { if ( dirty ) {
@@ -337,20 +337,20 @@ namespace e2d::labels
{ {
gcomponent<label> mark_dirty(gcomponent<label> self) { gcomponent<label> mark_dirty(gcomponent<label> self) {
if ( self ) { if ( self ) {
self.owner().component<label::dirty>().ensure(); self.component<label::dirty>().ensure();
} }
return self; return self;
} }
gcomponent<label> unmark_dirty(gcomponent<label> self) { gcomponent<label> unmark_dirty(gcomponent<label> self) {
if ( self ) { if ( self ) {
self.owner().component<label::dirty>().remove(); self.component<label::dirty>().remove();
} }
return self; return self;
} }
bool is_dirty(const const_gcomponent<label>& self) noexcept { bool is_dirty(const const_gcomponent<label>& self) noexcept {
return self.owner().component<label::dirty>().exists(); return self.component<label::dirty>().exists();
} }
gcomponent<label> change_text(gcomponent<label> self, str value) { gcomponent<label> change_text(gcomponent<label> self, str value) {

View File

@@ -172,7 +172,7 @@ namespace e2d
const char* component_inspector<layout>::title = ICON_FA_BARS " layout"; const char* component_inspector<layout>::title = ICON_FA_BARS " layout";
void component_inspector<layout>::operator()(gcomponent<layout>& c) const { void component_inspector<layout>::operator()(gcomponent<layout>& c) const {
if ( bool dirty = c.owner().component<layout::dirty>().exists(); if ( bool dirty = c.component<layout::dirty>().exists();
ImGui::Checkbox("dirty", &dirty) ) ImGui::Checkbox("dirty", &dirty) )
{ {
if ( dirty ) { if ( dirty ) {
@@ -226,20 +226,20 @@ namespace e2d::layouts
{ {
gcomponent<layout> mark_dirty(gcomponent<layout> self) { gcomponent<layout> mark_dirty(gcomponent<layout> self) {
if ( self ) { if ( self ) {
self.owner().component<layout::dirty>().ensure(); self.component<layout::dirty>().ensure();
} }
return self; return self;
} }
gcomponent<layout> unmark_dirty(gcomponent<layout> self) { gcomponent<layout> unmark_dirty(gcomponent<layout> self) {
if ( self ) { if ( self ) {
self.owner().component<layout::dirty>().remove(); self.component<layout::dirty>().remove();
} }
return self; return self;
} }
bool is_dirty(const const_gcomponent<layout>& self) noexcept { bool is_dirty(const const_gcomponent<layout>& self) noexcept {
return self.owner().component<layout::dirty>().exists(); return self.component<layout::dirty>().exists();
} }
gcomponent<layout> change_direction(gcomponent<layout> self, layout::directions value) { gcomponent<layout> change_direction(gcomponent<layout> self, layout::directions value) {
@@ -285,7 +285,7 @@ namespace e2d::layouts
} }
gcomponent<layout> find_parent_layout(const_gcomponent<layout> self) noexcept { gcomponent<layout> find_parent_layout(const_gcomponent<layout> self) noexcept {
const_gcomponent<actor> self_actor = self.owner().component<actor>(); const_gcomponent<actor> self_actor = self.component<actor>();
return self_actor return self_actor
? nodes::find_component_from_parents<layout>(self_actor->node()) ? nodes::find_component_from_parents<layout>(self_actor->node())
: gcomponent<layout>(); : gcomponent<layout>();

View File

@@ -96,7 +96,7 @@ namespace e2d
const char* component_inspector<widget>::title = ICON_FA_VECTOR_SQUARE " widget"; const char* component_inspector<widget>::title = ICON_FA_VECTOR_SQUARE " widget";
void component_inspector<widget>::operator()(gcomponent<widget>& c) const { void component_inspector<widget>::operator()(gcomponent<widget>& c) const {
if ( bool dirty = c.owner().component<widget::dirty>().exists(); if ( bool dirty = c.component<widget::dirty>().exists();
ImGui::Checkbox("dirty", &dirty) ) ImGui::Checkbox("dirty", &dirty) )
{ {
if ( dirty ) { if ( dirty ) {
@@ -161,20 +161,20 @@ namespace e2d::widgets
{ {
gcomponent<widget> mark_dirty(gcomponent<widget> self) { gcomponent<widget> mark_dirty(gcomponent<widget> self) {
if ( self ) { if ( self ) {
self.owner().component<widget::dirty>().ensure(); self.component<widget::dirty>().ensure();
} }
return self; return self;
} }
gcomponent<widget> unmark_dirty(gcomponent<widget> self) { gcomponent<widget> unmark_dirty(gcomponent<widget> self) {
if ( self ) { if ( self ) {
self.owner().component<widget::dirty>().remove(); self.component<widget::dirty>().remove();
} }
return self; return self;
} }
bool is_dirty(const const_gcomponent<widget>& self) noexcept { bool is_dirty(const const_gcomponent<widget>& self) noexcept {
return self.owner().component<widget::dirty>().exists(); return self.component<widget::dirty>().exists();
} }
gcomponent<widget> change_size(gcomponent<widget> self, const v2f& value) { gcomponent<widget> change_size(gcomponent<widget> self, const v2f& value) {
@@ -199,7 +199,7 @@ namespace e2d::widgets
} }
gcomponent<layout> find_parent_layout(const_gcomponent<widget> self) noexcept { gcomponent<layout> find_parent_layout(const_gcomponent<widget> self) noexcept {
const_gcomponent<actor> self_actor = self.owner().component<actor>(); const_gcomponent<actor> self_actor = self.component<actor>();
return self_actor return self_actor
? nodes::find_component_from_parents<layout>(self_actor->node()) ? nodes::find_component_from_parents<layout>(self_actor->node())
: gcomponent<layout>(); : gcomponent<layout>();

View File

@@ -61,7 +61,7 @@ namespace
// parents // parents
// //
static thread_local std::vector<const_gcomponent<touchable>> parents; static thread_local std::vector<gcomponent<touchable>> parents;
E2D_DEFER([](){ parents.clear(); }); E2D_DEFER([](){ parents.clear(); });
nodes::extract_components_from_parents<touchable>( nodes::extract_components_from_parents<touchable>(
@@ -102,7 +102,7 @@ namespace
disabled<touchable> disabled<touchable>
>()(iter->owner().raw_entity()); >()(iter->owner().raw_entity());
if ( !parent_disabled ) { if ( !parent_disabled ) {
iter->owner().component<events<touchable_events::event>>().ensure().add(event); iter->component<events<touchable_events::event>>().ensure().add(event);
if ( !(*iter)->bubbling() ) { if ( !(*iter)->bubbling() ) {
return; return;
} }