summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_panel.c
blob: 548516fe15c4af45c842cea23206b1335a8c6094 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define ELM_LAYOUT_PROTECTED

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

#define MY_CLASS EFL_UI_PANEL_CLASS

#define MY_CLASS_NAME "Efl_Ui_Panel"



EOLIAN static void
_efl_ui_panel_toggle(Eo *obj EINA_UNUSED, Efl_Ui_Panel_Data *sd)
{
   if (sd->state == EFL_UI_PANEL_STATE_CLOSED)
     {
        switch (sd->orient)
          {
           case EFL_ORIENT_LEFT:
              elm_interface_scrollable_region_bring_in(sd->scroller,
                                                       0, 0, sd->w, sd->h);
              break;
           case EFL_ORIENT_RIGHT:
           case EFL_ORIENT_UP:
           case EFL_ORIENT_DOWN:
              break;
          }
        sd->state = EFL_UI_PANEL_STATE_OPEN;
     }
   else if (sd->state == EFL_UI_PANEL_STATE_OPEN)
     {
        switch (sd->orient)
          {
           case EFL_ORIENT_LEFT:
              elm_interface_scrollable_region_bring_in(sd->scroller,
                                                       (sd->w * 0.8), 0, sd->w, sd->h);
              break;
           case EFL_ORIENT_RIGHT:
           case EFL_ORIENT_UP:
           case EFL_ORIENT_DOWN:
              break;
          }
        sd->state = EFL_UI_PANEL_STATE_CLOSED;
     }
}

EOLIAN static void
_efl_ui_panel_efl_orientation_orientation_set(Eo *obj EINA_UNUSED,
                                              Efl_Ui_Panel_Data *sd,
                                              Efl_Orient orient)
{
   if (sd->orient == orient) return;

   sd->orient = orient;
   //TODO change orientation

   switch (orient)
     {
      case EFL_ORIENT_LEFT:
      case EFL_ORIENT_RIGHT:
      case EFL_ORIENT_UP:
      case EFL_ORIENT_DOWN:
         break;
     }
}

EOLIAN static void
_efl_ui_panel_efl_gfx_visible_set(Eo *obj, Efl_Ui_Panel_Data *sd, Eina_Bool vis)
{
   efl_gfx_visible_set(efl_super(obj, MY_CLASS), vis);

   efl_gfx_visible_set(sd->scroller, vis);
   efl_gfx_visible_set(sd->box, vis);
   efl_gfx_visible_set(sd->content_table, vis);
   efl_gfx_visible_set(sd->content_spacer, vis);
   efl_gfx_visible_set(sd->event_spacer, vis);

   efl_gfx_visible_set(sd->event_block, vis);
}

EOLIAN static void
_efl_ui_panel_efl_gfx_position_set(Eo *obj, Efl_Ui_Panel_Data *sd,
                                   Evas_Coord x, Evas_Coord y)
{
   sd->x = x;
   sd->y = y;

   efl_gfx_position_set(efl_super(obj, MY_CLASS), x, y);

   efl_gfx_position_set(sd->scroller, x, y);
   efl_gfx_position_set(sd->event_block, x, y);
}

EOLIAN static void
_efl_ui_panel_efl_gfx_size_set(Eo *obj, Efl_Ui_Panel_Data *sd,
                               Evas_Coord w, Evas_Coord h)
{
   Evas_Coord content_w = w, content_h = h;

   sd->w = w;
   sd->h = h;

   efl_gfx_size_set(efl_super(obj, MY_CLASS), w, h);

   switch (sd->orient)
     {
      case EFL_ORIENT_LEFT:
      case EFL_ORIENT_RIGHT:
         content_w = w * 0.8;
         break;
      case EFL_ORIENT_UP:
      case EFL_ORIENT_DOWN:
         content_h = h * 0.8;
         break;
     }

   efl_gfx_size_set(sd->scroller, w, h);
   efl_gfx_size_set(sd->event_block, w, h);

   evas_object_size_hint_min_set(sd->content_spacer, content_w, content_h);
   evas_object_size_hint_min_set(sd->event_spacer, w, h);

   if (sd->state == EFL_UI_PANEL_STATE_CLOSED)
     {
        switch (sd->orient)
          {
           case EFL_ORIENT_LEFT:
              elm_interface_scrollable_content_region_show(sd->scroller,
                                                           content_w, 0, w, h);
              break;
           case EFL_ORIENT_RIGHT:
           case EFL_ORIENT_UP:
           case EFL_ORIENT_DOWN:
              break;
          }
     }
}

EOLIAN static Eina_Bool
_efl_ui_panel_efl_container_content_set(Eo *obj EINA_UNUSED, Efl_Ui_Panel_Data *sd,
                                        Evas_Object *content)
{
   if (sd->content == content) return EINA_TRUE;

   if (sd->content)
     elm_table_unpack(sd->content_table, sd->content);

   sd->content = content;
   elm_table_pack(sd->content_table, content, 0, 0, 1, 1);

   return EINA_TRUE;
}

EOLIAN static void
_efl_ui_panel_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Panel_Data *sd)
{
   /** in case of a left panel
     *
     * -------- scroller ---------
     * | --------- box --------- |
     * | | - table - - rect -- | |
     * | | | rect  | |       | | |
     * | | | / obj | |       | | |
     * | | --------- --------- | |
     * | ----------------------- |
     * ---------------------------
     */

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

   efl_canvas_group_add(efl_super(obj, MY_CLASS));
   elm_widget_sub_object_parent_add(obj);

   sd->orient = EFL_ORIENT_LEFT; // left panel by default
   sd->state = EFL_UI_PANEL_STATE_CLOSED; // closed by default

   sd->scroller = efl_add(ELM_SCROLLER_CLASS, obj);
   //TODO set "panel" style to the scroller
   elm_widget_sub_object_add(obj, sd->scroller);
   elm_interface_scrollable_bounce_allow_set(sd->scroller, EINA_FALSE, EINA_FALSE);
   elm_interface_scrollable_policy_set(sd->scroller, ELM_SCROLLER_POLICY_OFF,
                                       ELM_SCROLLER_POLICY_OFF);

   sd->box = efl_add(EFL_UI_BOX_CLASS, sd->scroller);
   efl_orientation_set(sd->box, EFL_ORIENT_RIGHT);
   elm_widget_sub_object_add(obj, sd->box);
   elm_object_content_set(sd->scroller, sd->box);

   sd->content_table = elm_table_add(sd->box);
   elm_widget_sub_object_add(obj, sd->content_table);
   efl_pack_end(sd->box, sd->content_table);

   sd->content_spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
   efl_gfx_color_set(sd->content_spacer, 0, 0, 0, 0);
   elm_table_pack(sd->content_table, sd->content_spacer, 0, 0, 1, 1);

   sd->event_spacer = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
   efl_gfx_color_set(sd->event_spacer, 0, 0, 0, 0);
   efl_pack_end(sd->box, sd->event_spacer);

   sd->event_block = efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_object_evas_get(obj));
   efl_gfx_color_set(sd->event_block, 0, 0, 0, 0);
}

EOLIAN static Eo *
_efl_ui_panel_efl_object_constructor(Eo *obj,
                                     Efl_Ui_Panel_Data *sd EINA_UNUSED)
{
   obj = efl_constructor(efl_super(obj, MY_CLASS));

   return obj;
}

#include "efl_ui_panel.eo.c"