diff --git a/src/bin/eolian_mono/eolian/mono/function_definition.hh b/src/bin/eolian_mono/eolian/mono/function_definition.hh index b8b811f755..b0bd88c40e 100644 --- a/src/bin/eolian_mono/eolian/mono/function_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/function_definition.hh @@ -263,7 +263,8 @@ struct property_extension_method_definition_generator } // Do we need BindablePart extensions for this class? - if (!helpers::inherits_from(cls, "Efl.Ui.LayoutPart")) + // IContent parts are handled directly through BindableFactoryParts + if (!helpers::inherits_from(cls, "Efl.Ui.LayoutPart") || helpers::inherits_from(cls, "Efl.IContent")) return true; if (property.setter.is_engaged()) diff --git a/src/bin/eolian_mono/eolian/mono/part_definition.hh b/src/bin/eolian_mono/eolian/mono/part_definition.hh index ec6ef61551..3569f438d5 100644 --- a/src/bin/eolian_mono/eolian/mono/part_definition.hh +++ b/src/bin/eolian_mono/eolian/mono/part_definition.hh @@ -47,12 +47,19 @@ struct part_extension_method_definition_generator /* auto unit = (const Eolian_Unit*) context_find_tag(context).state; */ /* auto klass = get_klass(part.klass, unit); */ + std::string bindableClass = "Efl.BindablePart"; + + // Efl.Content parts should be bound only throught FactoryBind + attributes::klass_def c(get_klass(part.klass, cls.unit), cls.unit); + if (helpers::inherits_from(c, "Efl.IContent")) + bindableClass = "Efl.BindableFactoryPart"; + if (!as_generator( - scope_tab << "public static Efl.BindablePart<" << part_klass_name << "> " << name_helpers::managed_part_name(part) << "(this Efl.Ui.ItemFactory fac, Efl.Csharp.ExtensionTag<" + scope_tab << "public static " << bindableClass << "<" << part_klass_name << "> " << name_helpers::managed_part_name(part) << "(this Efl.Ui.ItemFactory fac, Efl.Csharp.ExtensionTag<" << name_helpers::klass_full_concrete_or_interface_name(cls) << ", T> x=null) where T : " << name_helpers::klass_full_concrete_or_interface_name(cls) << "\n" << scope_tab << "{\n" - << scope_tab << scope_tab << "return new Efl.BindablePart<" << part_klass_name << ">(\"" << part.name << "\" ,fac);\n" + << scope_tab << scope_tab << "return new " << bindableClass << "<" << part_klass_name << ">(\"" << part.name << "\" ,fac);\n" << scope_tab << "}\n" ).generate(sink, attributes::unused, context)) return false; diff --git a/src/bindings/mono/efl_mono/Bind.cs b/src/bindings/mono/efl_mono/Bind.cs index c1e2a660d7..d82d0c1f49 100644 --- a/src/bindings/mono/efl_mono/Bind.cs +++ b/src/bindings/mono/efl_mono/Bind.cs @@ -82,6 +82,31 @@ public class BindablePart public string PartName { get; private set; } /// The binder that will be used to bind the properties. public Efl.Ui.IPropertyBind Binder { get; private set; } + +} + +/// Represents bindable factory parts as used by instances. +/// +public class BindableFactoryPart +{ + /// Creates a new bindable factory part with the binder binder. + public BindableFactoryPart(string partName, Efl.Ui.IFactoryBind binder) + { + this.PartName = partName; + this.Binder = binder; + } + + /// The name of the part this instance wraps. + public string PartName { get; private set; } + /// The binder that will be used to bind the properties. + public Efl.Ui.IFactoryBind Binder { get; private set; } + + /// Binds the given factory to this part. + public Eina.Error BindFactory(Efl.Ui.IFactory factory) + { + this.Binder.FactoryBind(this.PartName, factory); + return Eina.Error.NO_ERROR; + } } namespace Csharp diff --git a/src/tests/efl_mono/Parts.cs b/src/tests/efl_mono/Parts.cs index 00a67bae56..a27c1b472e 100644 --- a/src/tests/efl_mono/Parts.cs +++ b/src/tests/efl_mono/Parts.cs @@ -50,6 +50,16 @@ public static class TestMVVMParts Test.AssertEquals(error, Eina.Error.NO_ERROR); } + + public static void mvvm_factory_properties() + { + var factory = new Efl.Ui.ItemFactory(); + var iconFactory = new Efl.Ui.ImageFactory(null); + iconFactory.PropertyBind("filename", "modelProperty"); + var error = factory.IconPart().BindFactory(iconFactory); + + Test.AssertEquals(error, Eina.Error.NO_ERROR); + } } #endif