diff options
author | David Walter Seikel | 2014-05-05 04:59:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-05 04:59:13 +1000 |
commit | 27d85ca5fc18bc5ae9abecb88fba26b71e392209 (patch) | |
tree | e40435aa18af49c2d04745b4bc33493b831bd132 | |
parent | Merge winFangComplete into winFangAdd. (diff) | |
download | SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.zip SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.tar.gz SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.tar.bz2 SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.tar.xz |
Merge inline and external window creation.
-rw-r--r-- | src/extantz/chat.c | 2 | ||||
-rw-r--r-- | src/extantz/files.c | 2 | ||||
-rw-r--r-- | src/extantz/winFang.c | 113 | ||||
-rw-r--r-- | src/extantz/winFang.h | 3 | ||||
-rw-r--r-- | src/extantz/woMan.c | 2 |
5 files changed, 72 insertions, 50 deletions
diff --git a/src/extantz/chat.c b/src/extantz/chat.c index 5036c95..d608620 100644 --- a/src/extantz/chat.c +++ b/src/extantz/chat.c | |||
@@ -16,7 +16,7 @@ winFang *chat_add(globals *ourGlobals) | |||
16 | Widget *wid; | 16 | Widget *wid; |
17 | Evas_Object *bx, *en; | 17 | Evas_Object *bx, *en; |
18 | 18 | ||
19 | me = winFangAdd(ourGlobals->win, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3); | 19 | me = winFangAdd(ourGlobals->win, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); |
20 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | 20 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); |
21 | 21 | ||
22 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, | 22 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, |
diff --git a/src/extantz/files.c b/src/extantz/files.c index 254fc5f..357769e 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c | |||
@@ -146,7 +146,7 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa | |||
146 | Widget *wid; | 146 | Widget *wid; |
147 | Evas_Object *bx, *vbox, *fs, *bt, *rd = NULL, *rdg = NULL, *hoversel; | 147 | Evas_Object *bx, *vbox, *fs, *bt, *rd = NULL, *rdg = NULL, *hoversel; |
148 | 148 | ||
149 | me = winFangAdd(ourGlobals->win, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500); | 149 | me = winFangAdd(ourGlobals->win, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500, "file selector", "files"); |
150 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | 150 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); |
151 | 151 | ||
152 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, | 152 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, |
diff --git a/src/extantz/winFang.c b/src/extantz/winFang.c index 07fdaa7..a38845a 100644 --- a/src/extantz/winFang.c +++ b/src/extantz/winFang.c | |||
@@ -49,6 +49,11 @@ static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_ | |||
49 | evas_map_free(p); | 49 | evas_map_free(p); |
50 | } | 50 | } |
51 | 51 | ||
52 | static void _on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | ||
53 | { | ||
54 | elm_exit(); | ||
55 | } | ||
56 | |||
52 | void winFangHide(winFang *win) | 57 | void winFangHide(winFang *win) |
53 | { | 58 | { |
54 | int i; | 59 | int i; |
@@ -67,7 +72,7 @@ void winFangShow(winFang *win) | |||
67 | evas_object_show(win->hand[i]); | 72 | evas_object_show(win->hand[i]); |
68 | } | 73 | } |
69 | 74 | ||
70 | winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h) | 75 | winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title, char *name) |
71 | { | 76 | { |
72 | winFang *result; | 77 | winFang *result; |
73 | Evas_Object *obj, *obj2, *bg; | 78 | Evas_Object *obj, *obj2, *bg; |
@@ -77,6 +82,8 @@ winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h) | |||
77 | result = calloc(1, sizeof(winFang)); | 82 | result = calloc(1, sizeof(winFang)); |
78 | eina_clist_init(&result->widgets); | 83 | eina_clist_init(&result->widgets); |
79 | 84 | ||
85 | if (parent) result->internal = EINA_TRUE; | ||
86 | |||
80 | result->x = x; | 87 | result->x = x; |
81 | result->y = y; | 88 | result->y = y; |
82 | result->w = w; | 89 | result->w = w; |
@@ -85,63 +92,77 @@ winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h) | |||
85 | // In theory this should create an EWS window, in practice, I'm not seeing any difference. | 92 | // In theory this should create an EWS window, in practice, I'm not seeing any difference. |
86 | // 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. | 93 | // 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. |
87 | // elm_config_engine_set("ews"); | 94 | // elm_config_engine_set("ews"); |
88 | result->win = elm_win_add(parent, "inlined", ELM_WIN_INLINED_IMAGE); | 95 | if (result->internal) |
89 | // 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. | ||
90 | // According to the Elm inlined image window example, this is what's needed to. | ||
91 | evas_object_event_callback_add(elm_win_inlined_image_object_get(result->win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); | ||
92 | elm_win_alpha_set(result->win, EINA_TRUE); | ||
93 | |||
94 | // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. | ||
95 | // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. | ||
96 | bg = evas_object_rectangle_add(evas_object_evas_get(result->win)); | ||
97 | evas_object_color_set(bg, 50, 0, 100, 100); | ||
98 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
99 | elm_win_resize_object_add(result->win, bg); | ||
100 | evas_object_show(bg); | ||
101 | |||
102 | obj = elm_win_inlined_image_object_get(result->win); | ||
103 | obj2 = evas_object_evas_get(obj); | ||
104 | // image object for win is unlinked to its pos/size - so manual control | ||
105 | // this allows also for using map and other things with it. | ||
106 | evas_object_move(obj, result->x, result->y); | ||
107 | // Odd, it needs to be resized twice. WTF? | ||
108 | evas_object_resize(result->win, result->w, result->h); | ||
109 | evas_object_resize(obj, result->w, result->h); | ||
110 | evas_object_show(result->win); | ||
111 | |||
112 | // Create corner handles. | ||
113 | snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); | ||
114 | for (i = 0; i < 4; i++) | ||
115 | { | 96 | { |
116 | char key[32]; | 97 | result->win = elm_win_add(parent, name, ELM_WIN_INLINED_IMAGE); |
117 | int cx = result->x, cy = result->y; | 98 | obj = elm_win_inlined_image_object_get(result->win); |
118 | 99 | // 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. | |
119 | if (i == 1) cx += result->w; | 100 | // According to the Elm inlined image window example, this is what's needed to. |
120 | else if (i == 2) {cx += result->w; cy += result->h;} | 101 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); |
121 | else if (i == 3) cy += result->h; | 102 | elm_win_alpha_set(result->win, EINA_TRUE); |
122 | snprintf(key, sizeof(key), "h-%i\n", i); | 103 | |
104 | // image object for win is unlinked to its pos/size - so manual control | ||
105 | // this allows also for using map and other things with it. | ||
106 | evas_object_move(obj, result->x, result->y); | ||
107 | // Odd, it needs to be resized twice. WTF? | ||
108 | evas_object_resize(obj, result->w, result->h); | ||
109 | |||
110 | obj2 = evas_object_evas_get(obj); | ||
111 | // Create corner handles. | ||
112 | snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); | ||
113 | for (i = 0; i < 4; i++) | ||
114 | { | ||
115 | char key[32]; | ||
116 | int cx = result->x, cy = result->y; | ||
117 | |||
118 | if (i == 1) cx += result->w; | ||
119 | else if (i == 2) {cx += result->w; cy += result->h;} | ||
120 | else if (i == 3) cy += result->h; | ||
121 | snprintf(key, sizeof(key), "h-%i\n", i); | ||
123 | #if 1 | 122 | #if 1 |
124 | result->hand[i] = evas_object_image_filled_add(obj2); | 123 | result->hand[i] = evas_object_image_filled_add(obj2); |
125 | evas_object_image_file_set(result->hand[i], buf, NULL); | 124 | evas_object_image_file_set(result->hand[i], buf, NULL); |
126 | evas_object_resize(result->hand[i], 31, 31); | 125 | evas_object_resize(result->hand[i], 31, 31); |
127 | evas_object_move(result->hand[i], cx - 15, cy - 15); | 126 | evas_object_move(result->hand[i], cx - 15, cy - 15); |
128 | evas_object_data_set(obj, key, result->hand[i]); | 127 | evas_object_data_set(obj, key, result->hand[i]); |
129 | evas_object_show(result->hand[i]); | 128 | evas_object_show(result->hand[i]); |
130 | evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); | 129 | evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); |
131 | #else | 130 | #else |
132 | // TODO - No idea why, but using this version makes the window vanish when you click on a handle. | 131 | // TODO - No idea why, but using this version makes the window vanish when you click on a handle. |
133 | result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, obj2, | 132 | result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, obj2, |
134 | evas_obj_image_filled_set(EINA_TRUE), | 133 | evas_obj_image_filled_set(EINA_TRUE), |
135 | evas_obj_image_file_set(buf, NULL), | 134 | evas_obj_image_file_set(buf, NULL), |
136 | evas_obj_size_set(31, 31), | 135 | evas_obj_size_set(31, 31), |
137 | evas_obj_position_set(cx - 15, cy - 15), | 136 | evas_obj_position_set(cx - 15, cy - 15), |
138 | eo_key_data_set(key, result->hand[i], NULL), | 137 | eo_key_data_set(key, result->hand[i], NULL), |
139 | evas_obj_visibility_set(EINA_TRUE) | 138 | evas_obj_visibility_set(EINA_TRUE) |
140 | ); | 139 | ); |
141 | evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); | 140 | evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); |
142 | eo_unref(result->hand[i]); | 141 | eo_unref(result->hand[i]); |
143 | #endif | 142 | #endif |
143 | } | ||
144 | } | 144 | } |
145 | else | ||
146 | { | ||
147 | elm_config_preferred_engine_set("opengl_x11"); | ||
148 | result->win = elm_win_add(parent, name, ELM_WIN_BASIC); | ||
149 | evas_object_move(result->win, result->x, result->y); | ||
150 | evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL); | ||
151 | } | ||
152 | |||
153 | elm_win_title_set(result->win, title); | ||
154 | // Apparently transparent is not good enough for ELM backgrounds, so make it an Evas rectangle. | ||
155 | // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. | ||
156 | bg = eo_add(EVAS_OBJ_RECTANGLE_CLASS, evas_object_evas_get(result->win), | ||
157 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), | ||
158 | evas_obj_color_set(50, 0, 100, 100), | ||
159 | evas_obj_visibility_set(EINA_TRUE) | ||
160 | ); | ||
161 | elm_win_resize_object_add(result->win, bg); | ||
162 | eo_unref(bg); | ||
163 | |||
164 | evas_object_resize(result->win, result->w, result->h); | ||
165 | evas_object_show(result->win); | ||
145 | 166 | ||
146 | return result; | 167 | return result; |
147 | } | 168 | } |
diff --git a/src/extantz/winFang.h b/src/extantz/winFang.h index 478fb4e..6ae26e4 100644 --- a/src/extantz/winFang.h +++ b/src/extantz/winFang.h | |||
@@ -6,6 +6,7 @@ typedef struct _winFang | |||
6 | Evas_Object *win; | 6 | Evas_Object *win; |
7 | Eina_Clist widgets; | 7 | Eina_Clist widgets; |
8 | int x, y, w, h; | 8 | int x, y, w, h; |
9 | Eina_Bool internal; | ||
9 | 10 | ||
10 | Evas_Object *hand[4]; | 11 | Evas_Object *hand[4]; |
11 | 12 | ||
@@ -30,7 +31,7 @@ typedef struct _Widget | |||
30 | Evas_Smart_Cb on_del; | 31 | Evas_Smart_Cb on_del; |
31 | } Widget; | 32 | } Widget; |
32 | 33 | ||
33 | winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h); | 34 | winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title, char *name); |
34 | void winFangHide(winFang *win); | 35 | void winFangHide(winFang *win); |
35 | void winFangShow(winFang *win); | 36 | void winFangShow(winFang *win); |
36 | void winFangDel(winFang *win); | 37 | void winFangDel(winFang *win); |
diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index dc9c8e0..f0a2ed4 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c | |||
@@ -159,7 +159,7 @@ winFang *woMan_add(globals *ourGlobals) | |||
159 | char buf[PATH_MAX]; | 159 | char buf[PATH_MAX]; |
160 | int i; | 160 | int i; |
161 | 161 | ||
162 | me = winFangAdd(ourGlobals->win, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3); | 162 | me = winFangAdd(ourGlobals->win, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); |
163 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | 163 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); |
164 | 164 | ||
165 | bx = elm_box_add(me->win); | 165 | bx = elm_box_add(me->win); |