efl/src/lib/elementary/efl_ui_view_model.eo

145 lines
6.1 KiB
Plaintext
Raw Normal View History

function @beta EflUiViewModelPropertyGet {
[[Function called when a property is get.]]
params {
@in view_model: const(Efl.Ui.View_Model); [[The ViewModel object the @.property.get is issued on.]]
@in property: stringshare; [[The property name the @.property.get is issued on.]]
}
return: any_value_ref; [[The property value.]]
};
function @beta EflUiViewModelPropertySet {
[[Function called when a property is set.]]
params {
@in view_model: Efl.Ui.View_Model; [[The ViewModel object the @.property.set is issued on.]]
@in property: stringshare; [[The property name the @.property.set is issued on.]]
@in value: any_value_ref @move; [[The new value to set.]]
}
return: future<any_value_ref>; [[The value that was finally set.]]
};
class Efl.Ui.View_Model extends Efl.Composite_Model
{
[[Efl model providing helpers for custom properties used when linking a model to a view and you need to
generate/adapt values for display.
There is two ways to use this class, you can either inherit from it and have a custom constructor for example.
Or you can just instantiate it and manually define your property on it via callbacks.
@since 1.23
]]
methods {
property_string_add {
[[Adds a synthetic string property, generated from a $definition string and other properties in the model.
The $definition string, similar to how $printf works, contains ${} placeholders that are replaced by the
actual value of the property inside the placeholder tags when the synthetic property is retrieved.
For example, a numeric property $length might be strange to use as a label, since it will only display a
number. However, a synthetic string can be generated with the definition "Length ${length}." which renders
more nicely and does not require any more code by the user of the property.
$not_ready and $on_error strings can be given to be used when the data is not ready or there is some error,
respectively. These strings do accept placeholder tags.
See @.property_string_del
]]
params {
name: string; [[The name for the new synthetic property.]]
definition: string; [[The definition string for the new synthetic property.]]
not_ready: string; [[The text to be used if any of the properties used in $definition is not ready yet.
If set to $null, no check against EAGAIN will be done.]]
on_error: string; [[The text to be used if any of the properties used in $definition is in error. It takes
precedence over $not_ready. If set to $null, no error checks are performed.]]
}
return: Eina.Error;
}
property_string_del {
[[Delete a synthetic property previously defined by @.property_string_add.
See @.property_string_add
]]
params {
name: string; [[The name of the synthetic property to delete.]]
}
return: Eina.Error;
}
property_logic_add @beta {
[[Add callbacks that will be triggered when someone ask for the specified property name when getting or
setting a property.
A get or set should at least be provided for this call to succeed.
See @.property_logic_del
]]
params {
property: string; [[The property to bind on to.]]
get: EflUiViewModelPropertyGet; [[Define the get callback called when the @Efl.Model.property.get is called
with the above property name.]]
set: EflUiViewModelPropertySet; [[Define the set callback called when the @Efl.Model.property.set is called
with the above property name.]]
2019-12-04 09:22:25 -08:00
bound: iterator<string> @move; [[Iterator of property name to bind with this defined property see
@.property_bind.]]
}
return: Eina.Error;
}
property_logic_del @beta {
[[Delete previously added callbacks that were triggered when someone asked for the specified property name
when getting or setting a property.
A get or set should at least be provided for this call to succeed.
See @.property_logic_add
]]
params {
property: string; [[The property to bind on to.]]
}
return: Eina.Error;
}
property_bind {
[[Automatically update the field for the event @[Efl.Model.properties,changed] to include property
that are impacted with change in a property from the composited model.
The source doesn't have to be provided at this point by the composited model.
]]
params {
@in source: string; [[Property name in the composited model.]]
@in destination: string; [[Property name in the @Efl.Ui.View_Model]]
}
}
property_unbind {
[[Stop automatically updating the field for the event @[Efl.Model.properties,changed] to
include property that are impacted with change in a property from the
composited model.
]]
params {
@in source: string; [[Property name in the composited model.]]
@in destination: string; [[Property name in the @Efl.Ui.View_Model]]
}
}
@property children_bind {
[[Define if we will intercept all children object reference and
efl_model : rename all efl_model based classes. Summary: As the result of discussion in T7458, we need to rename all efl_model based classes with efl_XXX_Model sequence. I've run few vote for this, see V42, V43 few classes are totally renamed as our consideration of misnaming. | Efl.Model_Loop | Efl.Loop_Model | | Efl.Model_Item | Efl.Generic_Model | | Efl.Model_Container | Efl.Container_Model | | Efl.Model_Container_Item | Efl.Container_Model_Item | | Efl.Model_Composite | Efl.Composite_Model | | Efl.Model_Composite_Boolean | Efl.Boolean_Model | | Efl.Model_Composite_Boolean_Chlidren | Efl.Boolean_Model_Item | | Efl.Model_Composite_Selection | Efl.Select_Model | | Efl.Model_Composite_Selection_Chlidren | Efl.Select_Model_Item | | Efl.Model_View | Efl.View_Model | | Eio.Model | Efl.Io.Model | | Efl.Ui.Model_State | Efl.Ui.State_Model | | Efl.Ui.Model_Size | Efl.Ui.Size_Model | | Efl.Ui.Model_Exact | Efl.Ui.Exact_Model | | Efl.Ui.Model_Average | Efl.Ui.Average_Model | | Efl.Ui.Model_Homogeneous | Efl.Ui.Homogeneous_Model | I worried about Efl.Io.Model changes, cause it is widely used, but as I tested, there is no issue found yet. Eldbus.Model also may can changed Efl.Dbus.Model, but I cannot found any class who using Efl.Dbus namespace, so I left it future work. Test Plan: Run the Make Test, it works well except Efl test about selection. there are class inheritance problem exist in select_model, I reported it and will fix it in another patch. Reviewers: cedric, felipealmeida, woohyun, Hermet Reviewed By: cedric Subscribers: lauromoura Tags: #efl, #do_not_merge Differential Revision: https://phab.enlightenment.org/D7533
2019-01-30 20:35:34 -08:00
bind them through the ViewModel with the same property logic as this
one. Be careful of recursivity.
This can only be applied at construction time.]]
get {
}
set {
}
values {
enable: bool; [[Do you automatically bind children. Default to true.]]
}
}
}
implements {
Efl.Object.constructor;
Efl.Object.finalize;
Efl.Object.destructor;
Efl.Model.children_slice_get;
Efl.Model.properties { get; }
Efl.Model.property { set; get; }
}
constructors {
Efl.Ui.View_Model.children_bind @optional;
}
}