Interface: Progress - Add common interface for Slider and Progressbar

Summary:
Implement common interface efl_ui_progress and inherit slider and progressbar from common interface.
Currently legacy APIs will also call interface functions and later it can be deprecated.
This interface will be moved to EFL in src/lib/efl/interfaces when elementary is merged into efl.

Test Plan:
elementary_test -to 'slider'
elementary_test -to 'progressbar'

Reviewers: singh.amitesh, raster, tasn, felipealmeida, woohyun, cedric, jpeg

Subscribers: saurabhbunty, alok25

Differential Revision: https://phab.enlightenment.org/D3759
This commit is contained in:
Yeshwanth Reddivari 2016-04-07 16:50:03 +09:00 committed by Jean-Philippe Andre
parent d03b45f030
commit 7f9036dce5
12 changed files with 789 additions and 422 deletions

View File

@ -30,6 +30,7 @@ efl_eolian_files = \
lib/efl/interfaces/efl_vpath_file.eo \ lib/efl/interfaces/efl_vpath_file.eo \
lib/efl/interfaces/efl_vpath_core.eo \ lib/efl/interfaces/efl_vpath_core.eo \
lib/efl/interfaces/efl_vpath_file_core.eo \ lib/efl/interfaces/efl_vpath_file_core.eo \
lib/efl/interfaces/efl_ui_progress.eo \
$(efl_eolian_legacy_files) \ $(efl_eolian_legacy_files) \
$(NULL) $(NULL)

View File

@ -71,6 +71,7 @@ typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;
#include "interfaces/efl_text_properties.eo.h" #include "interfaces/efl_text_properties.eo.h"
#include "interfaces/efl_orientation.eo.h" #include "interfaces/efl_orientation.eo.h"
#include "interfaces/efl_flip.eo.h" #include "interfaces/efl_flip.eo.h"
#include "interfaces/efl_ui_progress.eo.h"
/* Core interface */ /* Core interface */
#include "interfaces/efl_animator.eo.h" #include "interfaces/efl_animator.eo.h"

View File

@ -37,6 +37,7 @@ EAPI const Eo_Event_Description _EFL_GFX_PATH_CHANGED =
#include "interfaces/efl_animator.eo.c" #include "interfaces/efl_animator.eo.c"
#include "interfaces/efl_orientation.eo.c" #include "interfaces/efl_orientation.eo.c"
#include "interfaces/efl_flip.eo.c" #include "interfaces/efl_flip.eo.c"
#include "interfaces/efl_ui_progress.eo.c"
EAPI void EAPI void
__efl_internal_init(void) __efl_internal_init(void)

View File

