aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/fangWin.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-04 17:12:08 +1000
committerDavid Walter Seikel2014-05-04 17:12:08 +1000
commitf8fc00691417f628ba09e53552f7ac89cfd98faa (patch)
treed075a31f01c4b9563affef7556bf94fceea6c95a /src/extantz/fangWin.c
parentAdd a file selector. (diff)
downloadSledjHamr-f8fc00691417f628ba09e53552f7ac89cfd98faa.zip
SledjHamr-f8fc00691417f628ba09e53552f7ac89cfd98faa.tar.gz
SledjHamr-f8fc00691417f628ba09e53552f7ac89cfd98faa.tar.bz2
SledjHamr-f8fc00691417f628ba09e53552f7ac89cfd98faa.tar.xz
New fangWin and Widget structures, and modify fangWin stuff to use them.
Diffstat (limited to 'src/extantz/fangWin.c')
-rw-r--r--src/extantz/fangWin.c60
1 files changed, 45 insertions, 15 deletions
diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c
index e95910c..7a9f0d5 100644
--- a/src/extantz/fangWin.c
+++ b/src/extantz/fangWin.c
@@ -1,7 +1,6 @@
1#include "extantz.h" 1#include "extantz.h"
2 2
3 3
4
5// Elm inlined image windows needs this to change focus on mouse click. 4// Elm inlined image windows needs this to change focus on mouse click.
6// Evas style event callback. 5// Evas style event callback.
7static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info) 6static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
@@ -77,40 +76,60 @@ static void create_handles(Evas_Object *obj)
77 } 76 }
78} 77}
79 78
80Evas_Object *fang_win_add(globals *ourGlobals) 79fangWin *fang_win_add(globals *ourGlobals)
81{ 80{
82 Evas_Object *win, *bg; 81 fangWin *result;
82 Evas_Object *bg;
83
84 result = calloc(1, sizeof(fangWin));
85 eina_clist_init(&result->widgets);
83 86
84 // In theory this should create an EWS window, in practice, I'm not seeing any difference. 87 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
85 // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words. 88 // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words.
86// elm_config_engine_set("ews"); 89// elm_config_engine_set("ews");
87 win = elm_win_add(ourGlobals->win, "inlined", ELM_WIN_INLINED_IMAGE); 90 result->win = elm_win_add(ourGlobals->win, "inlined", ELM_WIN_INLINED_IMAGE);
88 // 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. 91 // 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.
89 // According to the Elm inlined image window example, this is what's needed to. 92 // According to the Elm inlined image window example, this is what's needed to.
90 evas_object_event_callback_add(elm_win_inlined_image_object_get(win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); 93 evas_object_event_callback_add(elm_win_inlined_image_object_get(result->win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL);
91 elm_win_alpha_set(win, EINA_TRUE); 94 elm_win_alpha_set(result->win, EINA_TRUE);
92 95
93 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. 96 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
94 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. 97 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
95 bg = evas_object_rectangle_add(evas_object_evas_get(win)); 98 bg = evas_object_rectangle_add(evas_object_evas_get(result->win));
96 evas_object_color_set(bg, 50, 0, 100, 100); 99 evas_object_color_set(bg, 50, 0, 100, 100);
97 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 100 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
98 elm_win_resize_object_add(win, bg); 101 elm_win_resize_object_add(result->win, bg);
99 evas_object_show(bg); 102 evas_object_show(bg);
100 103
101 return win; 104 return result;
102} 105}
103 106
104void fang_win_complete(globals *ourGlobals, Evas_Object *win, int x, int y, int w, int h) 107void fang_win_complete(globals *ourGlobals, fangWin *win, int x, int y, int w, int h)
105{ 108{
106 // image object for win is unlinked to its pos/size - so manual control 109 // image object for win is unlinked to its pos/size - so manual control
107 // this allows also for using map and other things with it. 110 // this allows also for using map and other things with it.
108 evas_object_move(elm_win_inlined_image_object_get(win), x, y); 111 evas_object_move(elm_win_inlined_image_object_get(win->win), x, y);
109 // Odd, it needs to be resized twice. WTF? 112 // Odd, it needs to be resized twice. WTF?
110 evas_object_resize(win, w, h); 113 evas_object_resize(win->win, w, h);
111 evas_object_resize(elm_win_inlined_image_object_get(win), w, h); 114 evas_object_resize(elm_win_inlined_image_object_get(win->win), w, h);
112 evas_object_show(win); 115 evas_object_show(win->win);
113 create_handles(elm_win_inlined_image_object_get(win)); 116 create_handles(elm_win_inlined_image_object_get(win->win));
117}
118
119void fang_win_del(globals *ourGlobals, fangWin *win)
120{
121 Widget *wid;
122
123 if (!win) return;
124
125 // Elm will delete our widgets, but if we are using eo, we need to unref them.
126 EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node)
127 {
128 if (wid->on_del) wid->on_del(wid, wid->obj, NULL);
129 eo_unref(wid->obj);
130 }
131 if (win->on_del) win->on_del(win, win->win, NULL);
132 evas_object_del(win->win);
114} 133}
115 134
116void overlay_add(globals *ourGlobals) 135void overlay_add(globals *ourGlobals)
@@ -154,3 +173,14 @@ void overlay_add(globals *ourGlobals)
154 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), ourGlobals->win_w, ourGlobals->win_h); 173 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), ourGlobals->win_w, ourGlobals->win_h);
155 evas_object_show(gld->winwin); 174 evas_object_show(gld->winwin);
156} 175}
176
177Widget *widgetAdd(fangWin *win)
178{
179 Widget *result;
180
181 result = calloc(1, sizeof(Widget));
182 strcpy(result->magic, "Widget");
183 eina_clist_add_head(&win->widgets, &result->node);
184
185 return result;
186}