2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-03 04:27:30 -07:00
|
|
|
#define EFL_ACCESS_OBJECT_PROTECTED
|
2016-04-20 05:07:38 -07:00
|
|
|
#define ELM_LAYOUT_PROTECTED
|
2017-11-15 19:05:21 -08:00
|
|
|
#define EFL_ACCESS_VALUE_PROTECTED
|
2018-05-03 16:34:17 -07:00
|
|
|
#define EFL_PART_PROTECTED
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
#define EFL_UI_FORMAT_PROTECTED
|
2014-10-17 08:56:11 -07:00
|
|
|
|
2009-08-12 09:16:31 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2009-08-12 09:16:31 -07:00
|
|
|
#include "elm_priv.h"
|
2017-05-23 02:30:00 -07:00
|
|
|
#include "efl_ui_progressbar_private.h"
|
2012-11-25 22:32:53 -08:00
|
|
|
#include "elm_widget_layout.h"
|
2012-05-03 15:43:37 -07:00
|
|
|
|
edje/elm: Rename _internal_ to _part_ (EO)
In Edje and Elementary, we have part objects, which are what is returned
by the interface efl_part(). Those objects can't be of an opaque type as
this doesn't work nicely with strongly typed languages such as C++ or
C#. In JS, Lua, C the types are weak and mostly runtime-based so it
doesn't matter much.
As a consequence, the documentation and the types need to look nice in
this EO API. Thus, we remove the abusive term "internal" and explicitly
call all those classes "part" something.
Eventually we want the types to be declared in the EO file so bindings
(C#, C++, ...) can generate the proper access methods, returning the
best possible types.
Note that right now a few of those part types are used in the legacy API
but don't actually need to be exposed externally.
This is kind of a mega commit that does all the renaming at once, but
it's really just a big sed operation. The power of good IDEs :)
Ref T5315
Ref T5306
2017-09-12 21:29:25 -07:00
|
|
|
#include "efl_ui_progressbar_part.eo.h"
|
2016-05-24 04:40:18 -07:00
|
|
|
#include "elm_part_helper.h"
|
|
|
|
|
2017-05-23 02:30:00 -07:00
|
|
|
#define MY_CLASS EFL_UI_PROGRESSBAR_CLASS
|
2017-07-27 23:35:10 -07:00
|
|
|
#define MY_CLASS_PFX efl_ui_progressbar
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2017-05-23 02:30:00 -07:00
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Progressbar"
|
2009-08-12 09:16:31 -07:00
|
|
|
|
2012-06-22 15:45:13 -07:00
|
|
|
static const char SIG_CHANGED[] = "changed";
|
|
|
|
|
2009-08-12 09:16:31 -07:00
|
|
|
#define MIN_RATIO_LVL 0.0
|
|
|
|
#define MAX_RATIO_LVL 1.0
|
|
|
|
|
2012-06-22 15:45:13 -07:00
|
|
|
/* smart callbacks coming from elm progressbar objects (besides the
|
|
|
|
* ones coming from elm layout): */
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_CHANGED, ""},
|
2014-01-23 03:07:20 -08:00
|
|
|
{SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-07 21:05:06 -08:00
|
|
|
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2012-06-22 15:45:13 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2012-05-03 15:43:37 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
2009-08-12 09:16:31 -07:00
|
|
|
{
|
2012-05-03 15:43:37 -07:00
|
|
|
{"icon", "elm.swallow.content"},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2009-08-12 09:16:31 -07:00
|
|
|
|
2017-05-23 02:30:00 -07:00
|
|
|
static Efl_Ui_Progress_Status *
|
2019-05-29 06:28:47 -07:00
|
|
|
_progress_status_new(const char *part_name, double val, Eina_Bool exists)
|
2013-09-09 23:47:13 -07:00
|
|
|
{
|
2017-05-23 02:30:00 -07:00
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
ps = calloc(1, sizeof(Efl_Ui_Progress_Status));
|
2019-01-29 06:23:44 -08:00
|
|
|
if (!ps) return NULL;
|
2013-09-09 23:47:13 -07:00
|
|
|
ps->part_name = eina_stringshare_add(part_name);
|
|
|
|
ps->val = val;
|
2019-05-29 06:28:47 -07:00
|
|
|
ps->part_exists = exists;
|
2013-09-09 23:47:13 -07:00
|
|
|
return ps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2017-05-23 02:30:00 -07:00
|
|
|
_progress_status_free(Efl_Ui_Progress_Status *ps)
|
2013-09-09 23:47:13 -07:00
|
|
|
{
|
|
|
|
eina_stringshare_del(ps->part_name);
|
|
|
|
free(ps);
|
|
|
|
}
|
2016-04-07 00:50:03 -07:00
|
|
|
|
|
|
|
static inline Eina_Bool
|
2019-05-24 09:30:31 -07:00
|
|
|
_is_horizontal(Efl_Ui_Layout_Orientation dir)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
2019-05-24 09:30:31 -07:00
|
|
|
return efl_ui_layout_orientation_is_horizontal(dir, EINA_TRUE);
|
2017-08-09 07:47:24 -07:00
|
|
|
}
|
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:43:37 -07:00
|
|
|
_units_set(Evas_Object *obj)
|
2009-08-12 09:16:31 -07:00
|
|
|
{
|
2017-06-16 00:14:37 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET(obj, sd);
|
2009-08-12 09:16:31 -07:00
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
if (sd->show_progress_label)
|
2012-06-15 09:32:54 -07:00
|
|
|
{
|
2017-10-25 10:10:29 -07:00
|
|
|
Eina_Value val;
|
2012-06-15 09:32:54 -07:00
|
|
|
|
2017-10-25 10:10:29 -07:00
|
|
|
eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE);
|
2017-10-26 19:48:10 -07:00
|
|
|
eina_value_set(&val, sd->val);
|
|
|
|
|
|
|
|
// Keeping this bug since the legacy code was like that.
|
|
|
|
if (sd->is_legacy_format_string && !sd->is_legacy_format_cb)
|
2017-10-25 10:10:29 -07:00
|
|
|
eina_value_set(&val, 100 * sd->val);
|
2012-05-03 15:43:37 -07:00
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
if (!sd->format_strbuf) sd->format_strbuf = eina_strbuf_new();
|
|
|
|
efl_ui_format_formatted_value_get(obj, sd->format_strbuf, val);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
2019-05-29 06:28:47 -07:00
|
|
|
eina_value_flush(&val);
|
|
|
|
|
|
|
|
if (!sd->has_status_text_part) return;
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
elm_layout_text_set(obj, "elm.text.status", eina_strbuf_string_get(sd->format_strbuf));
|
|
|
|
else
|
|
|
|
elm_layout_text_set(obj, "efl.text.status", eina_strbuf_string_get(sd->format_strbuf));
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2019-05-29 06:28:47 -07:00
|
|
|
else if (sd->has_status_text_part)
|
2018-04-26 03:27:43 -07:00
|
|
|
{
|
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
elm_layout_text_set(obj, "elm.text.status", NULL);
|
|
|
|
else
|
|
|
|
elm_layout_text_set(obj, "efl.text.status", NULL);
|
|
|
|
}
|
2012-05-03 15:43:37 -07:00
|
|
|
}
|
2009-10-22 15:10:23 -07:00
|
|
|
|
2012-05-03 15:43:37 -07:00
|
|
|
static void
|
|
|
|
_val_set(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
double pos;
|
2018-02-06 05:33:58 -08:00
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
Eina_List *l;
|
2012-05-02 10:00:48 -07:00
|
|
|
|
2017-06-16 00:14:37 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET(obj, sd);
|
2013-10-05 01:15:19 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-02 10:00:48 -07:00
|
|
|
|
2013-09-09 23:47:13 -07:00
|
|
|
EINA_LIST_FOREACH(sd->progress_status, l, ps)
|
2017-08-09 07:47:24 -07:00
|
|
|
{
|
2018-02-06 05:33:58 -08:00
|
|
|
if (EINA_DBL_EQ(ps->val_max, ps->val_min))
|
|
|
|
{
|
|
|
|
WRN("progressbar min and max are equal.");
|
|
|
|
continue;
|
|
|
|
}
|
2019-05-29 06:28:47 -07:00
|
|
|
if (!ps->part_exists) continue;
|
2018-01-16 22:52:58 -08:00
|
|
|
pos = (ps->val - ps->val_min)/(ps->val_max - ps->val_min);
|
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
if (efl_ui_mirrored_get(obj) ^ efl_ui_layout_orientation_is_inverted(sd->dir))
|
2017-08-09 07:47:24 -07:00
|
|
|
pos = MAX_RATIO_LVL - pos;
|
|
|
|
|
|
|
|
edje_object_part_drag_value_set
|
|
|
|
(wd->resize_obj, ps->part_name, pos, pos);
|
|
|
|
}
|
2009-08-12 09:16:31 -07:00
|
|
|
}
|
|
|
|
|
2017-11-14 03:38:49 -08:00
|
|
|
//TODO: efl_ui_slider also use this.
|
|
|
|
static const char *
|
|
|
|
_theme_group_modify_pos_get(const char *cur_group, const char *search, size_t len, Eina_Bool is_legacy)
|
|
|
|
{
|
|
|
|
const char *pos = NULL;
|
|
|
|
const char *temp_str = NULL;
|
|
|
|
|
|
|
|
if (is_legacy)
|
|
|
|
return cur_group;
|
|
|
|
|
|
|
|
temp_str = cur_group + len - strlen(search);
|
|
|
|
if (temp_str >= cur_group)
|
|
|
|
{
|
|
|
|
if (!strcmp(temp_str, search))
|
|
|
|
pos = temp_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
_efl_ui_progressbar_theme_group_get(Evas_Object *obj, Efl_Ui_Progressbar_Data *sd)
|
|
|
|
{
|
|
|
|
const char *pos = NULL;
|
|
|
|
const char *cur_group = elm_widget_theme_element_get(obj);
|
|
|
|
Eina_Strbuf *new_group = eina_strbuf_new();
|
|
|
|
Eina_Bool is_legacy = elm_widget_is_legacy(obj);
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
if (cur_group)
|
|
|
|
{
|
|
|
|
len = strlen(cur_group);
|
|
|
|
pos = _theme_group_modify_pos_get(cur_group, "horizontal", len, is_legacy);
|
|
|
|
if (!pos)
|
|
|
|
pos = _theme_group_modify_pos_get(cur_group, "vertical", len, is_legacy);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: change separator when it is decided.
|
|
|
|
// can skip when prev_group == cur_group
|
|
|
|
if (!pos)
|
|
|
|
{
|
|
|
|
eina_strbuf_append(new_group, cur_group);
|
|
|
|
eina_strbuf_append(new_group, "/");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_strbuf_append_length(new_group, cur_group, pos - cur_group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_is_horizontal(sd->dir))
|
|
|
|
eina_strbuf_append(new_group, "horizontal");
|
|
|
|
else
|
|
|
|
eina_strbuf_append(new_group, "vertical");
|
|
|
|
|
|
|
|
return eina_strbuf_release(new_group);
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:37:07 -08:00
|
|
|
EOLIAN static Eina_Error
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_progressbar_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Progressbar_Data *sd)
|
2011-07-04 03:13:53 -07:00
|
|
|
{
|
2019-03-04 10:37:07 -08:00
|
|
|
Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
|
2019-03-04 10:36:41 -08:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC);
|
2017-11-14 03:38:49 -08:00
|
|
|
char *group;
|
2019-05-29 06:28:47 -07:00
|
|
|
const char *statuspart[] =
|
|
|
|
{
|
|
|
|
"efl.text.status",
|
|
|
|
"elm.text.status",
|
|
|
|
};
|
|
|
|
const char *curprogresspart[] =
|
|
|
|
{
|
|
|
|
"efl.cur.progressbar",
|
|
|
|
"elm.cur.progressbar",
|
|
|
|
};
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2017-11-14 03:38:49 -08:00
|
|
|
group = _efl_ui_progressbar_theme_group_get(obj, sd);
|
|
|
|
if (group)
|
|
|
|
{
|
|
|
|
elm_widget_theme_element_set(obj, group);
|
|
|
|
free(group);
|
|
|
|
}
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
|
2019-03-04 10:36:41 -08:00
|
|
|
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
{
|
|
|
|
if (sd->pulse)
|
|
|
|
elm_layout_signal_emit(obj, "elm,state,pulse", "elm");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "elm,state,fraction", "elm");
|
|
|
|
|
|
|
|
if (sd->pulse_state)
|
|
|
|
elm_layout_signal_emit(obj, "elm,state,pulse,start", "elm");
|
|
|
|
|
2019-06-28 01:08:03 -07:00
|
|
|
if (sd->show_progress_label && (!sd->pulse))
|
2018-04-26 04:24:09 -07:00
|
|
|
elm_layout_signal_emit(obj, "elm,state,units,visible", "elm");
|
|
|
|
}
|
2012-05-02 18:19:05 -07:00
|
|
|
else
|
2018-04-26 04:24:09 -07:00
|
|
|
{
|
|
|
|
if (sd->pulse)
|
|
|
|
elm_layout_signal_emit(obj, "efl,state,pulse", "efl");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "efl,state,fraction", "efl");
|
2011-07-04 03:13:53 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
if (sd->pulse_state)
|
|
|
|
elm_layout_signal_emit(obj, "efl,state,pulse,start", "efl");
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2019-06-28 01:08:03 -07:00
|
|
|
if (sd->show_progress_label && (!sd->pulse))
|
2018-04-26 04:24:09 -07:00
|
|
|
elm_layout_signal_emit(obj, "efl,state,units,visible", "efl");
|
|
|
|
}
|
2019-05-29 06:28:47 -07:00
|
|
|
sd->has_status_text_part = edje_object_part_exists(obj, statuspart[elm_widget_is_legacy(obj)]);
|
|
|
|
sd->has_cur_progressbar_part = edje_object_part_exists(obj, curprogresspart[elm_widget_is_legacy(obj)]);
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2017-08-09 07:47:24 -07:00
|
|
|
if (_is_horizontal(sd->dir))
|
2012-05-03 15:43:37 -07:00
|
|
|
evas_object_size_hint_min_set
|
2018-04-05 01:47:26 -07:00
|
|
|
(sd->spacer, (double)sd->size * efl_gfx_entity_scale_get(obj) *
|
2012-05-03 15:43:37 -07:00
|
|
|
elm_config_scale_get(), 1);
|
2012-05-02 18:19:05 -07:00
|
|
|
else
|
2012-05-03 15:43:37 -07:00
|
|
|
evas_object_size_hint_min_set
|
2018-04-05 01:47:26 -07:00
|
|
|
(sd->spacer, 1, (double)sd->size * efl_gfx_entity_scale_get(obj) *
|
2012-05-03 15:43:37 -07:00
|
|
|
elm_config_scale_get());
|
2012-05-02 10:00:48 -07:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
{
|
2019-05-24 09:30:31 -07:00
|
|
|
if (efl_ui_layout_orientation_is_inverted(sd->dir))
|
2018-04-26 04:24:09 -07:00
|
|
|
elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm");
|
|
|
|
}
|
2016-04-07 00:50:03 -07:00
|
|
|
else
|
2018-04-26 04:24:09 -07:00
|
|
|
{
|
2019-05-24 09:30:31 -07:00
|
|
|
if (efl_ui_layout_orientation_is_inverted(sd->dir))
|
2018-04-26 04:24:09 -07:00
|
|
|
elm_layout_signal_emit(obj, "efl,state,inverted,on", "efl");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "efl,state,inverted,off", "efl");
|
|
|
|
}
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2019-05-29 06:28:47 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
const Eina_List *l;
|
|
|
|
EINA_LIST_FOREACH(sd->progress_status, l, ps)
|
|
|
|
ps->part_exists = edje_object_part_exists(obj, ps->part_name);
|
|
|
|
}
|
|
|
|
|
2012-05-03 15:43:37 -07:00
|
|
|
_units_set(obj);
|
|
|
|
_val_set(obj);
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
edje_object_message_signal_process(wd->resize_obj);
|
2012-05-03 15:43:37 -07:00
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return int_ret;
|
2011-07-04 03:13:53 -07:00
|
|
|
}
|
|
|
|
|
2012-08-18 06:52:03 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2012-08-18 06:52:03 -07:00
|
|
|
{
|
|
|
|
const char *txt = elm_widget_access_info_get(obj);
|
|
|
|
|
|
|
|
if (!txt) txt = elm_layout_text_get(obj, NULL);
|
|
|
|
if (txt) return strdup(txt);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2012-08-18 06:52:03 -07:00
|
|
|
{
|
|
|
|
char *ret;
|
|
|
|
Eina_Strbuf *buf;
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
|
2019-05-29 06:28:47 -07:00
|
|
|
const char *txt = NULL;
|
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET(obj, sd);
|
|
|
|
if (sd->format_strbuf)
|
|
|
|
txt = eina_strbuf_string_get(sd->format_strbuf);
|
2018-04-26 03:27:43 -07:00
|
|
|
|
2012-08-18 06:52:03 -07:00
|
|
|
if (txt) eina_strbuf_append(buf, txt);
|
|
|
|
|
|
|
|
if (elm_widget_disabled_get(obj))
|
|
|
|
eina_strbuf_append(buf, " state: disabled");
|
|
|
|
|
|
|
|
if (eina_strbuf_length_get(buf))
|
|
|
|
{
|
|
|
|
ret = eina_strbuf_string_steal(buf);
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-26 00:36:41 -07:00
|
|
|
EOLIAN static void
|
2017-05-23 02:30:00 -07:00
|
|
|
_efl_ui_progressbar_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Progressbar_Data *priv)
|
2011-10-30 19:56:03 -07:00
|
|
|
{
|
2013-10-05 01:15:19 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2017-12-11 11:51:09 -08:00
|
|
|
char *group;
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2017-11-14 05:03:25 -08:00
|
|
|
if (!elm_widget_theme_klass_get(obj))
|
|
|
|
elm_widget_theme_klass_set(obj, "progressbar");
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
2013-08-26 22:19:19 -07:00
|
|
|
|
2019-07-30 10:11:48 -07:00
|
|
|
efl_ui_layout_finger_size_multiplier_set(obj, 0, 0);
|
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
priv->dir = EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL;
|
2012-05-03 15:43:37 -07:00
|
|
|
priv->val = MIN_RATIO_LVL;
|
2018-01-16 22:52:58 -08:00
|
|
|
priv->val_max = 1.0;
|
2017-12-11 11:51:09 -08:00
|
|
|
group = _efl_ui_progressbar_theme_group_get(obj, priv);
|
|
|
|
|
2019-03-04 10:36:41 -08:00
|
|
|
if (elm_widget_theme_object_set(obj, wd->resize_obj,
|
|
|
|
elm_widget_theme_klass_get(obj),
|
|
|
|
group,
|
|
|
|
elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2017-12-11 11:51:09 -08:00
|
|
|
free(group);
|
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl_ui_format_string_set(obj, "%.0f%%", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2012-05-03 15:43:37 -07:00
|
|
|
priv->spacer = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_color_set(priv->spacer, 0, 0, 0, 0);
|
|
|
|
evas_object_pass_events_set(priv->spacer, EINA_TRUE);
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
elm_layout_content_set(obj, "elm.swallow.bar", priv->spacer);
|
|
|
|
else
|
|
|
|
elm_layout_content_set(obj, "efl.bar", priv->spacer);
|
2012-05-03 15:43:37 -07:00
|
|
|
|
|
|
|
_units_set(obj);
|
|
|
|
_val_set(obj);
|
|
|
|
|
2012-08-18 06:52:03 -07:00
|
|
|
if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
_elm_access_object_register(obj, wd->resize_obj);
|
2012-08-18 06:52:03 -07:00
|
|
|
_elm_access_text_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("progressbar"));
|
2012-08-18 06:52:03 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
|
2012-08-18 06:52:03 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, NULL);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2011-10-30 19:56:03 -07:00
|
|
|
|
2014-03-26 00:36:41 -07:00
|
|
|
EOLIAN static void
|
2017-05-23 02:30:00 -07:00
|
|
|
_efl_ui_progressbar_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Progressbar_Data *sd)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2017-05-23 02:30:00 -07:00
|
|
|
Efl_Ui_Progress_Status *progress_obj;
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2013-09-09 23:47:13 -07:00
|
|
|
if (sd->progress_status)
|
|
|
|
{
|
|
|
|
EINA_LIST_FREE(sd->progress_status, progress_obj)
|
|
|
|
{
|
|
|
|
_progress_status_free(progress_obj);
|
|
|
|
}
|
|
|
|
}
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2017-10-25 10:10:29 -07:00
|
|
|
eina_strbuf_free(sd->format_strbuf);
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
sd->format_strbuf = NULL;
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2011-10-30 19:56:03 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2017-05-23 02:30:00 -07:00
|
|
|
_efl_ui_progressbar_efl_object_constructor(Eo *obj, Efl_Ui_Progressbar_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
2018-04-03 04:27:30 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PROGRESS_BAR);
|
2019-06-19 00:55:51 -07:00
|
|
|
efl_ui_range_limits_set(obj, 0.0, 1.0);
|
2019-06-28 01:08:03 -07:00
|
|
|
efl_ui_progressbar_show_progress_label_set(obj, EINA_TRUE);
|
2015-05-19 05:34:07 -07:00
|
|
|
return obj;
|
2009-08-12 09:16:31 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 00:36:41 -07:00
|
|
|
EOLIAN static void
|
2017-05-23 22:12:34 -07:00
|
|
|
_efl_ui_progressbar_pulse_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, Eina_Bool pulse)
|
2009-08-12 09:16:31 -07:00
|
|
|
{
|
|
|
|
pulse = !!pulse;
|
2012-05-03 15:43:37 -07:00
|
|
|
if (sd->pulse == pulse) return;
|
|
|
|
|
|
|
|
sd->pulse = pulse;
|
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
efl_ui_widget_theme_apply(obj);
|
2009-08-12 09:16:31 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 00:36:41 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_progressbar_pulse_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
|
2009-08-12 09:16:31 -07:00
|
|
|
{
|
2014-03-26 00:36:41 -07:00
|
|
|
return sd->pulse;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EOLIAN static void
|
2019-05-24 09:30:31 -07:00
|
|
|
_efl_ui_progressbar_efl_ui_layout_orientable_orientation_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Efl_Ui_Layout_Orientation dir)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
2018-10-11 03:42:57 -07:00
|
|
|
if (sd->dir == dir) return;
|
|
|
|
|
2017-08-09 07:47:24 -07:00
|
|
|
sd->dir = dir;
|
2016-04-07 00:50:03 -07:00
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
efl_ui_widget_theme_apply(obj);
|
2016-04-07 00:50:03 -07:00
|
|
|
}
|
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
EOLIAN static Efl_Ui_Layout_Orientation
|
|
|
|
_efl_ui_progressbar_efl_ui_layout_orientable_orientation_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
2017-08-09 07:47:24 -07:00
|
|
|
return sd->dir;
|
2016-04-07 00:50:03 -07:00
|
|
|
}
|
|
|
|
|
2017-09-19 19:16:17 -07:00
|
|
|
static void
|
|
|
|
_progressbar_span_size_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Evas_Coord size)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
|
|
|
if (sd->size == size) return;
|
|
|
|
|
|
|
|
sd->size = size;
|
|
|
|
|
2017-08-09 07:47:24 -07:00
|
|
|
if (_is_horizontal(sd->dir))
|
2016-04-07 00:50:03 -07:00
|
|
|
evas_object_size_hint_min_set
|
2018-04-05 01:47:26 -07:00
|
|
|
(sd->spacer, (double)sd->size * efl_gfx_entity_scale_get(obj) *
|
2016-04-07 00:50:03 -07:00
|
|
|
elm_config_scale_get(), 1);
|
|
|
|
else
|
|
|
|
evas_object_size_hint_min_set
|
2018-04-05 01:47:26 -07:00
|
|
|
(sd->spacer, 1, (double)sd->size * efl_gfx_entity_scale_get(obj) *
|
2016-04-07 00:50:03 -07:00
|
|
|
elm_config_scale_get());
|
|
|
|
|
2019-07-30 10:11:19 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-07 00:50:03 -07:00
|
|
|
}
|
|
|
|
|
2018-01-16 22:52:58 -08:00
|
|
|
static void
|
2018-02-06 05:33:58 -08:00
|
|
|
_progress_part_min_max_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double min, double max)
|
2018-01-16 22:52:58 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
Eina_Bool existing_ps = EINA_FALSE;
|
|
|
|
Eina_List *l;
|
|
|
|
|
2018-02-06 05:33:58 -08:00
|
|
|
if (EINA_DBL_EQ(min, max))
|
|
|
|
{
|
|
|
|
ERR("min & max provided are equal.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (min > max)
|
|
|
|
{
|
|
|
|
WRN("min is greater than max.");
|
|
|
|
}
|
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
2018-01-16 22:52:58 -08:00
|
|
|
{
|
2018-04-26 03:27:43 -07:00
|
|
|
if (!strcmp(part_name, "elm.cur.progressbar"))
|
|
|
|
{
|
|
|
|
sd->val_min = min;
|
|
|
|
sd->val_max = max;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!strcmp(part_name, "efl.cur.progressbar"))
|
|
|
|
{
|
|
|
|
sd->val_min = min;
|
|
|
|
sd->val_max = max;
|
|
|
|
}
|
2018-01-16 22:52:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->progress_status, l, ps)
|
|
|
|
{
|
|
|
|
if (!strcmp(ps->part_name, part_name))
|
|
|
|
{
|
|
|
|
existing_ps = EINA_TRUE;
|
|
|
|
ps->val_min = min;
|
|
|
|
ps->val_max = max;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!existing_ps)
|
|
|
|
{
|
2019-05-29 06:28:47 -07:00
|
|
|
ps = _progress_status_new(part_name, min, edje_object_part_exists(obj, part_name));
|
2018-01-16 22:52:58 -08:00
|
|
|
ps->val_min = min;
|
|
|
|
ps->val_max = max;
|
|
|
|
sd->progress_status = eina_list_append(sd->progress_status, ps);
|
|
|
|
}
|
2018-02-06 05:33:58 -08:00
|
|
|
_val_set(obj);
|
2018-01-16 22:52:58 -08:00
|
|
|
}
|
|
|
|
|
2017-05-24 01:02:37 -07:00
|
|
|
static void
|
|
|
|
_progressbar_part_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, const char *part_name, double val)
|
|
|
|
{
|
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
Eina_Bool existing_ps = EINA_FALSE;
|
|
|
|
Eina_List *l;
|
2018-02-09 23:24:11 -08:00
|
|
|
double min = 0.0, max = 0.0;
|
2019-05-29 06:28:47 -07:00
|
|
|
const char *curprogresspart[] =
|
|
|
|
{
|
|
|
|
"efl.cur.progressbar",
|
|
|
|
"elm.cur.progressbar",
|
|
|
|
};
|
|
|
|
Eina_Bool is_cur_progressbar = !strcmp(part_name, curprogresspart[elm_widget_is_legacy(obj)]);
|
2017-05-24 01:02:37 -07:00
|
|
|
|
2019-05-29 06:28:47 -07:00
|
|
|
if ((!is_cur_progressbar) || sd->has_cur_progressbar_part)
|
2019-06-19 00:55:51 -07:00
|
|
|
efl_ui_range_limits_get(efl_part(obj, part_name), &min, &max);
|
2018-01-16 22:52:58 -08:00
|
|
|
|
|
|
|
if (val < min) val = min;
|
|
|
|
if (val > max) val = max;
|
2017-05-24 01:02:37 -07:00
|
|
|
|
2019-05-29 06:28:47 -07:00
|
|
|
if (is_cur_progressbar)
|
|
|
|
sd->val = val;
|
2017-05-24 01:02:37 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->progress_status, l, ps)
|
|
|
|
{
|
|
|
|
if (!strcmp(ps->part_name, part_name))
|
|
|
|
{
|
|
|
|
existing_ps = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!existing_ps)
|
|
|
|
{
|
2019-05-29 06:28:47 -07:00
|
|
|
ps = _progress_status_new(part_name, val, edje_object_part_exists(obj, part_name));
|
2018-01-16 22:52:58 -08:00
|
|
|
ps->val_min = 0.0;
|
|
|
|
ps->val_max = 1.0;
|
2018-02-09 23:24:11 -08:00
|
|
|
ps->val = val;
|
2017-05-24 01:02:37 -07:00
|
|
|
sd->progress_status = eina_list_append(sd->progress_status, ps);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ps->val = val;
|
|
|
|
|
|
|
|
_val_set(obj);
|
|
|
|
_units_set(obj);
|
|
|
|
efl_event_callback_legacy_call
|
|
|
|
(obj, EFL_UI_PROGRESSBAR_EVENT_CHANGED, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static double
|
|
|
|
_progressbar_part_value_get(Efl_Ui_Progressbar_Data *sd, const char* part)
|
|
|
|
{
|
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->progress_status, l, ps)
|
|
|
|
{
|
|
|
|
if (!strcmp(ps->part_name, part)) return ps->val;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EOLIAN static void
|
2019-01-21 07:22:32 -08:00
|
|
|
_efl_ui_progressbar_efl_ui_range_display_range_value_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double val)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
2017-01-06 09:57:46 -08:00
|
|
|
if (EINA_DBL_EQ(sd->val, val)) return;
|
2016-04-07 00:50:03 -07:00
|
|
|
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
_progressbar_part_value_set(obj, sd, "elm.cur.progressbar", val);
|
|
|
|
else
|
2019-07-10 20:35:58 -07:00
|
|
|
{
|
|
|
|
if (val < sd->val_min)
|
|
|
|
{
|
|
|
|
ERR("Error, value is less than minimum");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (val > sd->val_max)
|
|
|
|
{
|
|
|
|
ERR("Error, value is greater than maximum");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_progressbar_part_value_set(obj, sd, "efl.cur.progressbar", val);
|
|
|
|
}
|
2016-04-07 00:50:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static double
|
2019-05-29 06:28:47 -07:00
|
|
|
_efl_ui_progressbar_efl_ui_range_display_range_value_get(const Eo *obj, Efl_Ui_Progressbar_Data *sd)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
2019-05-29 06:28:47 -07:00
|
|
|
if (!sd->has_cur_progressbar_part) return 0.0;
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
return efl_ui_range_value_get(efl_part(obj, "elm.cur.progressbar"));
|
|
|
|
else
|
|
|
|
return efl_ui_range_value_get(efl_part(obj, "efl.cur.progressbar"));
|
2016-04-07 00:50:03 -07:00
|
|
|
}
|
|
|
|
|
2014-03-26 00:36:41 -07:00
|
|
|
EOLIAN static void
|
2017-05-23 22:12:34 -07:00
|
|
|
_efl_ui_progressbar_pulse_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, Eina_Bool state)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2009-08-12 09:16:31 -07:00
|
|
|
state = !!state;
|
2013-02-19 19:08:33 -08:00
|
|
|
if ((!sd->pulse) || (sd->pulse_state == state)) return;
|
2012-05-03 15:43:37 -07:00
|
|
|
|
|
|
|
sd->pulse_state = state;
|
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
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");
|
|
|
|
}
|
2009-08-12 09:16:31 -07:00
|
|
|
else
|
2018-04-26 04:24:09 -07:00
|
|
|
{
|
|
|
|
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");
|
|
|
|
}
|
2009-08-12 09:16:31 -07:00
|
|
|
}
|
|
|
|
|
2016-09-01 16:58:27 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_progressbar_pulse_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
|
2016-09-01 16:58:27 -07:00
|
|
|
{
|
|
|
|
return (sd->pulse_state && sd->pulse);
|
|
|
|
}
|
|
|
|
|
2018-01-16 22:52:58 -08:00
|
|
|
EOLIAN static void
|
2019-06-19 00:55:51 -07:00
|
|
|
_efl_ui_progressbar_efl_ui_range_display_range_limits_set(Eo *obj, Efl_Ui_Progressbar_Data *sd, double min, double max)
|
2018-01-16 22:52:58 -08:00
|
|
|
{
|
2019-07-08 07:17:38 -07:00
|
|
|
if (max < min)
|
|
|
|
{
|
|
|
|
ERR("Wrong params. min(%lf) is greater than max(%lf).", min, max);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (EINA_DBL_EQ(max, min))
|
|
|
|
{
|
|
|
|
ERR("min and max must have a different value");
|
|
|
|
return;
|
|
|
|
}
|
2018-04-26 03:27:43 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
_progress_part_min_max_set(obj, sd, "elm.cur.progressbar", min, max);
|
|
|
|
else
|
|
|
|
_progress_part_min_max_set(obj, sd, "efl.cur.progressbar", min, max);
|
2018-01-16 22:52:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2019-06-19 00:55:51 -07:00
|
|
|
_efl_ui_progressbar_efl_ui_range_display_range_limits_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd, double *min, double *max)
|
2018-01-16 22:52:58 -08:00
|
|
|
{
|
|
|
|
if (min) *min = sd->val_min;
|
|
|
|
if (max) *max = sd->val_max;
|
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
/* Efl.Part begin */
|
|
|
|
|
|
|
|
EOLIAN static Eo *
|
2018-05-03 16:34:17 -07:00
|
|
|
_efl_ui_progressbar_efl_part_part_get(const Eo *obj, Efl_Ui_Progressbar_Data *sd EINA_UNUSED, const char *part)
|
2009-08-12 09:16:31 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
|
|
|
|
|
|
|
// Progress bars are dragable types
|
2019-03-07 15:39:32 -08:00
|
|
|
if (edje_object_part_drag_dir_get(wd->resize_obj, part) != (Edje_Drag_Dir)EFL_UI_DRAG_DIR_NONE)
|
2017-10-26 05:28:20 -07:00
|
|
|
return ELM_PART_IMPLEMENT(EFL_UI_PROGRESSBAR_PART_CLASS, obj, part);
|
|
|
|
|
2018-05-03 16:34:17 -07:00
|
|
|
return efl_part_get(efl_super(obj, MY_CLASS), part);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EOLIAN static void
|
2019-01-21 07:22:32 -08:00
|
|
|
_efl_ui_progressbar_part_efl_ui_range_display_range_value_set(Eo *obj, void *_pd EINA_UNUSED, double val)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
|
|
|
|
Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
|
|
|
|
|
|
|
|
_progressbar_part_value_set(pd->obj, sd, pd->part, val);
|
2009-08-12 09:16:31 -07:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EOLIAN static double
|
2019-01-21 07:22:32 -08:00
|
|
|
_efl_ui_progressbar_part_efl_ui_range_display_range_value_get(const Eo *obj, void *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
|
|
|
|
Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
|
|
|
|
|
|
|
|
return _progressbar_part_value_get(sd, pd->part);
|
2010-04-01 07:22:36 -07:00
|
|
|
}
|
|
|
|
|
2017-11-15 19:05:21 -08:00
|
|
|
EOLIAN static void
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_progressbar_efl_access_value_value_and_text_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *_pd, double *value, const char **text EINA_UNUSED)
|
2017-11-15 19:05:21 -08:00
|
|
|
{
|
|
|
|
if (value) *value = _pd->val;
|
|
|
|
}
|
|
|
|
|
2018-01-16 22:52:58 -08:00
|
|
|
EOLIAN static void
|
2019-06-19 00:55:51 -07:00
|
|
|
_efl_ui_progressbar_part_efl_ui_range_display_range_limits_set(Eo *obj, void *_pd EINA_UNUSED, double min, double max)
|
2018-01-16 22:52:58 -08:00
|
|
|
{
|
|
|
|
Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
|
|
|
|
Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
|
|
|
|
|
2018-02-06 05:33:58 -08:00
|
|
|
_progress_part_min_max_set(pd->obj, sd, pd->part, min, max);
|
2018-01-16 22:52:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2019-06-19 00:55:51 -07:00
|
|
|
_efl_ui_progressbar_part_efl_ui_range_display_range_limits_get(const Eo *obj, void *_pd EINA_UNUSED, double *min, double *max)
|
2018-01-16 22:52:58 -08:00
|
|
|
{
|
|
|
|
Efl_Ui_Progress_Status *ps;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
|
|
|
|
Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(sd->progress_status, l, ps)
|
|
|
|
{
|
|
|
|
if (!strcmp(ps->part_name, pd->part))
|
|
|
|
{
|
|
|
|
if (min) *min = ps->val_min;
|
|
|
|
if (max) *max = ps->val_max;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-28 01:08:03 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_progressbar_show_progress_label_set(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *pd, Eina_Bool show)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
char signal_name[32];
|
|
|
|
const char *ns = elm_widget_is_legacy(obj) ? "elm" : "efl";
|
|
|
|
|
|
|
|
pd->show_progress_label = show;
|
|
|
|
|
|
|
|
snprintf(signal_name, sizeof(signal_name), "%s,state,units,%s", ns,
|
|
|
|
show ? "visible" : "hidden");
|
|
|
|
elm_layout_signal_emit(obj, signal_name, ns);
|
|
|
|
edje_object_message_signal_process(wd->resize_obj);
|
|
|
|
_units_set(obj);
|
2019-07-30 10:11:19 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2019-06-28 01:08:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_progressbar_show_progress_label_get(const Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *pd)
|
|
|
|
{
|
|
|
|
return pd->show_progress_label;
|
|
|
|
}
|
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_progressbar_efl_ui_format_apply_formatted_value(Eo *obj, Efl_Ui_Progressbar_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_units_set(obj);
|
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
#include "efl_ui_progressbar_part.eo.c"
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
/* Efl.Part end */
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
2018-01-16 03:09:54 -08:00
|
|
|
ELM_PART_TEXT_DEFAULT_IMPLEMENT(efl_ui_progressbar, Efl_Ui_Progressbar_Data)
|
|
|
|
ELM_PART_MARKUP_DEFAULT_IMPLEMENT(efl_ui_progressbar, Efl_Ui_Progressbar_Data)
|
|
|
|
ELM_PART_CONTENT_DEFAULT_IMPLEMENT(efl_ui_progressbar, Efl_Ui_Progressbar_Data)
|
2009-08-12 09:16:31 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(efl_ui_progressbar)
|
2010-04-01 07:22:36 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
#define EFL_UI_PROGRESSBAR_EXTRA_OPS \
|
|
|
|
ELM_LAYOUT_CONTENT_ALIASES_OPS(efl_ui_progressbar), \
|
2018-05-28 01:32:46 -07:00
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_progressbar)
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
#include "efl_ui_progressbar.eo.c"
|
|
|
|
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "efl_ui_progressbar_legacy_eo.h"
|
2018-02-26 04:22:08 -08:00
|
|
|
#include "efl_ui_progressbar_legacy_part.eo.h"
|
2018-01-23 22:50:58 -08:00
|
|
|
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_progressbar"
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_progressbar_legacy_class_constructor(Efl_Class *klass)
|
|
|
|
{
|
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eo *
|
|
|
|
_efl_ui_progressbar_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
obj = efl_constructor(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS));
|
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
|
2018-10-22 04:39:06 -07:00
|
|
|
legacy_object_focus_handle(obj);
|
2018-01-23 22:50:58 -08:00
|
|
|
return obj;
|
|
|
|
}
|
2017-10-26 05:28:20 -07:00
|
|
|
|
2018-02-26 04:22:08 -08:00
|
|
|
/* FIXME: replicated from elm_layout just because progressbar's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
|
|
|
static void
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(Evas_Object *obj)
|
2018-02-26 04:22:08 -08:00
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
if (!elm_widget_resize_object_get(obj)) return;
|
2018-06-18 20:42:09 -07:00
|
|
|
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
|
|
|
|
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
|
2018-02-26 04:22:08 -08:00
|
|
|
|
|
|
|
elm_layout_signal_emit(obj, buf, "elm");
|
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
2019-07-30 10:11:19 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2018-02-26 04:22:08 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: replicated from elm_layout just because progressbar's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
2019-03-04 10:37:07 -08:00
|
|
|
EOLIAN static Eina_Error
|
2018-02-26 04:22:08 -08:00
|
|
|
_efl_ui_progressbar_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
|
|
|
|
{
|
2019-03-04 10:37:07 -08:00
|
|
|
Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
|
2018-02-26 04:22:08 -08:00
|
|
|
|
|
|
|
int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS));
|
2019-03-04 10:36:41 -08:00
|
|
|
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(obj);
|
2018-02-26 04:22:08 -08:00
|
|
|
|
|
|
|
return int_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: replicated from elm_layout just because progressbar's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_progressbar_legacy_efl_ui_widget_widget_sub_object_del(Eo *obj, void *_pd EINA_UNUSED, Evas_Object *sobj)
|
|
|
|
{
|
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
|
|
|
int_ret = elm_widget_sub_object_del(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS), sobj);
|
|
|
|
if (!int_ret) return EINA_FALSE;
|
|
|
|
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(obj);
|
2018-02-26 04:22:08 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: replicated from elm_layout just because progressbar's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
|
|
|
static Eina_Bool
|
|
|
|
_efl_ui_progressbar_legacy_content_set(Eo *obj, void *_pd EINA_UNUSED, const char *part, Evas_Object *content)
|
|
|
|
{
|
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
|
|
|
int_ret = efl_content_set(efl_part(efl_super(obj, EFL_UI_PROGRESSBAR_LEGACY_CLASS), part), content);
|
|
|
|
if (!int_ret) return EINA_FALSE;
|
|
|
|
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(obj);
|
2018-02-26 04:22:08 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Efl.Part for legacy begin */
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_part_is_efl_ui_progressbar_legacy_part(const Eo *obj EINA_UNUSED, const char *part)
|
|
|
|
{
|
|
|
|
return eina_streq(part, "elm.swallow.content");
|
|
|
|
}
|
|
|
|
|
|
|
|
ELM_PART_OVERRIDE_PARTIAL(efl_ui_progressbar_legacy, EFL_UI_PROGRESSBAR_LEGACY, void, _part_is_efl_ui_progressbar_legacy_part)
|
2018-06-20 09:24:06 -07:00
|
|
|
ELM_PART_OVERRIDE_CONTENT_SET_NO_SD(efl_ui_progressbar_legacy)
|
2018-02-26 04:22:08 -08:00
|
|
|
#include "efl_ui_progressbar_legacy_part.eo.c"
|
|
|
|
|
|
|
|
/* Efl.Part for legacy end */
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_progressbar_add(Evas_Object *parent)
|
2017-10-25 10:10:29 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
2018-01-23 22:50:58 -08:00
|
|
|
Eo *obj = elm_legacy_add(EFL_UI_PROGRESSBAR_LEGACY_CLASS, parent);
|
2018-02-09 21:40:54 -08:00
|
|
|
elm_progressbar_unit_format_set(obj, "%.0f%%");
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
return obj;
|
|
|
|
}
|
2017-10-25 10:10:29 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI void
|
|
|
|
elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse)
|
|
|
|
{
|
|
|
|
efl_ui_progressbar_pulse_mode_set(obj, pulse);
|
2017-10-25 10:10:29 -07:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_progressbar_pulse_get(const Evas_Object *obj)
|
2017-10-25 10:10:29 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
return efl_ui_progressbar_pulse_mode_get(obj);
|
2017-10-25 10:10:29 -07:00
|
|
|
}
|
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EAPI void
|
2017-10-26 05:28:20 -07:00
|
|
|
elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state)
|
2012-06-15 09:32:54 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
efl_ui_progressbar_pulse_set(obj, state);
|
|
|
|
}
|
2012-06-15 09:32:54 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_progressbar_is_pulsing_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
return efl_ui_progressbar_pulse_get(obj);
|
2012-06-15 09:32:54 -07:00
|
|
|
}
|
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EAPI void
|
2017-10-26 05:28:20 -07:00
|
|
|
elm_progressbar_part_value_set(Evas_Object *obj, const char *part, double val)
|
2009-08-12 09:16:31 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
if (EINA_DBL_EQ(efl_ui_range_value_get(efl_part(obj, part)), val)) return;
|
|
|
|
efl_ui_range_value_set(efl_part(obj, part), val);
|
|
|
|
}
|
2016-04-07 00:50:03 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI double
|
|
|
|
elm_progressbar_part_value_get(const Evas_Object *obj, const char *part)
|
|
|
|
{
|
|
|
|
return efl_ui_range_value_get(efl_part(obj, part));
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EAPI Eina_Bool
|
2017-05-23 02:30:00 -07:00
|
|
|
elm_progressbar_horizontal_get(const Evas_Object *obj)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2018-04-20 01:49:44 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2018-04-20 01:49:44 -07:00
|
|
|
return _is_horizontal(sd->dir);
|
2016-04-07 00:50:03 -07:00
|
|
|
}
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EAPI void
|
2017-05-23 02:30:00 -07:00
|
|
|
elm_progressbar_inverted_set(Evas_Object *obj, Eina_Bool inverted)
|
2016-04-07 00:50:03 -07:00
|
|
|
{
|
2019-05-24 09:30:31 -07:00
|
|
|
Efl_Ui_Layout_Orientation dir;
|
2018-04-20 01:49:44 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
dir = sd->dir & EFL_UI_LAYOUT_ORIENTATION_AXIS_BITMASK;
|
|
|
|
if (inverted) dir |= EFL_UI_LAYOUT_ORIENTATION_INVERTED;
|
2012-05-03 15:43:37 -07:00
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(obj, dir);
|
2009-08-12 09:16:31 -07:00
|
|
|
}
|
2010-04-01 07:22:36 -07:00
|
|
|
|
2016-04-07 00:50:03 -07:00
|
|
|
EAPI Eina_Bool
|
2017-05-23 02:30:00 -07:00
|
|
|
elm_progressbar_inverted_get(const Evas_Object *obj)
|
2010-04-01 07:22:36 -07:00
|
|
|
{
|
2018-04-20 01:49:44 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
|
2016-04-07 00:50:03 -07:00
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
return efl_ui_layout_orientation_is_inverted(sd->dir);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI void
|
|
|
|
elm_progressbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2019-05-24 09:30:31 -07:00
|
|
|
Efl_Ui_Layout_Orientation dir;
|
2018-04-20 01:49:44 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
|
2017-10-26 05:28:20 -07:00
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
dir = horizontal ? EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL : EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
|
|
|
|
dir |= (sd->dir & EFL_UI_LAYOUT_ORIENTATION_INVERTED);
|
2017-10-26 05:28:20 -07:00
|
|
|
|
2019-05-24 09:30:31 -07:00
|
|
|
efl_ui_layout_orientation_set(obj, dir);
|
2010-04-01 07:22:36 -07:00
|
|
|
}
|
2014-03-26 00:36:41 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
progressbar_func_type format_cb;
|
|
|
|
progressbar_freefunc_type format_free_cb;
|
|
|
|
} Pb_Format_Wrapper_Data;
|
2017-05-24 01:02:37 -07:00
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
static Eina_Bool
|
2017-10-26 05:28:20 -07:00
|
|
|
_format_legacy_to_format_eo_cb(void *data, Eina_Strbuf *str, const Eina_Value value)
|
2017-09-19 19:16:17 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
Pb_Format_Wrapper_Data *pfwd = data;
|
|
|
|
char *buf = NULL;
|
|
|
|
double val = 0;
|
|
|
|
const Eina_Value_Type *type = eina_value_type_get(&value);
|
2017-09-19 19:16:17 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
if (type == EINA_VALUE_TYPE_DOUBLE)
|
|
|
|
eina_value_get(&value, &val);
|
2017-09-19 19:16:17 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
if (pfwd->format_cb)
|
|
|
|
buf = pfwd->format_cb(val);
|
|
|
|
if (buf)
|
|
|
|
eina_strbuf_append(str, buf);
|
|
|
|
if (pfwd->format_free_cb) pfwd->format_free_cb(buf);
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2017-09-19 19:16:17 -07:00
|
|
|
}
|
2017-05-24 01:02:37 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
static void
|
|
|
|
_format_legacy_to_format_eo_free_cb(void *data)
|
2017-05-24 01:02:37 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
Pb_Format_Wrapper_Data *pfwd = data;
|
|
|
|
free(pfwd);
|
2017-05-24 01:02:37 -07:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI void
|
|
|
|
elm_progressbar_unit_format_function_set(Evas_Object *obj, progressbar_func_type func, progressbar_freefunc_type free_func)
|
2017-05-24 01:02:37 -07:00
|
|
|
{
|
2017-10-26 19:48:10 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
|
2017-10-26 05:28:20 -07:00
|
|
|
Pb_Format_Wrapper_Data *pfwd = malloc(sizeof(Pb_Format_Wrapper_Data));
|
2019-01-29 06:23:44 -08:00
|
|
|
if (!pfwd) return;
|
2017-07-27 23:35:10 -07:00
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
pfwd->format_cb = func;
|
|
|
|
pfwd->format_free_cb = free_func;
|
2017-10-26 19:48:10 -07:00
|
|
|
sd->is_legacy_format_cb = EINA_TRUE;
|
2017-05-18 01:52:17 -07:00
|
|
|
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl_ui_format_func_set(obj, pfwd, _format_legacy_to_format_eo_cb,
|
|
|
|
_format_legacy_to_format_eo_free_cb);
|
2017-10-26 05:28:20 -07:00
|
|
|
}
|
2017-05-23 22:12:34 -07:00
|
|
|
|
|
|
|
EAPI void
|
2017-10-26 05:28:20 -07:00
|
|
|
elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size)
|
2017-05-23 22:12:34 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
_progressbar_span_size_set(obj, sd, size);
|
2017-05-23 22:12:34 -07:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI Evas_Coord
|
|
|
|
elm_progressbar_span_size_get(const Evas_Object *obj)
|
2017-05-23 22:12:34 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, 0);
|
|
|
|
return sd->size;
|
2017-05-23 22:12:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2017-10-26 05:28:20 -07:00
|
|
|
elm_progressbar_unit_format_set(Evas_Object *obj, const char *units)
|
2017-05-23 22:12:34 -07:00
|
|
|
{
|
2017-10-26 19:48:10 -07:00
|
|
|
EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
|
2017-10-26 05:28:20 -07:00
|
|
|
|
2017-10-26 19:48:10 -07:00
|
|
|
sd->is_legacy_format_string = EINA_TRUE;
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl_ui_format_string_set(obj, units, EFL_UI_FORMAT_STRING_TYPE_SIMPLE);
|
2017-05-23 22:12:34 -07:00
|
|
|
}
|
|
|
|
|
2017-10-26 05:28:20 -07:00
|
|
|
EAPI const char *
|
|
|
|
elm_progressbar_unit_format_get(const Evas_Object *obj)
|
2017-05-23 22:12:34 -07:00
|
|
|
{
|
2019-07-11 03:33:55 -07:00
|
|
|
const char *fmt = NULL;
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl_ui_format_string_get(obj, &fmt, NULL);
|
|
|
|
return fmt;
|
2017-05-24 01:02:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2017-10-26 05:28:20 -07:00
|
|
|
elm_progressbar_value_set(Evas_Object *obj, double val)
|
2017-05-24 01:02:37 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
efl_ui_range_value_set(obj, val);
|
2017-05-24 01:02:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI double
|
2017-10-26 05:28:20 -07:00
|
|
|
elm_progressbar_value_get(const Evas_Object *obj)
|
2017-05-24 01:02:37 -07:00
|
|
|
{
|
2017-10-26 05:28:20 -07:00
|
|
|
return efl_ui_range_value_get(obj);
|
2017-05-24 01:02:37 -07:00
|
|
|
}
|
2018-01-23 22:50:58 -08:00
|
|
|
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "efl_ui_progressbar_legacy_eo.c"
|