summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2005-10-29 11:51:19 +0000
committerCarsten Haitzler <raster@rasterman.com>2005-10-29 11:51:19 +0000
commit6890023f7145e52ba1803495bd8177f9031673de (patch)
treeb8106f48e1f7090cd38f4271666d2748ce7e7d95 /src
parentd329126dea516dc6b4f5952c474b3975cd73014d (diff)
a scrollview smart plus gfx for it.
SVN revision: 18103
Diffstat (limited to 'src')
-rw-r--r--src/bin/Makefile.am2
-rw-r--r--src/bin/e_includes.h1
-rw-r--r--src/bin/e_intl.c1
-rw-r--r--src/bin/e_pan.c12
-rw-r--r--src/bin/e_pan.h16
-rw-r--r--src/bin/e_scrollframe.c611
-rw-r--r--src/bin/e_scrollframe.h30
-rw-r--r--src/bin/e_test.c25
8 files changed, 683 insertions, 15 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index af9e52a..6c298a6 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -106,6 +106,7 @@ e_int_border_remember.h \
106e_eap_editor.h \ 106e_eap_editor.h \
107e_widget_iconsel.h \ 107e_widget_iconsel.h \
108e_widget_fileman.h \ 108e_widget_fileman.h \
109e_scrollframe.h \
109e_file_selector.h \ 110e_file_selector.h \
110e_file_dialog.h 111e_file_dialog.h
111 112
@@ -194,6 +195,7 @@ e_int_border_remember.c \
194e_eap_editor.c \ 195e_eap_editor.c \
195e_widget_iconsel.c \ 196e_widget_iconsel.c \
196e_widget_fileman.c \ 197e_widget_fileman.c \
198e_scrollframe.c \
197e_file_selector.c \ 199e_file_selector.c \
198e_file_dialog.c \ 200e_file_dialog.c \
199$(ENLIGHTENMENTHEADERS) 201$(ENLIGHTENMENTHEADERS)
diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h
index 2f528f4..dd5ee82 100644
--- a/src/bin/e_includes.h
+++ b/src/bin/e_includes.h
@@ -84,6 +84,7 @@
84#include "e_thumb.h" 84#include "e_thumb.h"
85#include "e_int_border_remember.h" 85#include "e_int_border_remember.h"
86#include "e_eap_editor.h" 86#include "e_eap_editor.h"
87#include "e_scrollframe.h"
87#include "e_file_selector.h" 88#include "e_file_selector.h"
88#include "e_file_dialog.h" 89#include "e_file_dialog.h"
89#include "e_widget_fileman.h" 90#include "e_widget_fileman.h"
diff --git a/src/bin/e_intl.c b/src/bin/e_intl.c
index e41c46a..713d6c6 100644
--- a/src/bin/e_intl.c
+++ b/src/bin/e_intl.c
@@ -85,6 +85,7 @@ e_intl_init(void)
85 ADD_LANG("sk_SK.UTF-8"); 85 ADD_LANG("sk_SK.UTF-8");
86 ADD_LANG("sv_SV.UTF-8"); 86 ADD_LANG("sv_SV.UTF-8");
87 ADD_LANG("nb_NO.UTF-8"); 87 ADD_LANG("nb_NO.UTF-8");
88 ADD_LANG("nl_NL.UTF-8");
88 89
89 _e_intl_input_method_config_edd = E_CONFIG_DD_NEW("input_method_config", E_Input_Method_Config); 90 _e_intl_input_method_config_edd = E_CONFIG_DD_NEW("input_method_config", E_Input_Method_Config);
90 E_CONFIG_VAL(_e_intl_input_method_config_edd, E_Input_Method_Config, version, INT); 91 E_CONFIG_VAL(_e_intl_input_method_config_edd, E_Input_Method_Config, version, INT);
diff --git a/src/bin/e_pan.c b/src/bin/e_pan.c
index abe0bfc..34f9479 100644
--- a/src/bin/e_pan.c
+++ b/src/bin/e_pan.c
@@ -89,13 +89,13 @@ void
89e_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) 89e_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
90{ 90{
91 API_ENTRY return; 91 API_ENTRY return;
92 sd->px = x; 92 if (x > (sd->child_w - sd->w)) x = sd->child_w - sd->w;
93 sd->py = y; 93 if (y > (sd->child_h - sd->h)) y = sd->child_h - sd->h;
94 if (x > (sd->w - sd->child_w)) x = sd->w - sd->child_w;
95 if (y > (sd->h - sd->child_h)) y = sd->h - sd->child_h;
96 if (x < 0) x = 0; 94 if (x < 0) x = 0;
97 if (y < 0) y = 0; 95 if (y < 0) y = 0;
98 if ((x == sd->px) && (y == sd->py)) return; 96 if ((x == sd->px) && (y == sd->py)) return;
97 sd->px = x;
98 sd->py = y;
99 _e_smart_reconfigure(sd); 99 _e_smart_reconfigure(sd);
100 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL); 100 evas_object_smart_callback_call(sd->smart_obj, "changed", NULL);
101} 101}
@@ -114,12 +114,12 @@ e_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
114 API_ENTRY return; 114 API_ENTRY return;
115 if (x) 115 if (x)
116 { 116 {
117 if (sd->w > sd->child_w) *x = sd->w - sd->child_w; 117 if (sd->w < sd->child_w) *x = sd->child_w - sd->w;
118 else *x = 0; 118 else *x = 0;
119 } 119 }
120 if (y) 120 if (y)
121 { 121 {
122 if (sd->h > sd->child_h) *y = sd->h - sd->child_h; 122 if (sd->h < sd->child_h) *y = sd->child_h - sd->h;
123 else *y = 0; 123 else *y = 0;
124 } 124 }
125} 125}
diff --git a/src/bin/e_pan.h b/src/bin/e_pan.h
index 64e742e..bff3736 100644
--- a/src/bin/e_pan.h
+++ b/src/bin/e_pan.h
@@ -6,15 +6,13 @@
6#ifndef E_PAN_H 6#ifndef E_PAN_H
7#define E_PAN_H 7#define E_PAN_H
8 8
9EAPI Evas_Object *e_pan_add(Evas *evas); 9EAPI Evas_Object *e_pan_add (Evas *evas);
10void e_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y); 10EAPI void e_pan_child_set (Evas_Object *obj, Evas_Object *child);
11void e_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); 11EAPI Evas_Object *e_pan_child_get (Evas_Object *obj);
12void e_pan_child_set(Evas_Object *obj, Evas_Object *child); 12EAPI void e_pan_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
13Evas_Object *e_pan_child_get(Evas_Object *obj); 13EAPI void e_pan_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
14void e_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y); 14EAPI void e_pan_max_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
15void e_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); 15EAPI void e_pan_child_size_get (Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
16void e_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
17void e_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
18 16
19#endif 17#endif
20#endif 18#endif
diff --git a/src/bin/e_scrollframe.c b/src/bin/e_scrollframe.c
new file mode 100644
index 0000000..33d5854
--- /dev/null
+++ b/src/bin/e_scrollframe.c
@@ -0,0 +1,611 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include "e.h"
5
6#define SMART_NAME "e_scrollframe"
7#define API_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if ((!obj) || (!sd) || (evas_object_type_get(obj) && strcmp(evas_object_type_get(obj), SMART_NAME)))
8#define INTERNAL_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
9typedef struct _E_Smart_Data E_Smart_Data;
10
11struct _E_Smart_Data
12{
13 Evas_Coord x, y, w, h;
14
15 Evas_Object *smart_obj;
16 Evas_Object *child_obj;
17 Evas_Object *pan_obj;
18 Evas_Object *edje_obj;
19 Evas_Object *event_obj;
20
21 E_Scrollframe_Policy hbar_flags, vbar_flags;
22
23 struct {
24 Evas_Coord w, h;
25 } child;
26 struct {
27 Evas_Coord x, y;
28 } step, page;
29
30 unsigned char hbar_visible : 1;
31 unsigned char vbar_visible : 1;
32};
33
34/* local subsystem functions */
35static void _e_smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
36static void _e_smart_child_resize_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
37static void _e_smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info);
38static void _e_smart_edje_drag_v(void *data, Evas_Object *obj, const char *emission, const char *source);
39static void _e_smart_edje_drag_h(void *data, Evas_Object *obj, const char *emission, const char *source);
40static void _e_smart_scrollbar_read(E_Smart_Data *sd);
41static void _e_smart_scrollbar_reset(E_Smart_Data *sd);
42static int _e_smart_scrollbar_bar_h_visibility_adjust(E_Smart_Data *sd);
43static int _e_smart_scrollbar_bar_v_visibility_adjust(E_Smart_Data *sd);
44static void _e_smart_scrollbar_bar_visibility_adjust(E_Smart_Data *sd);
45static void _e_smart_scrollbar_size_adjust(E_Smart_Data *sd);
46static void _e_smart_reconfigure(E_Smart_Data *sd);
47static void _e_smart_add(Evas_Object *obj);
48static void _e_smart_del(Evas_Object *obj);
49static void _e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
50static void _e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
51static void _e_smart_show(Evas_Object *obj);
52static void _e_smart_hide(Evas_Object *obj);
53static void _e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
54static void _e_smart_clip_set(Evas_Object *obj, Evas_Object * clip);
55static void _e_smart_clip_unset(Evas_Object *obj);
56static void _e_smart_init(void);
57
58/* local subsystem globals */
59static Evas_Smart *_e_smart = NULL;
60
61/* externally accessible functions */
62Evas_Object *
63e_scrollframe_add(Evas *evas)
64{
65 _e_smart_init();
66 return evas_object_smart_add(evas, _e_smart);
67}
68
69void
70e_scrollframe_child_set(Evas_Object *obj, Evas_Object *child)
71{
72 Evas_Coord w, h;
73
74 API_ENTRY return;
75 if (sd->child_obj)
76 {
77 e_pan_child_set(sd->pan_obj, NULL);
78 evas_object_event_callback_del(sd->child_obj, EVAS_CALLBACK_FREE, _e_smart_child_del_hook);
79 evas_object_event_callback_del(sd->child_obj, EVAS_CALLBACK_RESIZE, _e_smart_child_resize_hook);
80 }
81
82 sd->child_obj = child;
83 if (!child) return;
84
85 evas_object_event_callback_add(child, EVAS_CALLBACK_FREE, _e_smart_child_del_hook, sd);
86 evas_object_event_callback_add(child, EVAS_CALLBACK_RESIZE, _e_smart_child_resize_hook, sd);
87 evas_object_geometry_get(child, NULL, NULL, &w, &h);
88 sd->child.w = w;
89 sd->child.h = h;
90 e_pan_child_set(sd->pan_obj, sd->child_obj);
91 _e_smart_scrollbar_size_adjust(sd);
92 _e_smart_scrollbar_reset(sd);
93}
94
95void
96e_scrollframe_child_pos_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
97{
98 Evas_Coord mx = 0, my = 0;
99 double vx, vy;
100
101 API_ENTRY return;
102 e_pan_max_get(sd->pan_obj, &mx, &my);
103 if (mx > 0) vx = (double)x / (double)mx;
104 else vx = 0.0;
105 if (vx < 0.0) vx = 0.0;
106 else if (vx > 1.0) vx = 1.0;
107 if (my > 0) vy = (double)y / (double)my;
108 else vy = 0.0;
109 if (vy < 0.0) vy = 0.0;
110 else if (vy > 1.0) vy = 1.0;
111 edje_object_part_drag_value_set(sd->edje_obj, "vbar_bar", 0.0, vy);
112 edje_object_part_drag_value_set(sd->edje_obj, "hbar_bar", vx, 0.0);
113 e_pan_set(sd->pan_obj, x, y);
114}
115
116void
117e_scrollframe_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
118{
119 API_ENTRY return;
120 e_pan_get(sd->pan_obj, x, y);
121}
122
123void
124e_scrollframe_child_viewport_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
125{
126 API_ENTRY return;
127 evas_object_geometry_get(sd->pan_obj, NULL, NULL, w, h);
128}
129
130void
131e_scrollframe_step_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
132{
133 API_ENTRY return;
134 if (x < 1) x = 1;
135 if (y < 1) y = 1;
136 sd->step.x = x;
137 sd->step.y = y;
138 _e_smart_scrollbar_size_adjust(sd);
139}
140
141void
142e_scrollframe_step_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
143{
144 API_ENTRY return;
145 if (x) *x = sd->step.x;
146 if (y) *y = sd->step.y;
147}
148
149void
150e_scrollframe_page_size_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
151{
152 API_ENTRY return;
153 sd->page.x = x;
154 sd->page.y = y;
155 _e_smart_scrollbar_size_adjust(sd);
156}
157
158void
159e_scrollframe_page_size_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
160{
161 API_ENTRY return;
162 if (x) *x = sd->page.x;
163 if (y) *y = sd->page.y;
164}
165
166void
167e_scrollframe_policy_set(Evas_Object *obj, E_Scrollframe_Policy hbar, E_Scrollframe_Policy vbar)
168{
169 API_ENTRY return;
170 if ((sd->hbar_flags == hbar) && (sd->vbar_flags == vbar)) return;
171 sd->hbar_flags = hbar;
172 sd->vbar_flags = vbar;
173 _e_smart_scrollbar_size_adjust(sd);
174}
175
176void
177e_scrollframe_policy_get(Evas_Object *obj, E_Scrollframe_Policy *hbar, E_Scrollframe_Policy *vbar)
178{
179 API_ENTRY return;
180 if (hbar) *hbar = sd->hbar_flags;
181 if (vbar) *vbar = sd->vbar_flags;
182}
183
184/* local subsystem functions */
185static void
186_e_smart_edje_drag_v(void *data, Evas_Object *obj, const char *emission, const char *source)
187{
188 E_Smart_Data *sd;
189
190 sd = data;
191 _e_smart_scrollbar_read(sd);
192}
193
194static void
195_e_smart_edje_drag_h(void *data, Evas_Object *obj, const char *emission, const char *source)
196{
197 E_Smart_Data *sd;
198
199 sd = data;
200 _e_smart_scrollbar_read(sd);
201}
202
203static void
204_e_smart_child_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
205{
206 E_Smart_Data *sd;
207
208 sd = data;
209 sd->child_obj = NULL;
210 _e_smart_scrollbar_size_adjust(sd);
211 _e_smart_scrollbar_reset(sd);
212}
213
214static void
215_e_smart_child_resize_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
216{
217 Evas_Coord w, h;
218 E_Smart_Data *sd;
219
220 sd = data;
221 evas_object_geometry_get(sd->child_obj, NULL, NULL, &w, &h);
222 if ((w != sd->child.w) || (h != sd->child.h))
223 {
224 sd->child.w = w;
225 sd->child.h = h;
226 _e_smart_scrollbar_size_adjust(sd);
227 }
228}
229
230static void
231_e_smart_event_wheel(void *data, Evas *e, Evas_Object *obj, void *event_info)
232{
233 Evas_Event_Mouse_Wheel *ev;
234 E_Smart_Data *sd;
235 Evas_Coord x = 0, y = 0;
236
237 sd = data;
238 ev = event_info;
239 e_scrollframe_child_pos_get(sd->smart_obj, &x, &y);
240 y += ev->z * sd->step.y;
241 e_scrollframe_child_pos_set(sd->smart_obj, x, y);
242}
243
244static void
245_e_smart_scrollbar_read(E_Smart_Data *sd)
246{
247 Evas_Coord x, y, mx = 0, my = 0;
248 double vx, vy;
249
250 edje_object_part_drag_value_get(sd->edje_obj, "vbar_bar", NULL, &vy);
251 edje_object_part_drag_value_get(sd->edje_obj, "hbar_bar", &vx, NULL);
252 e_pan_max_get(sd->pan_obj, &mx, &my);
253 x = vx * (double)mx;
254 y = vy * (double)my;
255 e_pan_set(sd->pan_obj, x, y);
256}
257
258static void
259_e_smart_scrollbar_reset(E_Smart_Data *sd)
260{
261 edje_object_part_drag_value_set(sd->edje_obj, "vbar_bar", 0.0, 0.0);
262 edje_object_part_drag_value_set(sd->edje_obj, "hbar_bar", 0.0, 0.0);
263 if (!sd->child_obj)
264 {
265 edje_object_part_drag_size_set(sd->edje_obj, "vbar_bar", 1.0, 1.0);
266 edje_object_part_drag_size_set(sd->edje_obj, "hbar_bar", 1.0, 1.0);
267 }
268 e_pan_set(sd->pan_obj, 0, 0);
269}
270
271static int
272_e_smart_scrollbar_bar_v_visibility_adjust(E_Smart_Data *sd)
273{
274 int scroll_v_vis_change = 0;
275 Evas_Coord w, h, vw, vh;
276
277 w = sd->child.w;
278 h = sd->child.h;
279 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
280 if (sd->vbar_visible)
281 {
282 if (sd->vbar_flags == E_SCROLLFRAME_POLICY_AUTO)
283 {
284 if (sd->child_obj)
285 {
286 if (h <= vh)
287 {
288 scroll_v_vis_change = 1;
289 sd->vbar_visible = 0;
290 }
291 }
292 else
293 {
294 scroll_v_vis_change = 1;
295 sd->vbar_visible = 0;
296 }
297 }
298 else if (sd->vbar_flags == E_SCROLLFRAME_POLICY_OFF)
299 {
300 scroll_v_vis_change = 1;
301 sd->vbar_visible = 0;
302 }
303 }
304 else
305 {
306 if (sd->vbar_flags == E_SCROLLFRAME_POLICY_AUTO)
307 {
308 if (sd->child_obj)
309 {
310 if (h > vh)
311 {
312 scroll_v_vis_change = 1;
313 sd->vbar_visible = 1;
314 }
315 }
316 }
317 else if (sd->vbar_flags == E_SCROLLFRAME_POLICY_ON)
318 {
319 scroll_v_vis_change = 1;
320 sd->vbar_visible = 1;
321 }
322 }
323 if (scroll_v_vis_change)
324 {
325 if (sd->vbar_visible)
326 edje_object_signal_emit(sd->edje_obj, "vbar", "show");
327 else
328 edje_object_signal_emit(sd->edje_obj, "vbar", "hide");
329 edje_object_message_signal_process(sd->edje_obj);
330 _e_smart_scrollbar_size_adjust(sd);
331 }
332 return scroll_v_vis_change;
333}
334
335static int
336_e_smart_scrollbar_bar_h_visibility_adjust(E_Smart_Data *sd)
337{
338 int scroll_h_vis_change = 0;
339 Evas_Coord w, h, vw, vh;
340
341 w = sd->child.w;
342 h = sd->child.h;
343 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
344 if (sd->hbar_visible)
345 {
346 if (sd->hbar_flags == E_SCROLLFRAME_POLICY_AUTO)
347 {
348 if (sd->child_obj)
349 {
350 if (w <= vw)
351 {
352 scroll_h_vis_change = 1;
353 sd->hbar_visible = 0;
354 }
355 }
356 else
357 {
358 scroll_h_vis_change = 1;
359 sd->hbar_visible = 0;
360 }
361 }
362 else if (sd->hbar_flags == E_SCROLLFRAME_POLICY_OFF)
363 {
364 scroll_h_vis_change = 1;
365 sd->hbar_visible = 0;
366 }
367 }
368 else
369 {
370 if (sd->hbar_flags == E_SCROLLFRAME_POLICY_AUTO)
371 {
372 if (sd->child_obj)
373 {
374 if (w > vw)
375 {
376 scroll_h_vis_change = 1;
377 sd->hbar_visible = 1;
378 }
379 }
380 }
381 else if (sd->hbar_flags == E_SCROLLFRAME_POLICY_ON)
382 {
383 scroll_h_vis_change = 1;
384 sd->hbar_visible = 1;
385 }
386 }
387 if (scroll_h_vis_change)
388 {
389 if (sd->hbar_visible)
390 edje_object_signal_emit(sd->edje_obj, "hbar", "show");
391 else
392 edje_object_signal_emit(sd->edje_obj, "hbar", "hide");
393 edje_object_message_signal_process(sd->edje_obj);
394 _e_smart_scrollbar_size_adjust(sd);
395 }
396 return scroll_h_vis_change;
397}
398
399static void
400_e_smart_scrollbar_bar_visibility_adjust(E_Smart_Data *sd)
401{
402 int changed = 0;
403
404 changed |= _e_smart_scrollbar_bar_h_visibility_adjust(sd);
405 changed |= _e_smart_scrollbar_bar_v_visibility_adjust(sd);
406 if (changed)
407 {
408 _e_smart_scrollbar_bar_h_visibility_adjust(sd);
409 _e_smart_scrollbar_bar_v_visibility_adjust(sd);
410 }
411}
412
413static void
414_e_smart_scrollbar_size_adjust(E_Smart_Data *sd)
415{
416 if (sd->child_obj)
417 {
418 Evas_Coord x, y, w, h, mx = 0, my = 0, vw = 0, vh = 0;
419 double vx, vy, size;
420
421 evas_object_geometry_get(sd->pan_obj, NULL, NULL, &vw, &vh);
422 w = sd->child.w;
423 if (w < 1) w = 1;
424 size = (double)vw / (double)w;
425 if (size > 1.0)
426 {
427 size = 1.0;
428 edje_object_part_drag_value_set(sd->edje_obj, "hbar_bar", 0.0, 0.0);
429 }
430 edje_object_part_drag_size_set(sd->edje_obj, "hbar_bar", size, 1.0);
431
432 h = sd->child.h;
433 if (h < 1) h = 1;
434 size = (double)vh / (double)h;
435 if (size > 1.0)
436 {
437 size = 1.0;
438 edje_object_part_drag_value_set(sd->edje_obj, "vbar_bar", 0.0, 0.0);
439 }
440 edje_object_part_drag_size_set(sd->edje_obj, "vbar_bar", 1.0, size);
441
442 edje_object_part_drag_value_get(sd->edje_obj, "hbar_bar", &vx, NULL);
443 edje_object_part_drag_value_get(sd->edje_obj, "vbar_bar", NULL, &vy);
444 e_pan_max_get(sd->pan_obj, &mx, &my);
445 x = vx * mx;
446 y = vy * my;
447
448 edje_object_part_drag_step_set(sd->edje_obj, "hbar_bar", (double)sd->step.x / (double)w, 0.0);
449 edje_object_part_drag_step_set(sd->edje_obj, "vbar_bar", 0.0, (double)sd->step.y / (double)h);
450 if (sd->page.x > 0)
451 edje_object_part_drag_page_set(sd->edje_obj, "hbar_bar", (double)sd->page.x / (double)w, 0.0);
452 else
453 edje_object_part_drag_page_set(sd->edje_obj, "hbar_bar", -((double)sd->page.x * ((double)vw / (double)w)) / 100.0, 0.0);
454 if (sd->page.y > 0)
455 edje_object_part_drag_page_set(sd->edje_obj, "vbar_bar", 0.0, (double)sd->page.y / (double)h);
456 else
457 edje_object_part_drag_page_set(sd->edje_obj, "vbar_bar", 0.0, -((double)sd->page.y * ((double)vh / (double)h)) / 100.0);
458
459 e_pan_set(sd->pan_obj, x, y);
460 }
461 else
462 {
463 edje_object_part_drag_size_set(sd->edje_obj, "vbar_bar", 1.0, 1.0);
464 edje_object_part_drag_size_set(sd->edje_obj, "hbar_bar", 1.0, 1.0);
465 e_pan_set(sd->pan_obj, 0, 0);
466 }
467 _e_smart_scrollbar_bar_visibility_adjust(sd);
468}
469
470static void
471_e_smart_reconfigure(E_Smart_Data *sd)
472{
473 evas_object_move(sd->edje_obj, sd->x, sd->y);
474 evas_object_resize(sd->edje_obj, sd->w, sd->h);
475 evas_object_move(sd->event_obj, sd->x, sd->y);
476 evas_object_resize(sd->event_obj, sd->w, sd->h);
477 _e_smart_scrollbar_size_adjust(sd);
478}
479
480static void
481_e_smart_add(Evas_Object *obj)
482{
483 E_Smart_Data *sd;
484 Evas_Object *o;
485
486 sd = calloc(1, sizeof(E_Smart_Data));
487 if (!sd) return;
488 evas_object_smart_data_set(obj, sd);
489
490 sd->smart_obj = obj;
491 sd->x = 0;
492 sd->y = 0;
493 sd->w = 0;
494 sd->h = 0;
495 sd->step.x = 32;
496 sd->step.y = 32;
497 sd->page.x = -50;
498 sd->page.y = -50;
499 sd->hbar_flags = E_SCROLLFRAME_POLICY_AUTO;
500 sd->vbar_flags = E_SCROLLFRAME_POLICY_AUTO;
501 sd->hbar_visible = 1;
502 sd->vbar_visible = 1;
503
504 o = edje_object_add(evas_object_evas_get(obj));
505 sd->edje_obj = o;
506 e_theme_edje_object_set(o, "base/theme/widgets",
507 "widgets/scrollframe");
508 edje_object_signal_callback_add(o, "drag*", "vbar_bar", _e_smart_edje_drag_v, sd);
509 edje_object_signal_callback_add(o, "drag*", "hbar_bar", _e_smart_edje_drag_h, sd);
510 evas_object_smart_member_add(o, obj);
511
512 o = e_pan_add(evas_object_evas_get(obj));
513 sd->pan_obj = o;
514 evas_object_show(o);
515 edje_object_part_swallow(sd->edje_obj, "item", o);
516
517 o = evas_object_rectangle_add(evas_object_evas_get(obj));
518 sd->event_obj = o;
519 evas_object_color_set(o, 0, 0, 0, 0);
520 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_WHEEL, _e_smart_event_wheel, sd);
521 evas_object_smart_member_add(o, obj);
522 evas_object_repeat_events_set(o, 1);
523 evas_object_show(o);
524
525 _e_smart_scrollbar_reset(sd);
526}
527
528static void
529_e_smart_del(Evas_Object *obj)
530{
531 INTERNAL_ENTRY;
532 e_scrollframe_child_set(obj, NULL);
533 evas_object_del(sd->pan_obj);
534 evas_object_del(sd->edje_obj);
535 evas_object_del(sd->event_obj);
536 free(sd);
537}
538
539static void
540_e_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
541{
542 INTERNAL_ENTRY;
543 sd->x = x;
544 sd->y = y;
545 _e_smart_reconfigure(sd);
546}
547
548static void
549_e_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
550{
551 INTERNAL_ENTRY;
552 sd->w = w;
553 sd->h = h;
554 _e_smart_reconfigure(sd);
555}
556
557static void
558_e_smart_show(Evas_Object *obj)
559{
560 INTERNAL_ENTRY;
561 evas_object_show(sd->edje_obj);
562}
563
564static void
565_e_smart_hide(Evas_Object *obj)
566{
567 INTERNAL_ENTRY;
568 evas_object_hide(sd->edje_obj);
569}
570
571static void
572_e_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
573{
574 INTERNAL_ENTRY;
575 evas_object_color_set(sd->edje_obj, r, g, b, a);
576}
577
578static void
579_e_smart_clip_set(Evas_Object *obj, Evas_Object * clip)
580{
581 INTERNAL_ENTRY;
582 evas_object_clip_set(sd->edje_obj, clip);
583}
584
585static void
586_e_smart_clip_unset(Evas_Object *obj)
587{
588 INTERNAL_ENTRY;
589 evas_object_clip_unset(sd->edje_obj);
590}
591
592/* never need to touch this */
593
594static void
595_e_smart_init(void)
596{
597 if (_e_smart) return;
598 _e_smart = evas_smart_new(SMART_NAME,
599 _e_smart_add,
600 _e_smart_del,
601 NULL, NULL, NULL, NULL, NULL,
602 _e_smart_move,
603 _e_smart_resize,
604 _e_smart_show,
605 _e_smart_hide,
606 _e_smart_color_set,
607 _e_smart_clip_set,
608 _e_smart_clip_unset,
609 NULL);
610}
611
diff --git a/src/bin/e_scrollframe.h b/src/bin/e_scrollframe.h
new file mode 100644
index 0000000..b29df71
--- /dev/null
+++ b/src/bin/e_scrollframe.h
@@ -0,0 +1,30 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#ifdef E_TYPEDEFS
5#else
6#ifndef E_SCROLLFRAME_H
7#define E_SCROLLFRAME_H
8
9typedef enum _E_Scrollframe_Policy
10{
11 E_SCROLLFRAME_POLICY_OFF,
12 E_SCROLLFRAME_POLICY_ON,
13 E_SCROLLFRAME_POLICY_AUTO
14}
15E_Scrollframe_Policy;
16
17EAPI Evas_Object *e_scrollframe_add (Evas *evas);
18EAPI void e_scrollframe_child_set (Evas_Object *obj, Evas_Object *child);
19EAPI void e_scrollframe_child_pos_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
20EAPI void e_scrollframe_child_pos_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
21EAPI void e_scrollframe_child_viewport_size_get (Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
22EAPI void e_scrollframe_step_size_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
23EAPI void e_scrollframe_step_size_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
24EAPI void e_scrollframe_page_size_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y);
25EAPI void e_scrollframe_page_size_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y);
26EAPI void e_scrollframe_policy_set (Evas_Object *obj, E_Scrollframe_Policy hbar, E_Scrollframe_Policy vbar);
27EAPI void e_scrollframe_policy_get (Evas_Object *obj, E_Scrollframe_Policy *hbar, E_Scrollframe_Policy *vbar);
28
29#endif
30#endif
diff --git a/src/bin/e_test.c b/src/bin/e_test.c
index b9da9ee..d4769f8 100644
--- a/src/bin/e_test.c
+++ b/src/bin/e_test.c
@@ -307,6 +307,31 @@ _e_test_internal(E_Container *con)
307 e_win_centered_set(dia->win, 1); 307 e_win_centered_set(dia->win, 1);
308 e_dialog_show(dia); 308 e_dialog_show(dia);
309} 309}
310#elif 0
311static void
312_e_test_internal(E_Container *con)
313{
314 E_Dialog *dia;
315 Evas_Object *o, *o2;
316
317 dia = e_dialog_new(con);
318 e_dialog_title_set(dia, "A Test Dialog");
319
320 o = e_icon_add(dia->win->evas);
321 e_icon_file_set(o, "/home/raster/t.png");
322 evas_object_resize(o, 1024, 768);
323 evas_object_show(o);
324
325 o2 = e_scrollframe_add(dia->win->evas);
326 evas_object_resize(o2, 200, 300);
327 evas_object_show(o2);
328 e_scrollframe_child_set(o2, o);
329
330 e_dialog_content_set(dia, o2, 500, 300);
331 e_dialog_button_add(dia, "OK", NULL, NULL, NULL);
332 e_win_centered_set(dia->win, 1);
333 e_dialog_show(dia);
334}
310#else 335#else
311static void 336static void
312_e_test_internal(E_Container *con) 337_e_test_internal(E_Container *con)