summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2017-10-26 21:28:20 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2017-10-26 21:28:20 +0900
commit111caabf107bc032bf7432c152fd492a5295c6b0 (patch)
tree1625cb197abb68275e789c2f10d141d6d3f75290 /src/lib/elementary
parentde74fd11ba1b8afce81c89777d381016cee454ea (diff)
Efl.Ui.Progressbar: move legacy funcs at bottom of file
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/efl_ui_progressbar.c254
1 files changed, 128 insertions, 126 deletions
diff --git a/src/lib/elementary/efl_ui_progressbar.c b/src/lib/elementary/efl_ui_progressbar.c
index 32589fd32e..1b2042a7bc 100644
--- a/src/lib/elementary/efl_ui_progressbar.c
+++ b/src/lib/elementary/efl_ui_progressbar.c
@@ -342,16 +342,6 @@ _efl_ui_progressbar_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Progressbar_Data
342 efl_canvas_group_del(efl_super(obj, MY_CLASS)); 342 efl_canvas_group_del(efl_super(obj, MY_CLASS));
343} 343}
344 344
345EAPI Evas_Object *
346elm_progressbar_add(Evas_Object *parent)
347{
348 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
349 Eo *obj = efl_add(MY_CLASS, parent, efl_canvas_object_legacy_ctor(efl_added));
350 elm_progressbar_unit_format_set(obj, "%.0f %%");
351
352 return obj;
353}
354
355EOLIAN static Eo * 345EOLIAN static Eo *
356_efl_ui_progressbar_efl_object_constructor(Eo *obj, Efl_Ui_Progressbar_Data *_pd EINA_UNUSED) 346_efl_ui_progressbar_efl_object_constructor(Eo *obj, Efl_Ui_Progressbar_Data *_pd EINA_UNUSED)
357{ 347{
@@ -520,100 +510,109 @@ _efl_ui_progressbar_pulse_get(Eo *obj EINA_UNUSED, Efl_Ui_Progressbar_Data *sd)
520 return (sd->pulse_state && sd->pulse); 510 return (sd->pulse_state && sd->pulse);
521} 511}
522 512
523EAPI void 513EOLIAN static void
524elm_progressbar_value_set(Evas_Object *obj, double val) 514_efl_ui_progressbar_class_constructor(Efl_Class *klass)
525{ 515{
526 efl_ui_range_value_set(obj, val); 516 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
527} 517}
528 518
529EAPI double 519/* Efl.Part begin */
530elm_progressbar_value_get(const Evas_Object *obj) 520
521EOLIAN static Eo *
522_efl_ui_progressbar_efl_part_part(const Eo *obj, Efl_Ui_Progressbar_Data *sd EINA_UNUSED, const char *part)
531{ 523{
532 return efl_ui_range_value_get(obj); 524 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
525 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
526
527 // Progress bars are dragable types
528 if (edje_object_part_drag_dir_get(wd->resize_obj, part) != EFL_UI_DRAG_DIR_NONE)
529 return ELM_PART_IMPLEMENT(EFL_UI_PROGRESSBAR_PART_CLASS, obj, part);
530
531 return efl_part(efl_super(obj, MY_CLASS), part);
533} 532}
534 533
535EAPI void 534EOLIAN static void
536elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size) 535_efl_ui_progressbar_part_efl_ui_range_range_value_set(Eo *obj, void *_pd EINA_UNUSED, double val)
537{ 536{
538 EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd); 537 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
539 _progressbar_span_size_set(obj, sd, size); 538 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
539
540 _progressbar_part_value_set(pd->obj, sd, pd->part, val);
540} 541}
541 542
542EAPI Evas_Coord 543EOLIAN static double
543elm_progressbar_span_size_get(const Evas_Object *obj) 544_efl_ui_progressbar_part_efl_ui_range_range_value_get(Eo *obj, void *_pd EINA_UNUSED)
544{ 545{
545 EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, 0); 546 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
546 return sd->size; 547 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
548
549 return _progressbar_part_value_get(sd, pd->part);
547} 550}
548 551
549EAPI void 552#include "efl_ui_progressbar_part.eo.c"
550elm_progressbar_unit_format_set(Evas_Object *obj, const char *units)
551{
552 EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
553 553
554 sd->is_legacy_format = EINA_TRUE; 554/* Efl.Part end */
555 555
556 efl_ui_format_string_set(obj, units); 556/* Internal EO APIs and hidden overrides */
557}
558 557
559EAPI const char * 558ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(efl_ui_progressbar)
560elm_progressbar_unit_format_get(const Evas_Object *obj) 559ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(efl_ui_progressbar)
561{
562 return efl_ui_format_string_get(obj);
563}
564 560
565typedef struct 561#define EFL_UI_PROGRESSBAR_EXTRA_OPS \
566{ 562 ELM_LAYOUT_CONTENT_ALIASES_OPS(efl_ui_progressbar), \
567 progressbar_func_type format_cb; 563 ELM_LAYOUT_TEXT_ALIASES_OPS(efl_ui_progressbar), \
568 progressbar_freefunc_type format_free_cb; 564 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_progressbar), \
569} Pb_Format_Wrapper_Data; 565 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_progressbar)
570 566
571static void 567#include "efl_ui_progressbar.eo.c"
572_format_legacy_to_format_eo_cb(void *data, Eina_Strbuf *str, const Eina_Value value) 568
569/* Legacy APIs */
570
571EAPI Evas_Object *
572elm_progressbar_add(Evas_Object *parent)
573{ 573{
574 Pb_Format_Wrapper_Data *pfwd = data; 574 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
575 char *buf = NULL; 575 Eo *obj = efl_add(MY_CLASS, parent, efl_canvas_object_legacy_ctor(efl_added));
576 double val = 0; 576 elm_progressbar_unit_format_set(obj, "%.0f %%");
577 const Eina_Value_Type *type = eina_value_type_get(&value);
578 577
579 if (type == EINA_VALUE_TYPE_DOUBLE) 578 return obj;
580 eina_value_get(&value, &val); 579}
581 580
582 if (pfwd->format_cb) 581EAPI void
583 buf = pfwd->format_cb(val); 582elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse)
584 if (buf) 583{
585 eina_strbuf_append(str, buf); 584 efl_ui_progressbar_pulse_mode_set(obj, pulse);
586 if (pfwd->format_free_cb) pfwd->format_free_cb(buf);
587} 585}
588 586
589static void 587EAPI Eina_Bool
590_format_legacy_to_format_eo_free_cb(void *data) 588elm_progressbar_pulse_get(const Evas_Object *obj)
591{ 589{
592 Pb_Format_Wrapper_Data *pfwd = data; 590 return efl_ui_progressbar_pulse_mode_get(obj);
593 free(pfwd);
594} 591}
595 592
596EAPI void 593EAPI void
597elm_progressbar_unit_format_function_set(Evas_Object *obj, progressbar_func_type func, progressbar_freefunc_type free_func) 594elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state)
598{ 595{
599 Pb_Format_Wrapper_Data *pfwd = malloc(sizeof(Pb_Format_Wrapper_Data)); 596 efl_ui_progressbar_pulse_set(obj, state);
600 597}
601 pfwd->format_cb = func;
602 pfwd->format_free_cb = free_func;
603 598
604 efl_ui_format_cb_set(obj, pfwd, _format_legacy_to_format_eo_cb, 599EAPI Eina_Bool
605 _format_legacy_to_format_eo_free_cb); 600elm_progressbar_is_pulsing_get(const Evas_Object *obj)
601{
602 return efl_ui_progressbar_pulse_get(obj);
606} 603}
607 604
608EAPI void 605EAPI void
609elm_progressbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) 606elm_progressbar_part_value_set(Evas_Object *obj, const char *part, double val)
610{ 607{
611 Efl_Ui_Dir dir; 608 if (EINA_DBL_EQ(efl_ui_range_value_get(efl_part(obj, part)), val)) return;
612 EFL_UI_PROGRESSBAR_DATA_GET(obj, sd); 609 efl_ui_range_value_set(efl_part(obj, part), val);
613 610}
614 dir = _direction_get(horizontal, _is_inverted(sd->dir));
615 611
616 efl_ui_direction_set(obj, dir); 612EAPI double
613elm_progressbar_part_value_get(const Evas_Object *obj, const char *part)
614{
615 return efl_ui_range_value_get(efl_part(obj, part));
617} 616}
618 617
619EAPI Eina_Bool 618EAPI Eina_Bool
@@ -645,95 +644,98 @@ elm_progressbar_inverted_get(const Evas_Object *obj)
645 return _is_inverted(dir); 644 return _is_inverted(dir);
646} 645}
647 646
648EOLIAN static void 647EAPI void
649_efl_ui_progressbar_class_constructor(Efl_Class *klass) 648elm_progressbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
650{ 649{
651 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass); 650 Efl_Ui_Dir dir;
651 EFL_UI_PROGRESSBAR_DATA_GET(obj, sd);
652
653 dir = _direction_get(horizontal, _is_inverted(sd->dir));
654
655 efl_ui_direction_set(obj, dir);
652} 656}
653 657
654/* Efl.Part begin */ 658typedef struct
659{
660 progressbar_func_type format_cb;
661 progressbar_freefunc_type format_free_cb;
662} Pb_Format_Wrapper_Data;
655 663
656EOLIAN static Eo * 664static void
657_efl_ui_progressbar_efl_part_part(const Eo *obj, Efl_Ui_Progressbar_Data *sd EINA_UNUSED, const char *part) 665_format_legacy_to_format_eo_cb(void *data, Eina_Strbuf *str, const Eina_Value value)
658{ 666{
659 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL); 667 Pb_Format_Wrapper_Data *pfwd = data;
660 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); 668 char *buf = NULL;
669 double val = 0;
670 const Eina_Value_Type *type = eina_value_type_get(&value);
661 671
662 // Progress bars are dragable types 672 if (type == EINA_VALUE_TYPE_DOUBLE)
663 if (edje_object_part_drag_dir_get(wd->resize_obj, part) != EFL_UI_DRAG_DIR_NONE) 673 eina_value_get(&value, &val);
664 return ELM_PART_IMPLEMENT(EFL_UI_PROGRESSBAR_PART_CLASS, obj, part);
665 674
666 return efl_part(efl_super(obj, MY_CLASS), part); 675 if (pfwd->format_cb)
676 buf = pfwd->format_cb(val);
677 if (buf)
678 eina_strbuf_append(str, buf);
679 if (pfwd->format_free_cb) pfwd->format_free_cb(buf);
667} 680}
668 681
669EOLIAN static void 682static void
670_efl_ui_progressbar_part_efl_ui_range_range_value_set(Eo *obj, void *_pd EINA_UNUSED, double val) 683_format_legacy_to_format_eo_free_cb(void *data)
671{ 684{
672 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS); 685 Pb_Format_Wrapper_Data *pfwd = data;
673 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS); 686 free(pfwd);
674
675 _progressbar_part_value_set(pd->obj, sd, pd->part, val);
676} 687}
677 688
678EOLIAN static double 689EAPI void
679_efl_ui_progressbar_part_efl_ui_range_range_value_get(Eo *obj, void *_pd EINA_UNUSED) 690elm_progressbar_unit_format_function_set(Evas_Object *obj, progressbar_func_type func, progressbar_freefunc_type free_func)
680{ 691{
681 Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS); 692 Pb_Format_Wrapper_Data *pfwd = malloc(sizeof(Pb_Format_Wrapper_Data));
682 Efl_Ui_Progressbar_Data *sd = efl_data_scope_get(pd->obj, EFL_UI_PROGRESSBAR_CLASS);
683
684 return _progressbar_part_value_get(sd, pd->part);
685}
686
687#include "efl_ui_progressbar_part.eo.c"
688
689/* Efl.Part end */
690
691/* Internal EO APIs and hidden overrides */
692
693ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(efl_ui_progressbar)
694ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(efl_ui_progressbar)
695 693
696#define EFL_UI_PROGRESSBAR_EXTRA_OPS \ 694 pfwd->format_cb = func;
697 ELM_LAYOUT_CONTENT_ALIASES_OPS(efl_ui_progressbar), \ 695 pfwd->format_free_cb = free_func;
698 ELM_LAYOUT_TEXT_ALIASES_OPS(efl_ui_progressbar), \
699 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_progressbar), \
700 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_progressbar)
701 696
702#include "efl_ui_progressbar.eo.c" 697 efl_ui_format_cb_set(obj, pfwd, _format_legacy_to_format_eo_cb,
698 _format_legacy_to_format_eo_free_cb);
699}
703 700
704EAPI void 701EAPI void
705elm_progressbar_pulse_set(Evas_Object *obj, Eina_Bool pulse) 702elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size)
706{ 703{
707 efl_ui_progressbar_pulse_mode_set(obj, pulse); 704 EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
705 _progressbar_span_size_set(obj, sd, size);
708} 706}
709 707
710EAPI Eina_Bool 708EAPI Evas_Coord
711elm_progressbar_pulse_get(const Evas_Object *obj) 709elm_progressbar_span_size_get(const Evas_Object *obj)
712{ 710{
713 return efl_ui_progressbar_pulse_mode_get(obj); 711 EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd, 0);
712 return sd->size;
714} 713}
715 714
716EAPI void 715EAPI void
717elm_progressbar_pulse(Evas_Object *obj, Eina_Bool state) 716elm_progressbar_unit_format_set(Evas_Object *obj, const char *units)
718{ 717{
719 efl_ui_progressbar_pulse_set(obj, state); 718 EFL_UI_PROGRESSBAR_DATA_GET_OR_RETURN(obj, sd);
719
720 sd->is_legacy_format = EINA_TRUE;
721
722 efl_ui_format_string_set(obj, units);
720} 723}
721 724
722EAPI Eina_Bool 725EAPI const char *
723elm_progressbar_is_pulsing_get(const Evas_Object *obj) 726elm_progressbar_unit_format_get(const Evas_Object *obj)
724{ 727{
725 return efl_ui_progressbar_pulse_get(obj); 728 return efl_ui_format_string_get(obj);
726} 729}
727 730
728EAPI void 731EAPI void
729elm_progressbar_part_value_set(Evas_Object *obj, const char *part, double val) 732elm_progressbar_value_set(Evas_Object *obj, double val)
730{ 733{
731 if (EINA_DBL_EQ(efl_ui_range_value_get(efl_part(obj, part)), val)) return; 734 efl_ui_range_value_set(obj, val);
732 efl_ui_range_value_set(efl_part(obj, part), val);
733} 735}
734 736
735EAPI double 737EAPI double
736elm_progressbar_part_value_get(const Evas_Object *obj, const char *part) 738elm_progressbar_value_get(const Evas_Object *obj)
737{ 739{
738 return efl_ui_range_value_get(efl_part(obj, part)); 740 return efl_ui_range_value_get(obj);
739} 741}