aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/elementary/efl_page_indicator.c
blob: 6b0be267b21f976ca1f1bd984e0b92e6be08fd0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#include <Elementary.h>
#include "elm_priv.h"

#include "efl_page_indicator.h"
#include "efl_ui_widget_pager.h"

#define MY_CLASS EFL_PAGE_INDICATOR_CLASS



EOLIAN static void
_efl_page_indicator_update(Eo *obj EINA_UNUSED,
                           Efl_Page_Indicator_Data *pd,
                           double pos EINA_UNUSED)
{
   pd->curr_idx = efl_ui_pager_current_page_get(pd->pager.obj);
}

EOLIAN static void
_efl_page_indicator_pack(Eo *obj EINA_UNUSED,
                         Efl_Page_Indicator_Data *pd,
                         int index)
{
   pd->cnt++;
   if ((pd->curr_idx == -1) || (pd->curr_idx >= index)) pd->curr_idx++;
}

EOLIAN static void
_efl_page_indicator_unpack(Eo *obj EINA_UNUSED,
                           Efl_Page_Indicator_Data *pd,
                           int index)
{
   pd->cnt--;

   if ((pd->cnt == 0) ||
       ((index == pd->curr_idx) && (index != 0)) ||
       (index < pd->curr_idx))
     pd->curr_idx--;
}

EOLIAN static void
_efl_page_indicator_unpack_all(Eo *obj EINA_UNUSED,
                               Efl_Page_Indicator_Data *pd)
{
   pd->cnt = 0;
   pd->curr_idx = -1;
}

EOLIAN static void
_efl_page_indicator_bind(Eo *obj EINA_UNUSED,
                         Efl_Page_Indicator_Data *pd,
                         Eo *pager,
                         Efl_Canvas_Group *idbox)
{
   if (pd->pager.obj == pager) return;

   pd->pager.obj = pager;
   pd->idbox = idbox;

   if (pager)
     {
        pd->cnt = efl_content_count(pd->pager.obj);
        pd->curr_idx = efl_ui_pager_current_page_get(pd->pager.obj);
     }
   else
     {
        pd->cnt = 0;
        pd->curr_idx = -1;
     }
}


EOAPI EFL_VOID_FUNC_BODYV(efl_page_indicator_update,
                          EFL_FUNC_CALL(pos), double pos)
EOAPI EFL_VOID_FUNC_BODYV(efl_page_indicator_pack,
                          EFL_FUNC_CALL(index), int index)
EOAPI EFL_VOID_FUNC_BODYV(efl_page_indicator_unpack,
                          EFL_FUNC_CALL(index), int index)
EOAPI EFL_VOID_FUNC_BODY(efl_page_indicator_unpack_all)

#define EFL_PAGE_INDICATOR_EXTRA_OPS \
   EFL_OBJECT_OP_FUNC(efl_page_indicator_update, \
                      _efl_page_indicator_update), \
   EFL_OBJECT_OP_FUNC(efl_page_indicator_pack, \
                      _efl_page_indicator_pack), \
   EFL_OBJECT_OP_FUNC(efl_page_indicator_unpack, \
                      _efl_page_indicator_unpack), \
   EFL_OBJECT_OP_FUNC(efl_page_indicator_unpack_all, \
                      _efl_page_indicator_unpack_all)

#include "efl_page_indicator.eo.c"