Compare commits

...

2 Commits

Author SHA1 Message Date
Marcel Hollerbach 2d0564e347 efl_ui_progressbar: remove pulse_mode
pulse_mode is now implicit with pulse, if you set the progressbar to
pulse, the state is internally adjusted in a way that the theme is put
into the correct state. Legacy is not impacted by this because of the
previous commit.

ref T8501
2019-12-20 14:34:53 +01:00
Marcel Hollerbach 9fa6013b88 elm_progressbar: make pulse and pulse_mode independend from legacy
the next commit will refactor this API for Efl.Ui namespace.

ref T8501
2019-12-20 14:34:53 +01:00
3 changed files with 50 additions and 66 deletions

View File

@ -96,7 +96,6 @@ test_part_shadow(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
pb = efl_add(EFL_UI_PROGRESSBAR_CLASS, win);
efl_gfx_hint_weight_set(pb, EFL_GFX_HINT_EXPAND, 0);
efl_ui_progressbar_pulse_mode_set(pb, EINA_TRUE);
efl_pack(bx, pb);
td->pb1 = pb;
@ -122,7 +121,6 @@ test_part_shadow(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
efl_unref(shadow);
pb = efl_add(EFL_UI_PROGRESSBAR_CLASS, win);
efl_ui_progressbar_pulse_mode_set(pb, EINA_TRUE);
efl_gfx_hint_weight_set(pb, EFL_GFX_HINT_EXPAND, 0);
efl_pack(bx, pb);
td->pb4 = pb;
@ -150,7 +148,6 @@ test_part_shadow(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
// FIXME: Needs wheel progressbar class
pb = efl_add(EFL_UI_PROGRESSBAR_CLASS, win,
efl_ui_widget_style_set(efl_added, "wheel"));
efl_ui_progressbar_pulse_mode_set(pb, EINA_TRUE);
efl_pack(hbx, pb);
td->pb2 = pb;
@ -163,7 +160,6 @@ test_part_shadow(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
pb = efl_add(EFL_UI_PROGRESSBAR_CLASS, win,
efl_ui_widget_style_set(efl_added, "wheel"));
efl_ui_progressbar_pulse_mode_set(pb, EINA_TRUE);
efl_pack(hbx, pb);
td->pb3 = pb;

View File

@ -406,23 +406,6 @@ _efl_ui_progressbar_efl_object_constructor(Eo *obj, Efl_Ui_Progressbar_Data *_pd
return obj;
}
EOLIAN static void
_efl_ui_progressbar_pulse_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, Eina_Bool pulse)
{
pulse = !!pulse;
if (sd->pulse == pulse) return;
sd->pulse = pulse;
efl_ui_widget_theme_apply(obj);
}
EOLIAN static Eina_Bool
_efl_ui_progressbar_pulse_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
{
return sd->pulse;
}
EOLIAN static void
_efl_ui_progressbar_efl_ui_layout_orientable_orientation_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Efl_Ui_Layout_Orientation dir)
{
@ -513,6 +496,18 @@ _progress_part_min_max_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *par
_val_set(obj);
}
static void
_internal_theme_mode_pulse_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Eina_Bool pulse)
{
if (elm_widget_is_legacy(obj))
return;
if (sd->pulse == pulse)
return;
sd->pulse = pulse;
efl_ui_widget_theme_apply(obj);
}
static void
_progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double val)
{
@ -527,6 +522,8 @@ _progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *pa
};
Eina_Bool is_cur_progressbar = !strcmp(part_name, curprogresspart[elm_widget_is_legacy(obj)]);
_internal_theme_mode_pulse_set(obj, sd, EINA_FALSE);
if ((!is_cur_progressbar) || sd->has_cur_progressbar_part)
efl_ui_range_limits_get(efl_part(obj, part_name), &min, &max);
@ -618,28 +615,29 @@ _efl_ui_progressbar_efl_ui_range_display_range_value_get(const Eo *obj, Efl_Ui_P
return efl_ui_range_value_get(efl_part(obj, "efl.cur.progressbar"));
}
static void
_apply_pulse_state(Eo *obj, Efl_Ui_Progressbar_Data *sd)
{
const char *emitter = elm_widget_is_legacy(obj) ? "elm" : "efl";
const char *signal = elm_widget_is_legacy(obj) ? "elm,state,pulse," : "efl,state,pulse,";
char signal_buffer[strlen(signal) + strlen("start") + 1];
snprintf(signal_buffer, sizeof(signal_buffer), "%s%s", signal, sd->pulse_state ? "start" : "stop");
elm_layout_signal_emit(obj, signal_buffer, emitter);
}
EOLIAN static void
_efl_ui_progressbar_pulse_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Eina_Bool state)
{
state = !!state;
if ((!sd->pulse) || (sd->pulse_state == state)) return;
if (sd->pulse_state == state)
return;
sd->pulse_state = state;
if (elm_widget_is_legacy(obj))
{
if (sd->pulse_state)
elm_layout_signal_emit(obj, "elm,state,pulse,start", "elm");
else
elm_layout_signal_emit(obj, "elm,state,pulse,stop", "elm");
}
else
{
if (sd->pulse_state)
elm_layout_signal_emit(obj, "efl,state,pulse,start", "efl");
else
elm_layout_signal_emit(obj, "efl,state,pulse,stop", "efl");
}
_internal_theme_mode_pulse_set(obj, sd, EINA_TRUE);
_apply_pulse_state(obj, sd);
}
EOLIAN static Eina_Bool
@ -899,25 +897,40 @@ elm_progressbar_add(Evas_Object *parent)
EAPI void
elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse)
{
efl_ui_progressbar_pulse_mode_set(obj, pulse);
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
pulse = !!pulse;
if (sd->pulse == pulse) return;
sd->pulse = pulse;
efl_ui_widget_theme_apply(obj);
}
EAPI Eina_Bool
elm_progressbar_pulse_get(const Evas_Object *obj)
{
return efl_ui_progressbar_pulse_mode_get(obj);
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
return sd->pulse;
}
EAPI void
elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state)
{
efl_ui_progressbar_pulse_set(obj, state);
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
state = !!state;
if ((!sd->pulse) || (sd->pulse_state == state)) return;
sd->pulse_state = state;
_apply_pulse_state(obj, sd);
}
EAPI Eina_Bool
elm_progressbar_is_pulsing_get(const Evas_Object *obj)
{
return efl_ui_progressbar_pulse_get(obj);
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
return (sd->pulse_state && sd->pulse);
}
EAPI void

View File

@ -4,33 +4,8 @@ class @beta Efl.Ui.Progressbar extends Efl.Ui.Layout_Base implements Efl.Ui.Rang
{
[[Elementary progressbar class]]
methods {
@property pulse_mode {
[[Control whether a given progress bar widget is at "pulsing mode" or not.
By default progress bars display values from low to
high boundaries. There are situations however in which the
progress of a given task is unknown. In these cases,
you can set a progress bar widget to a "pulsing state" to give
the user an idea that some computation is being done
without showing the precise progress rate. In the default theme, it will
animate the bar with content, switching constantly between filling it and back
to non-filled in a loop. To start and stop this pulsing
animation you need to explicitly call @.pulse.set().
]]
set {
}
get {
}
values {
pulse: bool; [[$true to put $obj in pulsing mode, $false to put it back to its default one]]
}
}
@property pulse {
[[Start/stop a given progress bar "pulsing" animation, if its under that mode.
Note: This call won't do anything if $obj is not under "pulsing mode". See @.pulse_mode.
]]
[[Start/stop a given progress bar "pulsing" animation, if its under that mode.]]
set {
}
get {