@ -0,0 +1,63 @@
interface Efl.Ui.Progress {
legacy_prefix: null;
methods {
@property span_size {
[[Control the (exact) length of the bar region of a given progress widget
This sets the minimum width (when in horizontal mode) or height
(when in vertical mode) of the actual bar area of the progress
bar $obj. This in turn affects the object's minimum size. Use
this when you're not setting other size hints expanding on the
given direction (like weight and alignment hints) and you would
like it to have a specific size.
Note: Icon, label and unit text around $obj will require their
own space, which will make $obj to require more the $size,
actually.]]
set {
}
get {
}
values {
size: int; [[The length of the progress's bar region]]
}
}
@property value {
[[Control the progress value (in percentage) on a given progress widget
Use this call to set progress levels.
Note: If you passes a value out of the specified range for
$val, it will be interpreted as the closest of the boundary
values in the range.]]
set {
}
get {
}
values {
val: double; [[The progress value (must be between $0.0 and 1.0)]]
}
}
@property unit_format {
[[Control the format string for a given progress widget's units label
If $NULL is passed on $format, it will make $obj's units
area to be hidden completely. If not, it'll set the <b>format
string</b> for the units label's text. The units label is
provided a floating point value, so the units text is up display
at most one floating point value. Note that the units label is
optional. Use a format string such as "%1.2f meters" for
example.
Note: The default format string for a progress is an integer
percentage, as in $"%.0f %%".]]
set {
}
get {
}
values {
units: const(char)* @nullable; [[The format string for $obj's units label]]
}
}
}
}

View File

@ -59,6 +59,27 @@ _progress_status_free(Elm_Progress_Status *ps)
eina_stringshare_del(ps->part_name); eina_stringshare_del(ps->part_name);
free(ps); free(ps);
} }
static inline Eina_Bool
_is_horizontal(Efl_Orient orientation)
{
if (orientation == EFL_ORIENT_LEFT ||
orientation == EFL_ORIENT_RIGHT)
return EINA_TRUE;
return EINA_FALSE;
}
static inline Eina_Bool
_is_inverted(Efl_Orient orientation)
{
if (orientation == EFL_ORIENT_LEFT ||
orientation == EFL_ORIENT_UP)
return EINA_TRUE;
return EINA_FALSE;
}
static void static void
_units_set(Evas_Object *obj) _units_set(Evas_Object *obj)
{ {
@ -98,9 +119,9 @@ _val_set(Evas_Object *obj)
EINA_LIST_FOREACH(sd->progress_status, l, ps) EINA_LIST_FOREACH(sd->progress_status, l, ps)
{ {
pos = ps->val; pos = ps->val;
if ((!rtl && sd->inverted) || if ((!rtl && _is_inverted(sd->orientation)) ||
(rtl && ((!sd->horizontal && sd->inverted) || (rtl && ((sd->orientation == EFL_ORIENT_UP) ||
(sd->horizontal && !sd->inverted)))) (sd->orientation == EFL_ORIENT_RIGHT))))
pos = MAX_RATIO_LVL - pos; pos = MAX_RATIO_LVL - pos;
edje_object_part_drag_value_set edje_object_part_drag_value_set
@ -171,7 +192,7 @@ _elm_progressbar_elm_widget_theme_apply(Eo *obj, Elm_Progressbar_Data *sd)
ELM_LAYOUT_DATA_GET(obj, ld); ELM_LAYOUT_DATA_GET(obj, ld);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
if (sd->horizontal) if (_is_horizontal(sd->orientation))
eina_stringshare_replace(&ld->group, "horizontal"); eina_stringshare_replace(&ld->group, "horizontal");
else eina_stringshare_replace(&ld->group, "vertical"); else eina_stringshare_replace(&ld->group, "vertical");
@ -189,7 +210,7 @@ _elm_progressbar_elm_widget_theme_apply(Eo *obj, Elm_Progressbar_Data *sd)
if ((sd->units) && (!sd->pulse)) if ((sd->units) && (!sd->pulse))
elm_layout_signal_emit(obj, "elm,state,units,visible", "elm"); elm_layout_signal_emit(obj, "elm,state,units,visible", "elm");
if (sd->horizontal) if (_is_horizontal(sd->orientation))
evas_object_size_hint_min_set evas_object_size_hint_min_set
(sd->spacer, (double)sd->size * elm_widget_scale_get(obj) * (sd->spacer, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get(), 1); elm_config_scale_get(), 1);
@ -198,8 +219,10 @@ _elm_progressbar_elm_widget_theme_apply(Eo *obj, Elm_Progressbar_Data *sd)
(sd->spacer, 1, (double)sd->size * elm_widget_scale_get(obj) * (sd->spacer, 1, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get()); elm_config_scale_get());
if (sd->inverted) if (_is_inverted(sd->orientation))
elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm"); elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
else
elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm");
_units_set(obj); _units_set(obj);
_val_set(obj); _val_set(obj);
@ -259,7 +282,7 @@ _elm_progressbar_evas_object_smart_add(Eo *obj, Elm_Progressbar_Data *priv)
evas_obj_smart_add(eo_super(obj, MY_CLASS)); evas_obj_smart_add(eo_super(obj, MY_CLASS));
elm_widget_sub_object_parent_add(obj); elm_widget_sub_object_parent_add(obj);
priv->horizontal = EINA_TRUE; priv->orientation = EFL_ORIENT_RIGHT;
priv->units = eina_stringshare_add("%.0f %%"); priv->units = eina_stringshare_add("%.0f %%");
priv->val = MIN_RATIO_LVL; priv->val = MIN_RATIO_LVL;
@ -356,6 +379,86 @@ _elm_progressbar_pulse_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd)
return sd->pulse; return sd->pulse;
} }
EOLIAN static void
_elm_progressbar_efl_orientation_orientation_set(Eo *obj, Elm_Progressbar_Data *sd, Efl_Orient dir)
{
sd->orientation = dir;
elm_obj_widget_theme_apply(obj);
}
EOLIAN static Efl_Orient
_elm_progressbar_efl_orientation_orientation_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd)
{
return sd->orientation;
}
EOLIAN static void
_elm_progressbar_efl_ui_progress_span_size_set(Eo *obj, Elm_Progressbar_Data *sd, Evas_Coord size)
{
if (sd->size == size) return;
sd->size = size;
if (_is_horizontal(sd->orientation))
evas_object_size_hint_min_set
(sd->spacer, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get(), 1);
else
evas_object_size_hint_min_set
(sd->spacer, 1, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get());
elm_layout_sizing_eval(obj);
}
EOLIAN static Evas_Coord
_elm_progressbar_efl_ui_progress_span_size_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd)
{
return sd->size;
}
EOLIAN static void
_elm_progressbar_efl_ui_progress_value_set(Eo *obj, Elm_Progressbar_Data *sd, double val)
{
if (sd->val == val) return;
elm_progressbar_part_value_set(obj, "elm.cur.progressbar", val);
}
EOLIAN static double
_elm_progressbar_efl_ui_progress_value_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd)
{
return sd->val;
}
EOLIAN static void
_elm_progressbar_efl_ui_progress_unit_format_set(Eo *obj, Elm_Progressbar_Data *sd, const char *units)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
eina_stringshare_replace(&sd->units, units);
if (units)
{
elm_layout_signal_emit(obj, "elm,state,units,visible", "elm");
edje_object_message_signal_process(wd->resize_obj);
}
else
{
elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm");
edje_object_message_signal_process(wd->resize_obj);
}
_units_set(obj);
elm_layout_sizing_eval(obj);
}
EOLIAN static const char *
_elm_progressbar_efl_ui_progress_unit_format_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd)
{
return sd->units;
}
EOLIAN static void EOLIAN static void
_elm_progressbar_pulse(Eo *obj, Elm_Progressbar_Data *sd, Eina_Bool state) _elm_progressbar_pulse(Eo *obj, Elm_Progressbar_Data *sd, Eina_Bool state)
{ {
@ -420,75 +523,47 @@ _elm_progressbar_part_value_get(const Eo *obj EINA_UNUSED, Elm_Progressbar_Data
return 0.0; return 0.0;
} }
EOLIAN static void EAPI void
_elm_progressbar_value_set(Eo *obj, Elm_Progressbar_Data *sd, double val) elm_progressbar_value_set(Elm_Progressbar *obj, double val)
{ {
if (sd->val == val) return; efl_ui_progress_value_set(obj, val);
elm_progressbar_part_value_set(obj, "elm.cur.progressbar", val);
} }
EOLIAN static double EAPI double
_elm_progressbar_value_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd) elm_progressbar_value_get(const Elm_Progressbar *obj)
{ {
return sd->val; return efl_ui_progress_value_get(obj);
} }
EOLIAN static void EAPI void
_elm_progressbar_span_size_set(Eo *obj, Elm_Progressbar_Data *sd, Evas_Coord size) elm_progressbar_span_size_set(Elm_Progressbar *obj, Evas_Coord size)
{ {
if (sd->size == size) return; efl_ui_progress_span_size_set(obj, size);
sd->size = size;
if (sd->horizontal)
evas_object_size_hint_min_set
(sd->spacer, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get(), 1);
else
evas_object_size_hint_min_set
(sd->spacer, 1, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get());
elm_layout_sizing_eval(obj);
} }
EOLIAN static Evas_Coord EAPI Evas_Coord
_elm_progressbar_span_size_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd) elm_progressbar_span_size_get(const Elm_Progressbar *obj)
{ {
return sd->size; return efl_ui_progress_span_size_get(obj);
} }
EOLIAN static void EAPI void
_elm_progressbar_unit_format_set(Eo *obj, Elm_Progressbar_Data *sd, const char *units) elm_progressbar_unit_format_set(Elm_Progressbar *obj, const char *units)
{ {
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); efl_ui_progress_unit_format_set(obj, units);
eina_stringshare_replace(&sd->units, units);
if (units)
{
elm_layout_signal_emit(obj, "elm,state,units,visible", "elm");
edje_object_message_signal_process(wd->resize_obj);
}
else
{
elm_layout_signal_emit(obj, "elm,state,units,hidden", "elm");
edje_object_message_signal_process(wd->resize_obj);
}
_units_set(obj);
elm_layout_sizing_eval(obj);
} }
EOLIAN static const char* EAPI const char *
_elm_progressbar_unit_format_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd) elm_progressbar_unit_format_get(const Elm_Progressbar *obj)
{ {
return sd->units; return efl_ui_progress_unit_format_get(obj);
} }
EOLIAN static void EAPI void
_elm_progressbar_unit_format_function_set(Eo *obj, Elm_Progressbar_Data *sd, progressbar_func_type func, progressbar_freefunc_type free_func) elm_progressbar_unit_format_function_set(Elm_Progressbar *obj, progressbar_func_type func, progressbar_freefunc_type free_func)
{ {
ELM_PROGRESSBAR_DATA_GET(obj, sd);
sd->unit_format_func = func; sd->unit_format_func = func;
sd->unit_format_free = free_func; sd->unit_format_free = free_func;
@ -496,46 +571,63 @@ _elm_progressbar_unit_format_function_set(Eo *obj, Elm_Progressbar_Data *sd, pro
elm_layout_sizing_eval(obj); elm_layout_sizing_eval(obj);
} }
EOLIAN static void static Efl_Orient
_elm_progressbar_horizontal_set(Eo *obj, Elm_Progressbar_Data *sd, Eina_Bool horizontal) _orientation_get(Eina_Bool horizontal, Eina_Bool inverted)
{ {
horizontal = !!horizontal; if (horizontal)
if (sd->horizontal == horizontal) return; {
if (inverted)
sd->horizontal = horizontal; return EFL_ORIENT_LEFT;
elm_obj_widget_theme_apply(obj); else
} return EFL_ORIENT_RIGHT;
}
EOLIAN static Eina_Bool
_elm_progressbar_horizontal_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd)
{
return sd->horizontal;
}
EOLIAN static void
_elm_progressbar_inverted_set(Eo *obj, Elm_Progressbar_Data *sd, Eina_Bool inverted)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
inverted = !!inverted;
if (sd->inverted == inverted) return;
sd->inverted = inverted;
if (sd->inverted)
elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
else else
elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm"); {
if (inverted)
edje_object_message_signal_process(wd->resize_obj); return EFL_ORIENT_UP;
else
_val_set(obj); return EFL_ORIENT_DOWN;
_units_set(obj); }
} }
EOLIAN static Eina_Bool EAPI void
_elm_progressbar_inverted_get(Eo *obj EINA_UNUSED, Elm_Progressbar_Data *sd) elm_progressbar_horizontal_set(Elm_Progressbar *obj, Eina_Bool horizontal)
{ {
return sd->inverted; Efl_Orient dir;
ELM_PROGRESSBAR_DATA_GET(obj, sd);
dir = _orientation_get(horizontal, _is_inverted(sd->orientation));
efl_orientation_set(obj, dir);
}
EAPI Eina_Bool
elm_progressbar_horizontal_get(const Elm_Progressbar *obj)
{
Efl_Orient dir;
dir = efl_orientation_get(obj);
return _is_horizontal(dir);
}
EAPI void
elm_progressbar_inverted_set(Elm_Progressbar *obj, Eina_Bool inverted)
{
Efl_Orient dir;
ELM_PROGRESSBAR_DATA_GET(obj, sd);
dir = _orientation_get(_is_horizontal(sd->orientation), inverted);
efl_orientation_set(obj, dir);
}
EAPI Eina_Bool
elm_progressbar_inverted_get(const Elm_Progressbar *obj)
{
Efl_Orient dir;
dir = efl_orientation_get(obj);
return _is_inverted(dir);
} }
EOLIAN static Eina_Bool EOLIAN static Eina_Bool

