From c11c7b5041afdf54feeef141a681e53bd39c6477 Mon Sep 17 00:00:00 2001 From: Niraj Kumar Date: Tue, 10 Sep 2013 15:47:13 +0900 Subject: [PATCH] progressbar: Support second progress. This can be used by video/audio streaming such as youtube. --- legacy/elementary/AUTHORS | 1 + legacy/elementary/ChangeLog | 5 + legacy/elementary/NEWS | 1 + .../elementary/data/themes/widgets/progressbar.edc | 434 +++++++++++++++++++++ legacy/elementary/src/bin/test.c | 2 + legacy/elementary/src/bin/test_progressbar.c | 116 +++++- legacy/elementary/src/lib/elm_authors.h | 1 + legacy/elementary/src/lib/elm_progressbar.c | 123 +++++- legacy/elementary/src/lib/elm_progressbar_eo.h | 34 ++ legacy/elementary/src/lib/elm_progressbar_legacy.h | 33 ++ legacy/elementary/src/lib/elm_widget_progressbar.h | 9 + 11 files changed, 750 insertions(+), 9 deletions(-) diff --git a/legacy/elementary/AUTHORS b/legacy/elementary/AUTHORS index 926275f..a98a82e 100644 --- a/legacy/elementary/AUTHORS +++ b/legacy/elementary/AUTHORS @@ -81,3 +81,4 @@ Stefan Schmidt Ryuan Choi (ryuan) Hosang Kim Youngbok Shin +Niraj Kumar diff --git a/legacy/elementary/ChangeLog b/legacy/elementary/ChangeLog index 1718c8c..d957f29 100644 --- a/legacy/elementary/ChangeLog +++ b/legacy/elementary/ChangeLog @@ -1593,3 +1593,8 @@ 2013-09-07 Shinwoo Kim * elm_access : delete access object in job when its hover object is deleted + +2013-09-10 Niraj Kumar + + * ProgressBar: Added support for more than one progress status in a + single progress bar diff --git a/legacy/elementary/NEWS b/legacy/elementary/NEWS index 30d5df0..2a3ed46 100644 --- a/legacy/elementary/NEWS +++ b/legacy/elementary/NEWS @@ -86,6 +86,7 @@ Additions: * Add selectraise feature to gengrid. * Add bg reset feature. * Add elm_object_item_object_get(). + * Added support for more than one progress status in a progressbar. Improvements: diff --git a/legacy/elementary/data/themes/widgets/progressbar.edc b/legacy/elementary/data/themes/widgets/progressbar.edc index 1f88ef2..ff3b535 100644 --- a/legacy/elementary/data/themes/widgets/progressbar.edc +++ b/legacy/elementary/data/themes/widgets/progressbar.edc @@ -848,3 +848,437 @@ group { name: "elm/progressbar/horizontal/wheel"; /////////////////////////////////////////////////////////////////////////////// +group { name: "elm/progressbar/horizontal/recording"; + images { + image: "shelf_inset.png" COMP; + image: "bt_sm_base2.png" COMP; + image: "flip_shad.png" COMP; + } + parts { + part { name: "elm.background.progressbar"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { + relative: 1.0 1.0; + } + } + } + part { name: "elm.swallow.bar"; + mouse_events: 0; + scale: 1; + type: SWALLOW; + description { + min: 48 28; + max: 99999 28; state: "default" 0.0; + rel1 { + to_x: "elm.text"; + to_y: "elm.background.progressbar"; + relative: 1.0 0.0; + } + rel2 { + to: "elm.background.progressbar"; + relative: 1.0 1.0; + } + } + } + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; + visible: 0; + align: 0.0 0.5; + rel1 { + offset: 4 0; + to_y: "elm.background.progressbar"; + } + rel2 { + offset: 3 -1; + relative: 0.0 1.0; + to_y: "elm.background.progressbar"; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + aspect: 1.0 1.0; + aspect_preference: VERTICAL; + rel2.offset: 4 -1; + } + } + part { name: "elm.text"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + visible: 0; + fixed: 1 1; + align: 0.0 0.5; + rel1.to_x: "elm.swallow.content"; + rel1.relative: 1.0 0.0; + rel1.offset: -1 4; + rel2.to_x: "elm.swallow.content"; + rel2.relative: 1.0 1.0; + rel2.offset: -1 -5; + color: 0 0 0 255; + text { + font: "Sans,Edje-Vera"; + size: 10; + min: 0 0; + align: 0.0 0.5; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + text.min: 1 1; + rel1.offset: 0 4; + rel2.offset: 0 -5; + } + } + part { name: "background"; + mouse_events: 0; + clip_to: "elm.background.progressbar"; + description { + state: "default" 0.0; + rel1 { + to: "elm.swallow.bar"; + relative: 0.0 0.0; + } + rel2 { + to: "elm.swallow.bar"; + relative: 1.0 1.0; + offset: -1 -1; + } + image { + normal: "shelf_inset.png"; + border: 7 7 7 7; + } + } + } + part { name: "elm.text.status"; + type: TEXT; + mouse_events: 0; + description { state: "default" 0.0; + fixed: 1 1; + visible: 0; + rel1 { + to: "background"; + relative: 0.5 0.5; + } + rel2 { + to: "background"; + relative: 0.5 0.5; + } + text { + font: "Sans:style=Bold,Edje-Vera-Bold"; + size: 10; + min: 1 1; + align: 0.5 0.0; + } + color: 0 0 0 255; + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + text.min: 0 0; + } + } + part { name: "elm.progress.progressbar"; + mouse_events: 0; + clip_to: "elm.background.progressbar"; + description { + state: "default" 0.0; + min: 14 28; + fixed: 1 1; + rel1 { + to: "elm.swallow.bar"; + relative: 0.0 0.0; + } + rel2 { + to_y: "elm.swallow.bar"; + to_x: "elm.cur.progressbar"; + offset: -1 -1; + } + image { + normal: "flip_shad.png"; + border: 6 6 6 6; + } + } + description { + state: "invert" 0.0; + inherit: "default" 0.0; + rel1 { + to_y: "elm.swallow.bar"; + to_x: "elm.cur.progressbar"; + } + rel2 { + to: "elm.swallow.bar"; + relative: 1.0 1.0; + } + } + description { + state: "state_begin" 0.0; + inherit: "default" 0.0; + rel1 { + to: "elm.swallow.bar"; + relative: 0.0 0.0; + } + rel2 { + to: "elm.swallow.bar"; + relative: 0.1 1.0; + } + } + description { + state: "state_end" 0.0; + inherit: "default" 0.0; + rel1 { + to: "elm.swallow.bar"; + relative: 0.9 0.0; + } + rel2 { + to: "elm.swallow.bar"; + relative: 1.0 1.0; + } + } + } + part { name: "elm.progress.progressbar1"; + mouse_events: 0; + clip_to: "elm.background.progressbar"; + description { + state: "default" 0.0; + min: 14 28; + fixed: 1 1; + rel1 { + to: "elm.swallow.bar"; + relative: 0.0 0.0; + } + rel2 { + to_y: "elm.swallow.bar"; + to_x: "elm.cur.progressbar1"; + offset: -1 -1; + } + image { + normal: "bt_sm_base2.png"; + border: 6 6 6 6; + } + } + description { + state: "invert" 0.0; + inherit: "default" 0.0; + rel1 { + to_y: "elm.swallow.bar"; + to_x: "elm.cur.progressbar1"; + } + rel2 { + to: "elm.swallow.bar"; + relative: 1.0 1.0; + } + } + description { + state: "state_begin" 0.0; + inherit: "default" 0.0; + rel1 { + to: "elm.swallow.bar"; + relative: 0.0 0.0; + } + rel2 { + to: "elm.swallow.bar"; + relative: 0.1 1.0; + } + } + description { + state: "state_end" 0.0; + inherit: "default" 0.0; + rel1 { + to: "elm.swallow.bar"; + relative: 0.9 0.0; + } + rel2 { + to: "elm.swallow.bar"; + relative: 1.0 1.0; + } + } + } + part { name: "text-bar"; + type: TEXT; + mouse_events: 0; + clip_to: "progress-rect"; + effect: SOFT_SHADOW; + scale: 1; + description { state: "default" 0.0; + align: 0.0 0.0; + fixed: 1 1; + visible: 0; + rel1.to: "elm.text.status"; + rel1.offset: -1 -1; + rel2.to: "elm.text.status"; + text { + text_source: "elm.text.status"; + font: "Sans:style=Bold,Edje-Vera-Bold"; + size: 10; + min: 1 1; + align: 0.0 0.0; + } + color: 224 224 224 255; + color3: 0 0 0 64; + } + description { state: "hidden" 0.0; + inherit: "default" 0.0; + visible: 0; + text.min: 0 0; + } + } + part { name: "elm.cur.progressbar"; + mouse_events: 0; + dragable { + confine: "background"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + min: 14 28; + fixed: 1 1; + visible: 0; + rel1 { + to: "background"; + relative: 0 0; + } + rel2.to: "background"; + } + } + part { name: "elm.cur.progressbar1"; + mouse_events: 0; + dragable { + confine: "background"; + x: 1 1 1; + y: 0 0 0; + } + description { state: "default" 0.0; + min: 14 28; + fixed: 1 1; + visible: 0; + rel1 { + to: "background"; + relative: 0 0; + } + rel2.to: "background"; + } + } + part { name: "progress-rect"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "elm.progress.progressbar"; + rel2.to: "elm.progress.progressbar"; + } + } + } + programs { + program { name: "label_show"; + signal: "elm,state,text,visible"; + source: "elm"; + action: STATE_SET "visible" 0.0; + target: "elm.text"; + } + program { name: "label_hide"; + signal: "elm,state,text,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + } + program { name: "icon_show"; + signal: "elm,state,icon,visible"; + source: "elm"; + action: STATE_SET "visible" 0.0; + target: "elm.swallow.content"; + } + program { name: "icon_hide"; + signal: "elm,state,icon,hidden"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.content"; + } + program { name: "units_show"; + signal: "elm,state,units,visible"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "text-bar"; + target: "elm.text.status"; + } + program { name: "units_hide"; + signal: "elm,state,units,hidden"; + source: "elm"; + action: STATE_SET "hidden" 0.0; + target: "text-bar"; + target: "elm.text.status"; + } + program { name: "slide_to_end"; + action: STATE_SET "state_end" 0.0; + transition: LINEAR 0.5; + target: "elm.progress.progressbar"; + target: "elm.progress.progressbar1"; + after: "slide_to_begin"; + } + program { name: "slide_to_begin"; + signal: "elm,state,slide,begin"; + action: STATE_SET "state_begin" 0.0; + target: "elm.progress.progressbar"; + target: "elm.progress.progressbar1"; + transition: LINEAR 0.5; + after: "slide_to_end"; + } + program { name: "start_pulse"; + signal: "elm,state,pulse,start"; + source: "elm"; + after: "slide_to_end"; + } + program { name: "stop_pulse"; + signal: "elm,state,pulse,stop"; + source: "elm"; + action: ACTION_STOP; + target: "slide_to_begin"; + target: "slide_to_end"; + target: "start_pulse"; + after: "state_pulse"; + } + program { name: "state_pulse"; + signal: "elm,state,pulse"; + source: "elm"; + action: STATE_SET "state_begin" 0.0; + target: "elm.progress.progressbar"; + target: "elm.progress.progressbar1"; + after: "units_hide"; + } + program { name: "state_fraction"; + signal: "elm,state,fraction"; + source: "elm"; + action: ACTION_STOP; + target: "slide_to_begin"; + target: "slide_to_end"; + target: "start_pulse"; + action: STATE_SET "default" 0.0; + target: "elm.progress.progressbar"; + target: "elm.progress.progressbar1"; + } + program { name: "set_invert_on"; + signal: "elm,state,inverted,on"; + source: "elm"; + action: STATE_SET "invert" 0.0; + target: "elm.progress.progressbar"; + target: "elm.progress.progressbar1"; + } + program { name: "set_invert_off"; + signal: "elm,state,inverted,off"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.progress.progressbar"; + target: "elm.progress.progressbar1"; + } + } +} + +/////////////////////////////////////////////////////////////////////////////// diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c index 9bbec15..2e69866 100644 --- a/legacy/elementary/src/bin/test.c +++ b/legacy/elementary/src/bin/test.c @@ -127,6 +127,7 @@ void test_gengrid4(void *data, Evas_Object *obj, void *event_info); void test_win_state(void *data, Evas_Object *obj, void *event_info); void test_win_state2(void *data, Evas_Object *obj, void *event_info); void test_progressbar(void *data, Evas_Object *obj, void *event_info); +void test_progressbar2(void *data, Evas_Object *obj, void *event_info); void test_fileselector(void *data, Evas_Object *obj, void *event_info); void test_separator(void *data, Evas_Object *obj, void *event_info); void test_scroller(void *data, Evas_Object *obj, void *event_info); @@ -715,6 +716,7 @@ add_tests: ADD_TEST(NULL, "Range Values", "Spinner", test_spinner); ADD_TEST(NULL, "Range Values", "Slider", test_slider); ADD_TEST(NULL, "Range Values", "Progressbar", test_progressbar); + ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2); //------------------------------// ADD_TEST(NULL, "Booleans", "Check", test_check); diff --git a/legacy/elementary/src/bin/test_progressbar.c b/legacy/elementary/src/bin/test_progressbar.c index 6f63d32..13ac94f 100644 --- a/legacy/elementary/src/bin/test_progressbar.c +++ b/legacy/elementary/src/bin/test_progressbar.c @@ -38,6 +38,26 @@ _my_progressbar_value_set (void *data EINA_UNUSED) return ECORE_CALLBACK_CANCEL; } +static Eina_Bool +_my_progressbar_value_set2(void *data EINA_UNUSED) +{ + double progress; + + progress = elm_progressbar_value_get (_test_progressbar.pb1); + if (progress < 1.0) progress += 0.0123; + else progress = 0.0; + elm_progressbar_part_value_set(_test_progressbar.pb1, "elm.cur.progressbar", progress); + elm_progressbar_value_set(_test_progressbar.pb2, progress); + elm_progressbar_part_value_set(_test_progressbar.pb2, "elm.cur.progressbar1", progress-0.15); + elm_progressbar_part_value_set(_test_progressbar.pb3, "elm.cur.progressbar", progress); + elm_progressbar_part_value_set(_test_progressbar.pb3, "elm.cur.progressbar1", progress-0.15); + + if (progress < 1.0) return ECORE_CALLBACK_RENEW; + + _test_progressbar.timer = NULL; + return ECORE_CALLBACK_CANCEL; +} + static void my_progressbar_test_start(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { @@ -58,12 +78,37 @@ my_progressbar_test_start(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, } static void +my_progressbar_test_start2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + fprintf(stderr, "s1\n"); + + elm_object_disabled_set(_test_progressbar.btn_start, EINA_TRUE); + elm_object_disabled_set(_test_progressbar.btn_stop, EINA_FALSE); + + if (!_test_progressbar.timer) + _test_progressbar.timer = ecore_timer_add(0.1, + _my_progressbar_value_set2, NULL); +} + +static void my_progressbar_test_stop(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { + elm_progressbar_pulse(_test_progressbar.pb1, EINA_FALSE); elm_progressbar_pulse(_test_progressbar.pb2, EINA_FALSE); - elm_progressbar_pulse(_test_progressbar.pb5, EINA_FALSE); - elm_progressbar_pulse(_test_progressbar.pb7, EINA_FALSE); + elm_progressbar_pulse(_test_progressbar.pb3, EINA_FALSE); + elm_object_disabled_set(_test_progressbar.btn_start, EINA_FALSE); + elm_object_disabled_set(_test_progressbar.btn_stop, EINA_TRUE); + + if (_test_progressbar.timer) + { + ecore_timer_del(_test_progressbar.timer); + _test_progressbar.timer = NULL; + } +} +static void +my_progressbar_test_stop2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ elm_object_disabled_set(_test_progressbar.btn_start, EINA_FALSE); elm_object_disabled_set(_test_progressbar.btn_stop, EINA_TRUE); @@ -226,4 +271,71 @@ test_progressbar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve evas_object_show(win); } + +void +test_progressbar2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win, *pb, *bx, *bt, *bt_bx; + + win = elm_win_util_standard_add("progressbar", "Progressbar2"); + evas_object_smart_callback_add(win, "delete,request", + my_progressbar_destroy, NULL); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + + pb = elm_progressbar_add(win); + elm_object_text_set(pb, "Style: default"); + evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); + evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_progressbar_span_size_set(pb, 200); + elm_box_pack_end(bx, pb); + evas_object_show(pb); + _test_progressbar.pb1 = pb; + + pb = elm_progressbar_add(win); + elm_object_style_set(pb, "recording"); + elm_object_text_set(pb, "Style: Recording"); + evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); + evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_progressbar_span_size_set(pb, 200); + elm_box_pack_end(bx, pb); + evas_object_show(pb); + _test_progressbar.pb2 = pb; + + pb = elm_progressbar_add(win); + elm_object_style_set(pb, "recording"); + elm_object_text_set(pb, "Style: Recording 2"); + evas_object_size_hint_align_set(pb, EVAS_HINT_FILL, 0.5); + evas_object_size_hint_weight_set(pb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_progressbar_span_size_set(pb, 200); + elm_box_pack_end(bx, pb); + evas_object_show(pb); + _test_progressbar.pb3 = pb; + + bt_bx = elm_box_add(win); + elm_box_horizontal_set(bt_bx, EINA_TRUE); + evas_object_size_hint_weight_set(bt_bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_box_pack_end(bx, bt_bx); + evas_object_show(bt_bx); + + bt = elm_button_add(win); + elm_object_text_set(bt, "Start"); + evas_object_smart_callback_add(bt, "clicked", my_progressbar_test_start2, NULL); + elm_box_pack_end(bt_bx, bt); + evas_object_show(bt); + _test_progressbar.btn_start = bt; + + bt = elm_button_add(win); + elm_object_text_set(bt, "Stop"); + elm_object_disabled_set(bt, EINA_TRUE); + evas_object_smart_callback_add(bt, "clicked", my_progressbar_test_stop2, NULL); + elm_box_pack_end(bt_bx, bt); + evas_object_show(bt); + _test_progressbar.btn_stop = bt; + + evas_object_show(win); +} #endif diff --git a/legacy/elementary/src/lib/elm_authors.h b/legacy/elementary/src/lib/elm_authors.h index cebc5e1..3045c29 100644 --- a/legacy/elementary/src/lib/elm_authors.h +++ b/legacy/elementary/src/lib/elm_authors.h @@ -83,6 +83,7 @@ * @author Ryuan Choi (ryuan) * @author Hosang Kim * @author Youngbok Shin + * @author Niraj Kumar * * Please contact to get in * contact with the developers and maintainers. diff --git a/legacy/elementary/src/lib/elm_progressbar.c b/legacy/elementary/src/lib/elm_progressbar.c index d48c00e..ef702d8 100644 --- a/legacy/elementary/src/lib/elm_progressbar.c +++ b/legacy/elementary/src/lib/elm_progressbar.c @@ -40,6 +40,22 @@ static const Elm_Layout_Part_Alias_Description _text_aliases[] = {NULL, NULL} }; +static Elm_Progress_Status * +_progress_status_new(const char *part_name, double val) +{ + Elm_Progress_Status *ps; + ps = calloc(1, sizeof(Elm_Progress_Status)); + ps->part_name = eina_stringshare_add(part_name); + ps->val = val; + return ps; +} + +static inline void +_progress_status_free(Elm_Progress_Status *ps) +{ + eina_stringshare_del(ps->part_name); + free(ps); +} static void _units_set(Evas_Object *obj) { @@ -72,16 +88,21 @@ _val_set(Evas_Object *obj) ELM_PROGRESSBAR_DATA_GET(obj, sd); Elm_Widget_Smart_Data *wd = eo_data_scope_get(obj, ELM_OBJ_WIDGET_CLASS); - pos = sd->val; rtl = elm_widget_mirrored_get(obj); - - if ((!rtl && sd->inverted) || - (rtl && ((!sd->horizontal && sd->inverted) || + Elm_Progress_Status *ps; + Eina_List *l; + + EINA_LIST_FOREACH(sd->progress_status, l, ps) + { + pos = ps->val; + if ((!rtl && sd->inverted) || + (rtl && ((!sd->horizontal && sd->inverted) || (sd->horizontal && !sd->inverted)))) - pos = MAX_RATIO_LVL - pos; + pos = MAX_RATIO_LVL - pos; - edje_object_part_drag_value_set - (wd->resize_obj, "elm.cur.progressbar", pos, pos); + edje_object_part_drag_value_set + (wd->resize_obj, ps->part_name, pos, pos); + } } static void @@ -284,8 +305,16 @@ static void _elm_progressbar_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED) { Elm_Progressbar_Smart_Data *sd = _pd; + Elm_Progress_Status *progress_obj; if (sd->units) eina_stringshare_del(sd->units); + if (sd->progress_status) + { + EINA_LIST_FREE(sd->progress_status, progress_obj) + { + _progress_status_free(progress_obj); + } + } eo_do_super(obj, MY_CLASS, evas_obj_smart_del()); } @@ -388,6 +417,79 @@ _pulse(Eo *obj, void *_pd, va_list *list) } EAPI void +elm_progressbar_part_value_set(Evas_Object *obj, const char *part, double val) +{ + ELM_PROGRESSBAR_CHECK(obj); + eo_do(obj, elm_obj_progressbar_part_value_set(part, val)); +} + +static void +_part_value_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list) +{ + const char *part_name = va_arg(*list, const char *); + double val = va_arg(*list, double); + Elm_Progressbar_Smart_Data *sd = _pd; + Elm_Progress_Status *ps; + Eina_Bool existing_ps = EINA_FALSE; + Eina_List *l; + + if (val < MIN_RATIO_LVL) val = MIN_RATIO_LVL; + if (val > MAX_RATIO_LVL) val = MAX_RATIO_LVL; + + if (!strcmp(part_name, "elm.cur.progressbar")) + sd->val = val; + + EINA_LIST_FOREACH(sd->progress_status, l, ps) + { + if (!strcmp(ps->part_name, part_name)) + { + existing_ps = EINA_TRUE; + break; + } + } + + if (!existing_ps) + { + ps = _progress_status_new(part_name, val); + sd->progress_status = eina_list_append(sd->progress_status, ps); + } + else + ps->val = val; + + _val_set(obj); + _units_set(obj); + evas_object_smart_callback_call(obj, SIG_CHANGED, NULL); +} + +EAPI double +elm_progressbar_part_value_get(const Evas_Object *obj, const char * part) +{ + ELM_PROGRESSBAR_CHECK(obj) 0.0; + double ret; + eo_do((Eo *) obj, elm_obj_progressbar_part_value_get(part,&ret)); + return ret; +} + +static void +_part_value_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list) +{ + const char* part = va_arg(*list, const char *); + double *ret = va_arg(*list, double *); + Elm_Progressbar_Smart_Data *sd = _pd; + Elm_Progress_Status *ps; + Eina_List *l; + + EINA_LIST_FOREACH(sd->progress_status, l, ps) + { + if (!strcmp(ps->part_name, part)) + { + *ret = ps->val; + return; + } + } +} + +EAPI void elm_progressbar_value_set(Evas_Object *obj, double val) { @@ -400,6 +502,7 @@ _value_set(Eo *obj, void *_pd, va_list *list) { double val = va_arg(*list, double); Elm_Progressbar_Smart_Data *sd = _pd; + Elm_Progress_Status *ps; if (sd->val == val) return; @@ -407,6 +510,8 @@ _value_set(Eo *obj, void *_pd, va_list *list) if (sd->val < MIN_RATIO_LVL) sd->val = MIN_RATIO_LVL; if (sd->val > MAX_RATIO_LVL) sd->val = MAX_RATIO_LVL; + ps = _progress_status_new("elm.cur.progressbar", sd->val); + sd->progress_status = eina_list_append(sd->progress_status, ps); _val_set(obj); _units_set(obj); evas_object_smart_callback_call(obj, SIG_CHANGED, NULL); @@ -681,6 +786,8 @@ _class_constructor(Eo_Class *klass) EO_OP_FUNC(ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_HORIZONTAL_GET), _horizontal_get), EO_OP_FUNC(ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_SET), _inverted_set), EO_OP_FUNC(ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_GET), _inverted_get), + EO_OP_FUNC(ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_SET), _part_value_set), + EO_OP_FUNC(ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_GET), _part_value_get), EO_OP_FUNC_SENTINEL }; eo_class_funcs_set(klass, func_desc); @@ -702,6 +809,8 @@ static const Eo_Op_Description op_desc[] = { EO_OP_DESCRIPTION(ELM_OBJ_PROGRESSBAR_SUB_ID_HORIZONTAL_GET, "Retrieve the orientation of a given progress bar widget."), EO_OP_DESCRIPTION(ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_SET, "Invert a given progress bar widget's displaying values order."), EO_OP_DESCRIPTION(ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_GET, "Get whether a given progress bar widget's displaying values are inverted or not."), + EO_OP_DESCRIPTION(ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_SET, "Set the progress value (in percentage) on a given progress bar widget for a part."), + EO_OP_DESCRIPTION(ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_GET, "Get the progress value (in percentage) on a given progress bar widget for a part."), EO_OP_DESCRIPTION_SENTINEL }; static const Eo_Class_Description class_desc = { diff --git a/legacy/elementary/src/lib/elm_progressbar_eo.h b/legacy/elementary/src/lib/elm_progressbar_eo.h index 26f30aa..7cfa6eb 100644 --- a/legacy/elementary/src/lib/elm_progressbar_eo.h +++ b/legacy/elementary/src/lib/elm_progressbar_eo.h @@ -23,6 +23,8 @@ enum ELM_OBJ_PROGRESSBAR_SUB_ID_HORIZONTAL_GET, ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_SET, ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_GET, + ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_SET, + ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_GET, ELM_OBJ_PROGRESSBAR_SUB_ID_LAST }; @@ -229,3 +231,35 @@ enum * @ingroup Progressbar */ #define elm_obj_progressbar_inverted_get(ret) ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_INVERTED_GET), EO_TYPECHECK(Eina_Bool *, ret) + +/** + * @def elm_progressbar_part_value_set + * @since 1.8 + * + * Modified to support more than one progress status + * Set the value of the progress status a particular part + * + * @param[in] part + * @param[in] val + * + * @see elm_progressbar_part_value_set + * + * @ingroup Progressbar + */ +#define elm_obj_progressbar_part_value_set(part, val) ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_SET), EO_TYPECHECK(const char*, part), EO_TYPECHECK(double, val) + +/** + * @def elm_progressbar_part_value_get + * @since 1.8 + * + * Modified to support more than one progress status + * Get the value of the progress status of a particular part + * + * @param[in] part + * @param[out] ret + * + * @see elm_progressbar_part_value_get + * + * @ingroup Progressbar + */ +#define elm_obj_progressbar_part_value_get(part, ret) ELM_OBJ_PROGRESSBAR_ID(ELM_OBJ_PROGRESSBAR_SUB_ID_PART_VALUE_GET), EO_TYPECHECK(const char*, part), EO_TYPECHECK(double *, ret) diff --git a/legacy/elementary/src/lib/elm_progressbar_legacy.h b/legacy/elementary/src/lib/elm_progressbar_legacy.h index 492654d..89667e6 100644 --- a/legacy/elementary/src/lib/elm_progressbar_legacy.h +++ b/legacy/elementary/src/lib/elm_progressbar_legacy.h @@ -249,3 +249,36 @@ EAPI void elm_progressbar_inverted_set(Evas_Object *obj, * @ingroup Progressbar */ EAPI Eina_Bool elm_progressbar_inverted_get(const Evas_Object *obj); + +/** + * Set the progress value (in percentage) on a given progress bar + * widget for the given part name + * + * @since 1.8 + * + * @param obj The progress bar object + * @param part The partname to which val have to set + * @param val The progress value (@b must be between @c 0.0 and @c + * 1.0) + * + * Use this call to set progress bar status for more than one progress status . + * + * @ingroup Progressbar + */ +EAPI void elm_progressbar_part_value_set(Evas_Object *obj, const char *part, double val); + +/** + * Get the progress value (in percentage) on a given progress bar + * widget for a particular part + * + * @since 1.8 + * + * @param obj The progress bar object + * @param part The part name of the progress bar + * @return The value of the progressbar + * + * @see elm_progressbar_value_set() for more details + * + * @ingroup Progressbar + */ +EAPI double elm_progressbar_part_value_get(const Evas_Object *obj, const char *part); diff --git a/legacy/elementary/src/lib/elm_widget_progressbar.h b/legacy/elementary/src/lib/elm_widget_progressbar.h index 3747a17..20d7812 100644 --- a/legacy/elementary/src/lib/elm_widget_progressbar.h +++ b/legacy/elementary/src/lib/elm_widget_progressbar.h @@ -18,6 +18,8 @@ * Base layout smart data extended with progressbar instance data. */ typedef struct _Elm_Progressbar_Smart_Data Elm_Progressbar_Smart_Data; +typedef struct _Elm_Progress_Status Elm_Progress_Status; + struct _Elm_Progressbar_Smart_Data { Evas_Object *spacer; @@ -30,11 +32,18 @@ struct _Elm_Progressbar_Smart_Data Eina_Bool inverted : 1; Eina_Bool pulse : 1; Eina_Bool pulse_state : 1; + Eina_List *progress_status; char *(*unit_format_func)(double val); void (*unit_format_free)(char *str); }; +struct _Elm_Progress_Status +{ + const char *part_name; + double val; +}; + /** * @} */ -- 2.7.4