2019-09-04 08:07:37 -07:00
|
|
|
function @beta EflUiViewModelPropertyGet {
|
2018-11-28 16:03:33 -08:00
|
|
|
[[Function called when a property is get.]]
|
|
|
|
params {
|
2019-09-04 08:07:37 -07:00
|
|
|
@in view_model: const(Efl.Ui.View_Model); [[The ViewModel object the @.property.get is issued on.]]
|
2018-11-28 16:03:33 -08:00
|
|
|
@in property: stringshare; [[The property name the @.property.get is issued on.]]
|
|
|
|
}
|
2019-09-20 09:02:07 -07:00
|
|
|
return: any_value_ref; [[The property value.]]
|
2018-11-28 16:03:33 -08:00
|
|
|
};
|
|
|
|
|
2019-09-04 08:07:37 -07:00
|
|
|
function @beta EflUiViewModelPropertySet {
|
2018-11-28 16:03:33 -08:00
|
|
|
[[Function called when a property is set.]]
|
|
|
|
params {
|
2019-09-04 08:07:37 -07:00
|
|
|
@in view_model: Efl.Ui.View_Model; [[The ViewModel object the @.property.set is issued on.]]
|
2018-11-28 16:03:33 -08:00
|
|
|
@in property: stringshare; [[The property name the @.property.set is issued on.]]
|
2019-09-20 09:02:07 -07:00
|
|
|
@in value: any_value_ref @move; [[The new value to set.]]
|
2018-11-28 16:03:33 -08:00
|
|
|
}
|
2019-09-20 09:02:07 -07:00
|
|
|
return: future<any_value_ref>; [[The value that was finally set.]]
|
2018-11-28 16:03:33 -08:00
|
|
|
};
|
|
|
|
|
2019-09-25 08:02:14 -07:00
|
|
|
class Efl.Ui.View_Model extends Efl.Composite_Model
|
2018-11-28 16:03:33 -08:00
|
|
|
{
|
2019-09-02 07:24:26 -07:00
|
|
|
[[Efl model providing helpers for custom properties used when linking a model to a view and you need to
|
|
|
|
generate/adapt values for display.
|
2018-11-28 16:03:33 -08:00
|
|
|
|
2019-09-02 07:24:26 -07:00
|
|
|
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.
|
2019-10-14 00:55:52 -07:00
|
|
|
|
|
|
|
@since 1.23
|
2018-11-28 16:03:33 -08:00
|
|
|
]]
|
|
|
|
methods {
|
2019-04-28 10:59:57 -07:00
|
|
|
property_string_add {
|
|
|
|
[[Adds a synthetic string property, generated from a $definition string and other properties in the model.
|
|
|
|
|
2019-09-02 07:24:26 -07:00
|
|
|
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.
|
2019-04-28 10:59:57 -07:00
|
|
|
|
2019-09-02 07:24:26 -07:00
|
|
|
$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.
|
2019-04-28 10:59:57 -07:00
|
|
|
|
|
|
|
See @.property_string_del
|
|
|
|
]]
|
|
|
|
params {
|
|
|
|
name: string; [[The name for the new synthetic property.]]
|
|
|
|
definition: string; [[The definition string for the new synthetic property.]]
|
2019-09-02 07:24:26 -07:00
|
|
|
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.]]
|
2019-04-28 10:59:57 -07:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2019-09-25 08:02:14 -07:00
|
|
|
property_logic_add @beta {
|
2019-09-02 07:24:26 -07:00
|
|
|
[[Add callbacks that will be triggered when someone ask for the specified property name when getting or
|
|
|
|
setting a property.
|
2018-11-28 16:03:33 -08:00
|
|
|
|
|
|
|
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.]]
|
2019-09-04 08:07:37 -07:00
|
|
|
get: EflUiViewModelPropertyGet; [[Define the get callback called when the @Efl.Model.property.get is called
|
2019-09-02 07:24:26 -07:00
|
|
|
with the above property name.]]
|
2019-09-04 08:07:37 -07:00
|
|
|
set: EflUiViewModelPropertySet; [[Define the set callback called when the @Efl.Model.property.set is called
|
2019-09-02 07:24:26 -07:00
|
|
|
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.]]
|
2018-11-28 16:03:33 -08:00
|
|
|
}
|
|
|
|
return: Eina.Error;
|
|
|
|
}
|
2019-09-25 08:02:14 -07:00
|
|
|
property_logic_del @beta {
|
2019-09-02 07:24:26 -07:00
|
|
|
[[Delete previously added callbacks that were triggered when someone asked for the specified property name
|
|
|
|
when getting or setting a property.
|
2018-11-28 16:03:33 -08:00
|
|
|
|
|
|
|
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.]]
|
2019-09-04 08:07:37 -07:00
|
|
|
@in destination: string; [[Property name in the @Efl.Ui.View_Model]]
|
2018-11-28 16:03:33 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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.]]
|
2019-09-04 08:07:37 -07:00
|
|
|
@in destination: string; [[Property name in the @Efl.Ui.View_Model]]
|
2018-11-28 16:03:33 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@property children_bind {
|
2019-09-02 07:24:26 -07:00
|
|
|
[[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
|
2018-11-28 16:03:33 -08:00
|
|
|
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 {
|
2019-09-04 08:07:37 -07:00
|
|
|
Efl.Ui.View_Model.children_bind @optional;
|
2018-11-28 16:03:33 -08:00
|
|
|
}
|
|
|
|
}
|