aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries/winFang.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-12 02:47:54 +1000
committerDavid Walter Seikel2014-05-12 02:47:54 +1000
commita0f30eea71e05f114e6a708b07768995c884914c (patch)
tree5735ce1e4a072b6a15280e16d6c053cf0fd71b3d /src/libraries/winFang.c
parentMove the callback comments. (diff)
downloadSledjHamr-a0f30eea71e05f114e6a708b07768995c884914c.zip
SledjHamr-a0f30eea71e05f114e6a708b07768995c884914c.tar.gz
SledjHamr-a0f30eea71e05f114e6a708b07768995c884914c.tar.bz2
SledjHamr-a0f30eea71e05f114e6a708b07768995c884914c.tar.xz
Fix up winFang move and resize. Still more to fix here though.
Diffstat (limited to '')
-rw-r--r--src/libraries/winFang.c75
1 files changed, 45 insertions, 30 deletions
diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c
index d17d732..cd83291 100644
--- a/src/libraries/winFang.c
+++ b/src/libraries/winFang.c
@@ -1,24 +1,6 @@
1#include "winFang.h" 1#include "winFang.h"
2 2
3 3
4// Elm inlined image windows needs this to change focus on mouse click.
5// Evas style event callback.
6static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
7{
8 winFang *win = data;
9 Evas_Event_Mouse_Down *ev = event_info;
10
11 if (1 == ev->button)
12 {
13 Evas_Object *objs = evas_object_top_at_pointer_get(win->e);
14
15// TODO - This always returns the elm_win. So how the hell do you tell what got clicked on?
16printf("%s %s\n", evas_object_type_get(objs), evas_object_name_get(objs));
17
18 elm_object_focus_set(obj, EINA_TRUE);
19 }
20}
21
22static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 4static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
23{ 5{
24 Evas_Object *img = win->win, *test; 6 Evas_Object *img = win->win, *test;
@@ -40,7 +22,7 @@ static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Co
40 EINA_LIST_FOREACH(objs, this, test) 22 EINA_LIST_FOREACH(objs, this, test)
41 { 23 {
42 const char * name = evas_object_name_get(test); 24 const char * name = evas_object_name_get(test);
43 if (name && (strcmp("winFang", name) == 0)) 25 if (name && (strcmp(WF_LAYOUT, name) == 0))
44 i++; 26 i++;
45 } 27 }
46 if (2 <= i) 28 if (2 <= i)
@@ -72,7 +54,6 @@ static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Co
72 else if (i == 3) cy += win->h; 54 else if (i == 3) cy += win->h;
73 evas_object_move(win->hand[i], cx - 15, cy - 15); 55 evas_object_move(win->hand[i], cx - 15, cy - 15);
74 } 56 }
75 // TODO - This just stretches everything, we don't really want that.
76} 57}
77 58
78static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) 59static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
@@ -139,6 +120,28 @@ static void _onBgMove(void *data, Evas *evas, Evas_Object *obj, void *event_info
139 _checkWindowBounds(win, x, y, w, h); 120 _checkWindowBounds(win, x, y, w, h);
140} 121}
141 122
123static void _onBgUnclick(void *data, Evas *evas, Evas_Object *obj, void *event_info)
124{
125 Evas_Event_Mouse_Down *ev = event_info;
126
127 if (1 == ev->button)
128 {
129 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _onBgUnclick);
130 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove);
131 }
132}
133
134static void _onBgClick(void *data, Evas *evas, Evas_Object *obj, void *event_info)
135{
136 Evas_Event_Mouse_Down *ev = event_info;
137
138 if (1 == ev->button)
139 {
140 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP, _onBgUnclick, data);
141 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, data);
142 }
143}
144
142static void _on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 145static void _on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
143{ 146{
144 elm_exit(); 147 elm_exit();
@@ -165,6 +168,7 @@ void winFangShow(winFang *win)
165winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world) 168winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world)
166{ 169{
167 winFang *result; 170 winFang *result;
171 Evas_Object *obj;
168 char buf[PATH_MAX]; 172 char buf[PATH_MAX];
169 int i; 173 int i;
170 174
@@ -186,17 +190,28 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch
186 result->win = eo_add(ELM_OBJ_LAYOUT_CLASS, parent->win, 190 result->win = eo_add(ELM_OBJ_LAYOUT_CLASS, parent->win,
187 evas_obj_size_set(result->w, result->h), 191 evas_obj_size_set(result->w, result->h),
188 evas_obj_position_set(result->x, result->y), 192 evas_obj_position_set(result->x, result->y),
189 evas_obj_name_set("winFang"), 193 evas_obj_name_set(WF_LAYOUT),
190 elm_obj_layout_file_set(buf, "winFang/layout"), 194 elm_obj_layout_file_set(buf, WF_LAYOUT),
191 evas_obj_visibility_set(EINA_TRUE) 195 evas_obj_visibility_set(EINA_TRUE)
192 ); 196 );
193 result->e = evas_object_evas_get(result->win); 197 result->e = evas_object_evas_get(result->win);
194 198
195 // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets.
196 // According to the Elm inlined image window example, this is what's needed to.
197 evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, result);
198 evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, result);
199 199
200 // Something to catch clicks on the background, for moving the window.
201 // Cov Elm is uncooperative with this sort of thing, so we need to stick in a rectangle.
202 obj = eo_add(EVAS_OBJ_RECTANGLE_CLASS, result->win,
203 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
204 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
205 evas_obj_name_set(WF_UNDERLAY),
206 evas_obj_color_set(0, 0, 0, 0),
207 evas_obj_visibility_set(EINA_TRUE)
208 );
209 elm_object_part_content_set(result->win, WF_UNDERLAY, obj);
210 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _onBgClick, result);
211 eo_unref(obj);
212
213 if (title)
214 elm_object_part_text_set(result->win, WF_TITLE, title);
200/* 215/*
201 result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->win, 216 result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->win,
202 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), 217 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0),
@@ -209,6 +224,7 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch
209 elm_box_pack_end(result->box, result->title); 224 elm_box_pack_end(result->box, result->title);
210 eo_unref(result->title); 225 eo_unref(result->title);
211*/ 226*/
227
212/* 228/*
213 obj1 = eo_add(ELM_OBJ_SEPARATOR_CLASS, result->win, 229 obj1 = eo_add(ELM_OBJ_SEPARATOR_CLASS, result->win,
214 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), 230 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0),
@@ -220,17 +236,15 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch
220 eo_unref(obj1); 236 eo_unref(obj1);
221*/ 237*/
222 238
223 if (title)
224 elm_object_part_text_set(result->win, TITLE, title);
225
226 result->grid = eo_add(ELM_OBJ_GRID_CLASS, result->win, 239 result->grid = eo_add(ELM_OBJ_GRID_CLASS, result->win,
227 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), 240 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
228 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 241 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
242 evas_obj_name_set(WF_SWALLOW),
229 // TODO - Actually, this should be minus the size of the title stuff. 243 // TODO - Actually, this should be minus the size of the title stuff.
230 elm_obj_grid_size_set(result->w, result->h), 244 elm_obj_grid_size_set(result->w, result->h),
231 evas_obj_visibility_set(EINA_TRUE) 245 evas_obj_visibility_set(EINA_TRUE)
232 ); 246 );
233 elm_object_part_content_set(result->win, SWALLOW, result->grid); 247 elm_object_part_content_set(result->win, WF_SWALLOW, result->grid);
234 248
235 elm_layout_sizing_eval(result->win); 249 elm_layout_sizing_eval(result->win);
236 250
@@ -341,6 +355,7 @@ Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char
341 { 355 {
342 result->label = strdup(title); 356 result->label = strdup(title);
343 elm_object_text_set(result->obj, result->label); 357 elm_object_text_set(result->obj, result->label);
358 evas_object_name_set(result->obj, title);
344 } 359 }
345 } 360 }
346 361