View File

@ -1,28 +1,8 @@
class Elm.Progressbar (Elm.Layout) class Elm.Progressbar (Elm.Layout, Efl.Ui.Progress,
Efl.Orientation)
{ {
eo_prefix: elm_obj_progressbar; eo_prefix: elm_obj_progressbar;
methods { methods {
@property span_size {
[[Control the (exact) length of the bar region of a given progress bar widget
This sets the minimum width (when in horizontal mode) or height
(when in vertical mode) of the actual bar area of the progress
bar $obj. This in turn affects the object's minimum size. Use
this when you're not setting other size hints expanding on the
given direction (like weight and alignment hints) and you would
like it to have a specific size.
Note: Icon, label and unit text around $obj will require their
own space, which will make $obj to require more the $size,
actually.]]
set {
}
get {
}
values {
size: Evas.Coord; [[The length of the progress bar's bar region]]
}
}
@property pulse { @property pulse {
[[Control whether a given progress bar widget is at "pulsing mode" or not. [[Control whether a given progress bar widget is at "pulsing mode" or not.
@ -43,87 +23,6 @@ class Elm.Progressbar (Elm.Layout)
pulse: bool; [[$true to put $obj in pulsing mode, $false to put it back to its default one]] pulse: bool; [[$true to put $obj in pulsing mode, $false to put it back to its default one]]
} }
} }
@property value {
[[Control the progress value (in percentage) on a given progress bar widget
Use this call to set progress bar levels.
Note: If you passes a value out of the specified range for
$val, it will be interpreted as the closest of the boundary
values in the range.]]
set {
}
get {
}
values {
val: double; [[The progress value (must be between $0.0 and 1.0)]]
}
}
@property inverted {
[[Invert a given progress bar widget's displaying values order
A progress bar may be inverted, in which state it gets its
values inverted, with high values being on the left or top and
low values on the right or bottom, as opposed to normally have
the low values on the former and high values on the latter,
respectively, for horizontal and vertical modes.]]
set {
}
get {
}
values {
inverted: bool; [[Use $true to make $obj inverted, $false to bring it back to default, non-inverted values.]]
}
}
@property horizontal {
[[Control the orientation of a given progress bar widget
Use this function to change how your progress bar is to be
disposed: vertically or horizontally.]]
set {
}
get {
}
values {
horizontal: bool; [[Use $true to make $obj to be horizontal, $false to make it vertical]]
}
}
@property unit_format {
[[Control the format string for a given progress bar widget's units label
If $NULL is passed on $format, it will make $obj's units
area to be hidden completely. If not, it'll set the <b>format
string</b> for the units label's text. The units label is
provided a floating point value, so the units text is up display
at most one floating point value. Note that the units label is
optional. Use a format string such as "%1.2f meters" for
example.
Note: The default format string for a progress bar is an integer
percentage, as in $"%.0f %%".]]
set {
}
get {
}
values {
units: const(char)* @nullable; [[The format string for $obj's units label]]
}
}
@property unit_format_function {
set {
[[Set the format function pointer for the units label
Set the callback function to format the unit string.
See: @.unit_format.set for more info on how this works.
@since 1.7]]
}
values {
func: progressbar_func_type @nullable; [[The unit format function]]
free_func: progressbar_freefunc_type @optional; [[The freeing function for the format string.]]
}
}
part_value_set { part_value_set {
[[Set the progress value (in percentage) on a given progress bar widget for the given part name [[Set the progress value (in percentage) on a given progress bar widget for the given part name
@ -166,6 +65,10 @@ class Elm.Progressbar (Elm.Layout)
Elm.Layout.text_aliases.get; Elm.Layout.text_aliases.get;
Elm.Layout.content_aliases.get; Elm.Layout.content_aliases.get;
Elm.Layout.sizing_eval; Elm.Layout.sizing_eval;
Efl.Ui.Progress.span_size;
Efl.Ui.Progress.value;
Efl.Ui.Progress.unit_format;
Efl.Orientation.orientation;
} }
events { events {
changed; changed;

View File

@ -11,4 +11,184 @@
*/ */
EAPI Evas_Object *elm_progressbar_add(Evas_Object *parent); EAPI Evas_Object *elm_progressbar_add(Evas_Object *parent);
/**
* @brief Control the (exact) length of the bar region of a given progress bar
* widget
*
* This sets the minimum width (when in horizontal mode) or height (when in
* vertical mode) of the actual bar area of the progress bar @c obj. This in
* turn affects the object's minimum size. Use this when you're not setting
* other size hints expanding on the given direction (like weight and alignment
* hints) and you would like it to have a specific size.
*
* @note Icon, label and unit text around @c obj will require their own space,
* which will make @c obj to require more the @c size, actually.
*
* @param[in] size The length of the progress bar's bar region
*
* @ingroup Elm_Progressbar
*/
EAPI void elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size);
/**
* @brief Control the (exact) length of the bar region of a given progress bar
* widget
*
* This sets the minimum width (when in horizontal mode) or height (when in
* vertical mode) of the actual bar area of the progress bar @c obj. This in
* turn affects the object's minimum size. Use this when you're not setting
* other size hints expanding on the given direction (like weight and alignment
* hints) and you would like it to have a specific size.
*
* @note Icon, label and unit text around @c obj will require their own space,
* which will make @c obj to require more the @c size, actually.
*
* @return The length of the progress bar's bar region
*
* @ingroup Elm_Progressbar
*/
EAPI Evas_Coord elm_progressbar_span_size_get(const Evas_Object *obj);
/**
* @brief Control the progress value (in percentage) on a given progress bar
* widget
*
* Use this call to set progress bar levels.
*
* @note If you passes a value out of the specified range for @c val, it will
* be interpreted as the closest of the boundary values in the range.
*
* @param[in] val The progress value (must be between $0.0 and 1.0)
*
* @ingroup Elm_Progressbar
*/
EAPI void elm_progressbar_value_set(Evas_Object *obj, double val);
/**
* @brief Control the progress value (in percentage) on a given progress bar
* widget
*
* Use this call to set progress bar levels.
*
* @note If you passes a value out of the specified range for @c val, it will
* be interpreted as the closest of the boundary values in the range.
*
* @return The progress value (must be between $0.0 and 1.0)
*
* @ingroup Elm_Progressbar
*/
EAPI double elm_progressbar_value_get(const Evas_Object *obj);
/**
* @brief Invert a given progress bar widget's displaying values order
*
* A progress bar may be inverted, in which state it gets its values inverted,
* with high values being on the left or top and low values on the right or
* bottom, as opposed to normally have the low values on the former and high
* values on the latter, respectively, for horizontal and vertical modes.
*
* @param[in] inverted Use @c true to make @c obj inverted, @c false to bring
* it back to default, non-inverted values.
*
* @ingroup Elm_Progressbar
*/
EAPI void elm_progressbar_inverted_set(Evas_Object *obj, Eina_Bool inverted);
/**
* @brief Invert a given progress bar widget's displaying values order
*
* A progress bar may be inverted, in which state it gets its values inverted,
* with high values being on the left or top and low values on the right or
* bottom, as opposed to normally have the low values on the former and high
* values on the latter, respectively, for horizontal and vertical modes.
*
* @return Use @c true to make @c obj inverted, @c false to bring it back to
* default, non-inverted values.
*
* @ingroup Elm_Progressbar
*/
EAPI Eina_Bool elm_progressbar_inverted_get(const Evas_Object *obj);
/**
* @brief Control the orientation of a given progress bar widget
*
* Use this function to change how your progress bar is to be disposed:
* vertically or horizontally.
*
* @param[in] horizontal Use @c true to make @c obj to be horizontal, @c false
* to make it vertical
*
* @ingroup Elm_Progressbar
*/
EAPI void elm_progressbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal);
/**
* @brief Control the orientation of a given progress bar widget
*
* Use this function to change how your progress bar is to be disposed:
* vertically or horizontally.
*
* @return Use @c true to make @c obj to be horizontal, @c false to make it
* vertical
*
* @ingroup Elm_Progressbar
*/
EAPI Eina_Bool elm_progressbar_horizontal_get(const Evas_Object *obj);
/**
* @brief Control the format string for a given progress bar widget's units
* label
*
* If @c NULL is passed on @c format, it will make @c obj's units area to be
* hidden completely. If not, it'll set the <b>format string</b> for the units
* label's text. The units label is provided a floating point value, so the
* units text is up display at most one floating point value. Note that the
* units label is optional. Use a format string such as "%1.2f meters" for
* example.
*
* @note The default format string for a progress bar is an integer percentage,
* as in $"%.0f %%".
*
* @param[in] units The format string for @c obj's units label
*
* @ingroup Elm_Progressbar
*/
EAPI void elm_progressbar_unit_format_set(Evas_Object *obj, const char *units);
/**
* @brief Control the format string for a given progress bar widget's units
* label
*
* If @c NULL is passed on @c format, it will make @c obj's units area to be
* hidden completely. If not, it'll set the <b>format string</b> for the units
* label's text. The units label is provided a floating point value, so the
* units text is up display at most one floating point value. Note that the
* units label is optional. Use a format string such as "%1.2f meters" for
* example.
*
* @note The default format string for a progress bar is an integer percentage,
* as in $"%.0f %%".
*
* @return The format string for @c obj's units label
*
* @ingroup Elm_Progressbar
*/
EAPI const char *elm_progressbar_unit_format_get(const Evas_Object *obj);
/**
* @brief Set the format function pointer for the units label
*
* Set the callback function to format the unit string.
*
* See: @ref elm_progressbar_unit_format_set for more info on how this works.
*
* @param[in] func The unit format function
* @param[in] free_func The freeing function for the format string.
*
* @since 1.7
*
* @ingroup Elm_Progressbar
*/
EAPI void elm_progressbar_unit_format_function_set(Evas_Object *obj, progressbar_func_type func, progressbar_freefunc_type free_func);
#include "elm_progressbar.eo.legacy.h" #include "elm_progressbar.eo.legacy.h"

View File

@ -71,6 +71,45 @@ _delay_change(void *data)
return ECORE_CALLBACK_CANCEL; return ECORE_CALLBACK_CANCEL;
} }
static inline Eina_Bool
_is_horizontal(Efl_Orient orientation)
{
if (orientation == EFL_ORIENT_LEFT ||
orientation == EFL_ORIENT_RIGHT)
return EINA_TRUE;
return EINA_FALSE;
}
static inline Eina_Bool
_is_inverted(Efl_Orient orientation)
{
if (orientation == EFL_ORIENT_LEFT ||
orientation == EFL_ORIENT_UP)
return EINA_TRUE;
return EINA_FALSE;
}
static Efl_Orient
_orientation_get(Eina_Bool horizontal, Eina_Bool inverted)
{
if (horizontal)
{
if (inverted)
return EFL_ORIENT_LEFT;
else
return EFL_ORIENT_RIGHT;
}
else
{
if (inverted)
return EFL_ORIENT_UP;
else
return EFL_ORIENT_DOWN;
}
}
static void static void
_val_fetch(Evas_Object *obj, Eina_Bool user_event) _val_fetch(Evas_Object *obj, Eina_Bool user_event)
{ {
@ -83,18 +122,18 @@ _val_fetch(Evas_Object *obj, Eina_Bool user_event)
edje_object_part_drag_value_get edje_object_part_drag_value_get
(wd->resize_obj, "elm.dragable.slider", &posx, &posy); (wd->resize_obj, "elm.dragable.slider", &posx, &posy);
if (sd->horizontal) pos = posx; if (_is_horizontal(sd->orientation)) pos = posx;
else pos = posy; else pos = posy;
edje_object_part_drag_value_get edje_object_part_drag_value_get
(wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2); (wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2);
if (sd->horizontal) pos2 = posx2; if (_is_horizontal(sd->orientation)) pos2 = posx2;
else pos2 = posy2; else pos2 = posy2;
rtl = elm_widget_mirrored_get(obj); rtl = elm_widget_mirrored_get(obj);
if ((!rtl && sd->inverted) || if ((!rtl && _is_inverted(sd->orientation)) ||
(rtl && ((!sd->horizontal && sd->inverted) || (rtl && ((sd->orientation == EFL_ORIENT_UP) ||
(sd->horizontal && !sd->inverted)))) (sd->orientation == EFL_ORIENT_RIGHT))))
{ {
pos = 1.0 - pos; pos = 1.0 - pos;
pos2 = 1.0 - pos2; pos2 = 1.0 - pos2;
@ -153,9 +192,9 @@ _val_set(Evas_Object *obj)
pos2 = 1.0; pos2 = 1.0;
rtl = elm_widget_mirrored_get(obj); rtl = elm_widget_mirrored_get(obj);
if ((!rtl && sd->inverted) || if ((!rtl && _is_inverted(sd->orientation)) ||
(rtl && ((!sd->horizontal && sd->inverted) || (rtl && ((sd->orientation == EFL_ORIENT_UP) ||
(sd->horizontal && !sd->inverted)))) (sd->orientation == EFL_ORIENT_RIGHT))))
{ {
pos = 1.0 - pos; pos = 1.0 - pos;
pos2 = 1.0 - pos2; pos2 = 1.0 - pos2;
@ -351,7 +390,7 @@ _drag_up(void *data,
ELM_SLIDER_DATA_GET(data, sd); ELM_SLIDER_DATA_GET(data, sd);
step = sd->step; step = sd->step;
if (sd->inverted) step *= -1.0; if (_is_inverted(sd->orientation)) step *= -1.0;
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
edje_object_part_drag_step edje_object_part_drag_step
@ -369,7 +408,7 @@ _drag_down(void *data,
ELM_SLIDER_DATA_GET(data, sd); ELM_SLIDER_DATA_GET(data, sd);
step = -sd->step; step = -sd->step;
if (sd->inverted) step *= -1.0; if (_is_inverted(sd->orientation)) step *= -1.0;
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd); ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
edje_object_part_drag_step edje_object_part_drag_step
@ -479,26 +518,34 @@ _key_action_drag(Evas_Object *obj, const char *params)
if (!strcmp(dir, "left")) if (!strcmp(dir, "left"))
{ {
if (!sd->horizontal) return EINA_FALSE; if (!_is_horizontal(sd->orientation))
if (!sd->inverted) _drag_down(obj, NULL, NULL, NULL); return EINA_FALSE;
if (!_is_inverted(sd->orientation))
_drag_down(obj, NULL, NULL, NULL);
else _drag_up(obj, NULL, NULL, NULL); else _drag_up(obj, NULL, NULL, NULL);
} }
else if (!strcmp(dir, "right")) else if (!strcmp(dir, "right"))
{ {
if (!sd->horizontal) return EINA_FALSE; if (!_is_horizontal(sd->orientation))
if (!sd->inverted) _drag_up(obj, NULL, NULL, NULL); return EINA_FALSE;
if (!_is_inverted(sd->orientation))
_drag_up(obj, NULL, NULL, NULL);
else _drag_down(obj, NULL, NULL, NULL); else _drag_down(obj, NULL, NULL, NULL);
} }
else if (!strcmp(dir, "up")) else if (!strcmp(dir, "up"))
{ {
if (sd->horizontal) return EINA_FALSE; if (_is_horizontal(sd->orientation))
if (sd->inverted) _drag_up(obj, NULL, NULL, NULL); return EINA_FALSE;
if (_is_inverted(sd->orientation))
_drag_up(obj, NULL, NULL, NULL);
else _drag_down(obj, NULL, NULL, NULL); else _drag_down(obj, NULL, NULL, NULL);
} }
else if (!strcmp(dir, "down")) else if (!strcmp(dir, "down"))
{ {
if (sd->horizontal) return EINA_FALSE; if (_is_horizontal(sd->orientation))
if (sd->inverted) _drag_down(obj, NULL, NULL, NULL); return EINA_FALSE;
if (_is_inverted(sd->orientation))
_drag_down(obj, NULL, NULL, NULL);
else _drag_up(obj, NULL, NULL, NULL); else _drag_up(obj, NULL, NULL, NULL);
} }
else return EINA_FALSE; else return EINA_FALSE;
@ -567,13 +614,15 @@ _elm_slider_elm_widget_activate(Eo *obj, Elm_Slider_Data *sd, Elm_Activate act)
if ((act == ELM_ACTIVATE_UP) || if ((act == ELM_ACTIVATE_UP) ||
(act == ELM_ACTIVATE_RIGHT)) (act == ELM_ACTIVATE_RIGHT))
{ {
if (!sd->inverted) _drag_up(obj, NULL, NULL, NULL); if (!_is_inverted(sd->orientation))
_drag_up(obj, NULL, NULL, NULL);
else _drag_down(obj, NULL, NULL, NULL); else _drag_down(obj, NULL, NULL, NULL);
} }
else if ((act == ELM_ACTIVATE_DOWN) || else if ((act == ELM_ACTIVATE_DOWN) ||
(act == ELM_ACTIVATE_LEFT)) (act == ELM_ACTIVATE_LEFT))
{ {
if (!sd->inverted) _drag_down(obj, NULL, NULL, NULL); if (!_is_inverted(sd->orientation))
_drag_down(obj, NULL, NULL, NULL);
else _drag_up(obj, NULL, NULL, NULL); else _drag_up(obj, NULL, NULL, NULL);
} }
@ -656,7 +705,7 @@ _popup_add(Elm_Slider_Data *sd, Eo *obj, Evas_Object **popup,
// XXX popup needs to adapt to theme etc. // XXX popup needs to adapt to theme etc.
*popup = edje_object_add(evas_object_evas_get(obj)); *popup = edje_object_add(evas_object_evas_get(obj));
evas_object_smart_member_add(*popup, obj); evas_object_smart_member_add(*popup, obj);
if (sd->horizontal) if (_is_horizontal(sd->orientation))
_elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "horizontal/popup", elm_widget_style_get(obj)); _elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "horizontal/popup", elm_widget_style_get(obj));
else else
_elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "vertical/popup", elm_widget_style_get(obj)); _elm_theme_set(elm_widget_theme_get(obj), *popup, "slider", "vertical/popup", elm_widget_style_get(obj));
@ -696,7 +745,7 @@ _elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
ELM_LAYOUT_DATA_GET(obj, ld); ELM_LAYOUT_DATA_GET(obj, ld);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
if (sd->horizontal) if (_is_horizontal(sd->orientation))
{ {
eina_stringshare_replace(&ld->group, "horizontal"); eina_stringshare_replace(&ld->group, "horizontal");
if (sd->popup) if (sd->popup)
@ -741,7 +790,7 @@ _elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
_popup_add(sd, obj, &sd->popup2, &sd->track2, EINA_TRUE); _popup_add(sd, obj, &sd->popup2, &sd->track2, EINA_TRUE);
} }
if (sd->horizontal) if (_is_horizontal(sd->orientation))
evas_object_size_hint_min_set evas_object_size_hint_min_set
(sd->spacer, (double)sd->size * elm_widget_scale_get(obj) * (sd->spacer, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get(), 1); elm_config_scale_get(), 1);
@ -755,7 +804,7 @@ _elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
else else
elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm"); elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm");
if (sd->inverted) if (_is_inverted(sd->orientation))
{ {
elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm"); elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
if (sd->popup) if (sd->popup)
@ -763,6 +812,13 @@ _elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
if (sd->popup2) if (sd->popup2)
edje_object_signal_emit(sd->popup2, "elm,state,inverted,on", "elm"); edje_object_signal_emit(sd->popup2, "elm,state,inverted,on", "elm");
} }
else
{
elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm");
if (sd->popup)
edje_object_signal_emit(sd->popup, "elm,state,inverted,off", "elm");
}
if (sd->indicator_show) if (sd->indicator_show)
{ {
elm_layout_signal_emit(obj, "elm,state,val,show", "elm"); elm_layout_signal_emit(obj, "elm,state,val,show", "elm");
@ -822,7 +878,7 @@ _move_knob_on_mouse(Evas_Object *obj, double button_x, double button_y)
edje_object_part_drag_value_get edje_object_part_drag_value_get
(wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2); (wd->resize_obj, "elm.dragable2.slider", &posx2, &posy2);
if (sd->horizontal) if (_is_horizontal(sd->orientation))
{ {
diff1 = fabs(button_x - posx); diff1 = fabs(button_x - posx);
diff2 = fabs(button_x - posx2); diff2 = fabs(button_x - posx2);
@ -866,7 +922,7 @@ _spacer_down_cb(void *data,
evas_object_geometry_get(sd->spacer, &x, &y, &w, &h); evas_object_geometry_get(sd->spacer, &x, &y, &w, &h);
sd->downx = ev->canvas.x - x; sd->downx = ev->canvas.x - x;
sd->downy = ev->canvas.y - y; sd->downy = ev->canvas.y - y;
if (sd->horizontal) if (_is_horizontal(sd->orientation))
{ {
button_x = ((double)ev->canvas.x - (double)x) / (double)w; button_x = ((double)ev->canvas.x - (double)x) / (double)w;
if (button_x > 1) button_x = 1; if (button_x > 1) button_x = 1;
@ -905,7 +961,8 @@ _spacer_move_cb(void *data,
Evas_Coord d = 0; Evas_Coord d = 0;
evas_object_geometry_get(sd->spacer, &x, &y, &w, &h); evas_object_geometry_get(sd->spacer, &x, &y, &w, &h);
if (sd->horizontal) d = abs(ev->cur.canvas.x - x - sd->downx); if (_is_horizontal(sd->orientation))
d = abs(ev->cur.canvas.x - x - sd->downx);
else d = abs(ev->cur.canvas.y - y - sd->downy); else d = abs(ev->cur.canvas.y - y - sd->downy);
if (d > (_elm_config->thumbscroll_threshold - 1)) if (d > (_elm_config->thumbscroll_threshold - 1))
{ {
@ -932,7 +989,7 @@ _spacer_move_cb(void *data,
elm_slider_value_set(data, sd->val2); elm_slider_value_set(data, sd->val2);
return; return;
} }
if (sd->horizontal) if (_is_horizontal(sd->orientation))
{ {
button_x = ((double)ev->cur.canvas.x - (double)x) / (double)w; button_x = ((double)ev->cur.canvas.x - (double)x) / (double)w;
if (button_x > 1) button_x = 1; if (button_x > 1) button_x = 1;
@ -1011,7 +1068,7 @@ _elm_slider_evas_object_smart_calculate(Eo *obj, Elm_Slider_Data *sd)
{ {
elm_layout_freeze(obj); elm_layout_freeze(obj);
if (sd->horizontal) if (_is_horizontal(sd->orientation))
evas_object_size_hint_min_set evas_object_size_hint_min_set
(sd->spacer, (double)sd->size * elm_widget_scale_get(obj) * (sd->spacer, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get(), 1); elm_config_scale_get(), 1);
@ -1079,7 +1136,7 @@ _elm_slider_evas_object_smart_add(Eo *obj, Elm_Slider_Data *priv)
evas_obj_smart_add(eo_super(obj, MY_CLASS)); evas_obj_smart_add(eo_super(obj, MY_CLASS));
elm_widget_sub_object_parent_add(obj); elm_widget_sub_object_parent_add(obj);
priv->horizontal = EINA_TRUE; priv->orientation = EFL_ORIENT_RIGHT;
priv->indicator_show = EINA_TRUE; priv->indicator_show = EINA_TRUE;
priv->indicator_visible_mode = elm_config_slider_indicator_visible_mode_get(); priv->indicator_visible_mode = elm_config_slider_indicator_visible_mode_get();
priv->val_max = 1.0; priv->val_max = 1.0;
@ -1227,8 +1284,109 @@ _elm_slider_eo_base_constructor(Eo *obj, Elm_Slider_Data *_pd EINA_UNUSED)
return obj; return obj;
} }
EAPI void
elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size)
{
efl_ui_progress_span_size_set(obj, size);
}
EAPI Evas_Coord
elm_slider_span_size_get(const Evas_Object *obj)
{
return efl_ui_progress_span_size_get(obj);
}
EAPI void
elm_slider_unit_format_set(Evas_Object *obj, const char *units)
{
efl_ui_progress_unit_format_set(obj, units);
}
EAPI const char *
elm_slider_unit_format_get(const Evas_Object *obj)
{
return efl_ui_progress_unit_format_get(obj);
}
EAPI void
elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
{
Efl_Orient dir;
ELM_SLIDER_DATA_GET(obj, sd);
dir = _orientation_get(horizontal, _is_inverted(sd->orientation));
efl_orientation_set(obj, dir);
}
EAPI Eina_Bool
elm_slider_horizontal_get(const Evas_Object *obj)
{
Efl_Orient dir;
dir = efl_orientation_get(obj);
return _is_horizontal(dir);
}
EAPI void
elm_slider_value_set(Evas_Object *obj, double val)
{
efl_ui_progress_value_set(obj, val);
}
EAPI double
elm_slider_value_get(const Evas_Object *obj)
{
return efl_ui_progress_value_get(obj);
}
EAPI void
elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted)
{
Efl_Orient dir;
ELM_SLIDER_DATA_GET(obj, sd);
dir = _orientation_get(_is_horizontal(sd->orientation), inverted);
efl_orientation_set(obj, dir);
}
EAPI Eina_Bool
elm_slider_inverted_get(const Evas_Object *obj)
{
Efl_Orient dir;
dir = efl_orientation_get(obj);
return _is_inverted(dir);
}
EAPI void
elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func)
{
ELM_SLIDER_DATA_GET(obj, sd);
sd->units_format_func = func;
sd->units_format_free = free_func;
evas_object_smart_changed(obj);
}
EOLIAN static void EOLIAN static void
_elm_slider_span_size_set(Eo *obj, Elm_Slider_Data *sd, Evas_Coord size) _elm_slider_efl_orientation_orientation_set(Eo *obj, Elm_Slider_Data *sd, Efl_Orient dir)
{
sd->orientation = dir;
elm_obj_widget_theme_apply(obj);
}
EOLIAN static Efl_Orient
_elm_slider_efl_orientation_orientation_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{
return sd->orientation;
}
EOLIAN static void
_elm_slider_efl_ui_progress_span_size_set(Eo *obj, Elm_Slider_Data *sd, Evas_Coord size)
{ {
if (sd->size == size) return; if (sd->size == size) return;
sd->size = size; sd->size = size;
@ -1254,13 +1412,13 @@ _elm_slider_span_size_set(Eo *obj, Elm_Slider_Data *sd, Evas_Coord size)
} }
EOLIAN static Evas_Coord EOLIAN static Evas_Coord
_elm_slider_span_size_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) _elm_slider_efl_ui_progress_span_size_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{ {
return sd->size; return sd->size;
} }
EOLIAN static void EOLIAN static void
_elm_slider_unit_format_set(Eo *obj, Elm_Slider_Data *sd, const char *units) _elm_slider_efl_ui_progress_unit_format_set(Eo *obj, Elm_Slider_Data *sd, const char *units)
{ {
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
@ -1286,8 +1444,8 @@ _elm_slider_unit_format_set(Eo *obj, Elm_Slider_Data *sd, const char *units)
evas_object_smart_changed(obj); evas_object_smart_changed(obj);
} }
EOLIAN static const char* EOLIAN static const char *
_elm_slider_unit_format_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) _elm_slider_efl_ui_progress_unit_format_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{ {
return sd->units; return sd->units;
} }
@ -1305,22 +1463,6 @@ _elm_slider_indicator_format_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
return sd->indicator; return sd->indicator;
} }
EOLIAN static void
_elm_slider_horizontal_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool horizontal)
{
horizontal = !!horizontal;
if (sd->horizontal == horizontal) return;
sd->horizontal = horizontal;
elm_obj_widget_theme_apply(obj);
}
EOLIAN static Eina_Bool
_elm_slider_horizontal_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{
return sd->horizontal;
}
EOLIAN static void EOLIAN static void
_elm_slider_min_max_set(Eo *obj, Elm_Slider_Data *sd, double min, double max) _elm_slider_min_max_set(Eo *obj, Elm_Slider_Data *sd, double min, double max)
{ {
@ -1341,7 +1483,7 @@ _elm_slider_min_max_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, double *min, d
} }
EOLIAN static void EOLIAN static void
_elm_slider_value_set(Eo *obj, Elm_Slider_Data *sd, double val) _elm_slider_efl_ui_progress_value_set(Eo *obj, Elm_Slider_Data *sd, double val)
{ {
if (sd->val == val) return; if (sd->val == val) return;
sd->val = val; sd->val = val;
@ -1354,44 +1496,11 @@ _elm_slider_value_set(Eo *obj, Elm_Slider_Data *sd, double val)
} }
EOLIAN static double EOLIAN static double
_elm_slider_value_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd) _elm_slider_efl_ui_progress_value_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{ {
return sd->val; return sd->val;
} }
EOLIAN static void
_elm_slider_inverted_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool inverted)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
inverted = !!inverted;
if (sd->inverted == inverted) return;
sd->inverted = inverted;
if (sd->inverted)
{
elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
if (sd->popup)
edje_object_signal_emit(sd->popup, "elm,state,inverted,on", "elm");
}
else
{
elm_layout_signal_emit(obj, "elm,state,inverted,off", "elm");
if (sd->popup)
edje_object_signal_emit(sd->popup, "elm,state,inverted,off", "elm");
}
edje_object_message_signal_process(wd->resize_obj);
_visuals_refresh(obj);
}
EOLIAN static Eina_Bool
_elm_slider_inverted_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{
return sd->inverted;
}
EOLIAN static void EOLIAN static void
_elm_slider_indicator_format_function_set(Eo *obj, Elm_Slider_Data *sd, slider_func_type func, slider_freefunc_type free_func) _elm_slider_indicator_format_function_set(Eo *obj, Elm_Slider_Data *sd, slider_func_type func, slider_freefunc_type free_func)
{ {
@ -1400,15 +1509,6 @@ _elm_slider_indicator_format_function_set(Eo *obj, Elm_Slider_Data *sd, slider_f
evas_object_smart_changed(obj); evas_object_smart_changed(obj);
} }
EOLIAN static void
_elm_slider_units_format_function_set(Eo *obj, Elm_Slider_Data *sd, slider_func_type func, slider_freefunc_type free_func)
{
sd->units_format_func = func;
sd->units_format_free = free_func;
evas_object_smart_changed(obj);
}
EOLIAN static void EOLIAN static void
_elm_slider_indicator_show_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool show) _elm_slider_indicator_show_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool show)
{ {

View File

@ -1,44 +1,10 @@
class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value, class Elm.Slider (Elm.Layout, Efl.Ui.Progress,
Efl.Orientation,
Elm.Interface_Atspi_Value,
Elm.Interface_Atspi_Widget_Action) Elm.Interface_Atspi_Widget_Action)
{ {
eo_prefix: elm_obj_slider; eo_prefix: elm_obj_slider;
methods { methods {
@property horizontal {
set {
[[Set the orientation of a given slider widget.
Use this function to change how your slider is to be
disposed: vertically or horizontally.
By default it's displayed horizontally.
]]
}
get {
[[Get the orientation of a given slider widget.]]
}
values {
horizontal: bool;
}
}
@property value {
set {
[[Set the value the slider displays.
Value will be presented on the unit label following format
specified with @.unit_format.set and on indicator with
@.indicator_format.set.
Note: The value must to be between min and max values. This values
are set by @.min_max.set.
]]
}
get {
[[Get the value displayed by the slider.]]
}
values {
val: double; [[The value to be displayed.]]
}
}
@property indicator_format { @property indicator_format {
set { set {
[[Set the format string for the indicator label. [[Set the format string for the indicator label.
@ -71,27 +37,6 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
indicator: const(char)* @nullable; [[The format string for the indicator display.]] indicator: const(char)* @nullable; [[The format string for the indicator display.]]
} }
} }
@property inverted {
set {
[[Invert a given slider widget's displaying values order
A slider may be inverted, in which state it gets its values
inverted, with high vales being on the left or top and low
values on the right or bottom, as opposed to normally have
the low values on the former and high values on the latter,
respectively, for horizontal and vertical modes.
]]
}
get {
[[Get whether a given slider widget's displaying values are
inverted or not.
]]
}
values {
inverted: bool; [[Use $true to make $obj inverted, $false to bring
it back to default, non-inverted values.]]
}
}
@property indicator_show { @property indicator_show {
set { set {
[[Set whether to enlarge slider indicator (augmented knob) or not. [[Set whether to enlarge slider indicator (augmented knob) or not.
@ -118,7 +63,7 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
If actual value is less than $min, it will be updated to $min. If actual value is less than $min, it will be updated to $min.
If it is bigger then $max, will be updated to $max. Actual value If it is bigger then $max, will be updated to $max. Actual value
can be get with @.value,get. can be get with @Efl.Ui.Progress.value.get
By default, min is equal to 0.0, and max is equal to 1.0. By default, min is equal to 0.0, and max is equal to 1.0.
@ -138,36 +83,6 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
max: double; [[The maximum value.]] max: double; [[The maximum value.]]
} }
} }
@property unit_format {
set {
[[Set the format string for the unit label.
Unit label is displayed all the time, if set, after slider's bar.
In horizontal mode, at right and in vertical mode, at bottom.
If $null, unit label won't be visible. If not it sets the format
string for the label text. To the label text is provided a
floating point value, so the label text can display up to 1
floating point value. Note that this is optional.
Use a format string such as "%1.2f meters" for example, and it
will display values like: "3.14 meters" for a value equal to
3.14159.
Default is unit label disabled.
]]
}
get {
[[Get the unit label format of the slider.
Unit label is displayed all the time, if set, after slider's bar.
In horizontal mode, at right and in vertical mode, at bottom.
]]
}
values {
units: const(char)* @nullable; [[The format string for the unit display.]]
}
}
@property indicator_show_on_focus { @property indicator_show_on_focus {
set { set {
[[Show the indicator of slider on focus.]] [[Show the indicator of slider on focus.]]
@ -179,33 +94,6 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
flag: bool; flag: bool;
} }
} }
@property span_size {
set {
[[Set the (exact) length of the bar region of a given slider widget.
This sets the minimum width (when in horizontal mode) or height
(when in vertical mode) of the actual bar area of the slider
$obj. This in turn affects the object's minimum size. Use
this when you're not setting other size hints expanding on the
given direction (like weight and alignment hints) and you would
like it to have a specific size.
Note: Icon, end, label, indicator and unit text around $obj
will require their own space, which will make $obj to require
more the $size, actually.
]]
}
get {
[[Get the length set for the bar region of a given slider widget
If that size was not set previously, with @.span_size.set, this
call will return $0.
]]
}
values {
size: Evas.Coord; [[The length of the slider's bar region.]]
}
}
@property step { @property step {
set { set {
[[Set the step by which slider indicator will move. [[Set the step by which slider indicator will move.
@ -251,18 +139,6 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
free_func: slider_freefunc_type @nullable; [[The freeing function for the format string.]] free_func: slider_freefunc_type @nullable; [[The freeing function for the format string.]]
} }
} }
@property units_format_function {
set {
[[Set the format function pointer for the units label
Set the callback function to format the units string.
]]
}
values {
func: slider_func_type @nullable; [[The units format function.]]
free_func: slider_freefunc_type @nullable; [[The freeing function for the format string.]]
}
}
@property range_enabled { @property range_enabled {
set { set {
[[Enables the range. This enables two indicators in slider.]] [[Enables the range. This enables two indicators in slider.]]
@ -302,6 +178,10 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
Elm.Layout.text_aliases.get; Elm.Layout.text_aliases.get;
Elm.Layout.content_aliases.get; Elm.Layout.content_aliases.get;
Elm.Layout.sizing_eval; Elm.Layout.sizing_eval;
Efl.Ui.Progress.span_size;
Efl.Ui.Progress.value;
Efl.Ui.Progress.unit_format;
Efl.Orientation.orientation;
Elm.Interface_Atspi_Value.value_and_text.get; Elm.Interface_Atspi_Value.value_and_text.get;
Elm.Interface_Atspi_Value.value_and_text.set; Elm.Interface_Atspi_Value.value_and_text.set;
Elm.Interface_Atspi_Value.range.get; Elm.Interface_Atspi_Value.range.get;

View File

@ -11,4 +11,152 @@
*/ */
EAPI Evas_Object *elm_slider_add(Evas_Object *parent); EAPI Evas_Object *elm_slider_add(Evas_Object *parent);
/**
* @brief Set the orientation of a given slider widget.
*
* Use this function to change how your slider is to be disposed: vertically or
* horizontally.
*
* By default it's displayed horizontally.
*
* @param[in] horizontal
*
* @ingroup Elm_Slider
*/
EAPI void elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal);
/** Get the orientation of a given slider widget.
*
* @ingroup Elm_Slider
*/
EAPI Eina_Bool elm_slider_horizontal_get(const Evas_Object *obj);
/**
* @brief Set the value the slider displays.
*
* Value will be presented on the unit label following format specified with
* @ref elm_slider_unit_format_set and on indicator with
* @ref elm_slider_indicator_format_set.
*
* @note The value must to be between min and max values. This values are set
* by @ref elm_slider_min_max_set.
*
* @param[in] val The value to be displayed.
*
* @ingroup Elm_Slider
*/
EAPI void elm_slider_value_set(Evas_Object *obj, double val);
/**
* @brief Get the value displayed by the slider.
*
* @return The value to be displayed.
*
* @ingroup Elm_Slider
*/
EAPI double elm_slider_value_get(const Evas_Object *obj);
/**
* @brief Invert a given slider widget's displaying values order
*
* A slider may be inverted, in which state it gets its values inverted, with
* high vales being on the left or top and low values on the right or bottom,
* as opposed to normally have the low values on the former and high values on
* the latter, respectively, for horizontal and vertical modes.
*
* @param[in] inverted Use @c true to make @c obj inverted, @c false to bring
* it back to default, non-inverted values.
*
* @ingroup Elm_Slider
*/
EAPI void elm_slider_inverted_set(Evas_Object *obj, Eina_Bool inverted);
/**
* @brief Get whether a given slider widget's displaying values are inverted or
* not.
*
* @return Use @c true to make @c obj inverted, @c false to bring it back to
* default, non-inverted values.
*
* @ingroup Elm_Slider
*/
EAPI Eina_Bool elm_slider_inverted_get(const Evas_Object *obj);
/**
* @brief Set the (exact) length of the bar region of a given slider widget.
*
* This sets the minimum width (when in horizontal mode) or height (when in
* vertical mode) of the actual bar area of the slider @c obj. This in turn
* affects the object's minimum size. Use this when you're not setting other
* size hints expanding on the given direction (like weight and alignment
* hints) and you would like it to have a specific size.
*
* @note Icon, end, label, indicator and unit text around @c obj will require
* their own space, which will make @c obj to require more the @c size,
* actually.
*
* @param[in] size The length of the slider's bar region.
*
* @ingroup Elm_Slider
*/
EAPI void elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size);
/**
* @brief Get the length set for the bar region of a given slider widget
*
* If that size was not set previously, with @ref elm_slider_span_size_set,
* this call will return $0.
*
* @return The length of the slider's bar region.
*
* @ingroup Elm_Slider
*/
EAPI Evas_Coord elm_slider_span_size_get(const Evas_Object *obj);
/**
* @brief Set the format string for the unit label.
*
* Unit label is displayed all the time, if set, after slider's bar. In
* horizontal mode, at right and in vertical mode, at bottom.
*
* If @c null, unit label won't be visible. If not it sets the format string
* for the label text. To the label text is provided a floating point value, so
* the label text can display up to 1 floating point value. Note that this is
* optional.
*
* Use a format string such as "%1.2f meters" for example, and it will display
* values like: "3.14 meters" for a value equal to 3.14159.
*
* Default is unit label disabled.
*
* @param[in] units The format string for the unit display.
*
* @ingroup Elm_Slider
*/
EAPI void elm_slider_unit_format_set(Evas_Object *obj, const char *units);
/**
* @brief Get the unit label format of the slider.
*
* Unit label is displayed all the time, if set, after slider's bar. In
* horizontal mode, at right and in vertical mode, at bottom.
*
* @return The format string for the unit display.
*
* @ingroup Elm_Slider
*/
EAPI const char *elm_slider_unit_format_get(const Evas_Object *obj);
/**
* @brief Set the format function pointer for the units label
*
* Set the callback function to format the units string.
*
* @param[in] func The units format function.
* @param[in] free_func The freeing function for the format string.
*
* @ingroup Elm_Slider
*/
EAPI void elm_slider_units_format_function_set(Evas_Object *obj, slider_func_type func, slider_freefunc_type free_func);
#include "elm_slider.eo.legacy.h" #include "elm_slider.eo.legacy.h"

View File

@ -34,8 +34,7 @@ struct _Elm_Progressbar_Data
Evas_Coord size; /**< Width or height of progressbar */ Evas_Coord size; /**< Width or height of progressbar */
double val; /**< Value of progressbar */ double val; /**< Value of progressbar */
Eina_Bool horizontal : 1; /**< Whether progressbar style is horizontal */ Efl_Orient orientation; /**< Orientation of the progressbar */
Eina_Bool inverted : 1; /**< Whether direction of progressbar is LTR */
Eina_Bool pulse : 1; /**< Whether object is put in the pulsing mode */ Eina_Bool pulse : 1; /**< Whether object is put in the pulsing mode */
Eina_Bool pulse_state : 1; /**< To start the pulsing animation, otherwise to stop it */ Eina_Bool pulse_state : 1; /**< To start the pulsing animation, otherwise to stop it */
Eina_List *progress_status; /**< The list of _Elm_Progress_Status. To save the progress value(in percentage) each part of given progress bar */ Eina_List *progress_status; /**< The list of _Elm_Progress_Status. To save the progress value(in percentage) each part of given progress bar */

View File

@ -47,11 +47,10 @@ struct _Elm_Slider_Data
Evas_Coord size; Evas_Coord size;
Evas_Coord downx, downy; Evas_Coord downx, downy;
Efl_Orient orientation;
double range_from, range_to; double range_from, range_to;
Eina_Bool horizontal : 1;
Eina_Bool inverted : 1;
Eina_Bool indicator_show : 1; Eina_Bool indicator_show : 1;
Eina_Bool spacer_down : 1; Eina_Bool spacer_down : 1;
Eina_Bool frozen : 1; Eina_Bool frozen : 1;