aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/winFang.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-05 04:59:13 +1000
committerDavid Walter Seikel2014-05-05 04:59:13 +1000
commit27d85ca5fc18bc5ae9abecb88fba26b71e392209 (patch)
treee40435aa18af49c2d04745b4bc33493b831bd132 /src/extantz/winFang.c
parentMerge winFangComplete into winFangAdd. (diff)
downloadSledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.zip
SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.tar.gz
SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.tar.bz2
SledjHamr-27d85ca5fc18bc5ae9abecb88fba26b71e392209.tar.xz
Merge inline and external window creation.
Diffstat (limited to '')
-rw-r--r--src/extantz/winFang.c113
1 files changed, 67 insertions, 46 deletions
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
52static void _on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{
54 elm_exit();
55}
56
52void winFangHide(winFang *win) 57void 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
70winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h) 75winFang *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}