summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2014-08-22 10:32:10 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2014-08-22 12:16:41 -0400
commit70719368af677947b1dd10c0a92c8d1fdcec3370 (patch)
tree74f1f644da79cf0b4db0c0bd78628aa03bbc0fbb
parentd15a8f38a61478b41e0ac80ff3ee6f12e068534d (diff)
add pips menu edit, cancel edit on bg click, fix resize aspecting
-rw-r--r--src/e_mod_main.c8
-rw-r--r--src/e_mod_main.h4
-rw-r--r--src/moveresize.c8
-rw-r--r--src/pip.c144
4 files changed, 128 insertions, 36 deletions
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index 391005d..a50adeb 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -118,10 +118,12 @@ e_modapi_save(E_Module *m EINA_UNUSED)
118} 118}
119 119
120EINTERN void 120EINTERN void
121ds_fade_setup(E_Comp *comp) 121ds_fade_setup(E_Comp *comp, Evas_Object_Event_Cb click_cb)
122{ 122{
123 if (fade_obj) return; 123 if (fade_obj) return;
124 fade_obj = evas_object_rectangle_add(comp->evas); 124 fade_obj = evas_object_rectangle_add(comp->evas);
125 if (click_cb)
126 evas_object_event_callback_add(fade_obj, EVAS_CALLBACK_MOUSE_DOWN, click_cb, NULL);
125 evas_object_name_set(fade_obj, "fade_obj"); 127 evas_object_name_set(fade_obj, "fade_obj");
126 evas_object_geometry_set(fade_obj, 0, 0, comp->man->w, comp->man->h); 128 evas_object_geometry_set(fade_obj, 0, 0, comp->man->w, comp->man->h);
127 evas_object_layer_set(fade_obj, E_LAYER_MENU + 1); 129 evas_object_layer_set(fade_obj, E_LAYER_MENU + 1);
@@ -131,7 +133,9 @@ ds_fade_setup(E_Comp *comp)
131} 133}
132 134
133EINTERN void 135EINTERN void
134ds_fade_end(Ecore_Cb end_cb) 136ds_fade_end(Ecore_Cb end_cb, Evas_Object_Event_Cb click_cb)
135{ 137{
136 efx_fade(fade_obj, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, (Efx_End_Cb)_ds_fade_end, end_cb); 138 efx_fade(fade_obj, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, (Efx_End_Cb)_ds_fade_end, end_cb);
139 if (click_cb)
140 evas_object_event_callback_del(fade_obj, EVAS_CALLBACK_MOUSE_DOWN, click_cb);
137} 141}
diff --git a/src/e_mod_main.h b/src/e_mod_main.h
index 96247e4..09d1744 100644
--- a/src/e_mod_main.h
+++ b/src/e_mod_main.h
@@ -83,8 +83,8 @@ typedef struct Config
83extern Mod *mod; 83extern Mod *mod;
84extern Config *ds_config; 84extern Config *ds_config;
85 85
86EINTERN void ds_fade_setup(E_Comp *comp); 86EINTERN void ds_fade_setup(E_Comp *comp, Evas_Object_Event_Cb click_cb);
87EINTERN void ds_fade_end(Ecore_Cb cb); 87EINTERN void ds_fade_end(Ecore_Cb cb, Evas_Object_Event_Cb click_cb);
88 88
89EINTERN void ds_init(void); 89EINTERN void ds_init(void);
90EINTERN void ds_shutdown(void); 90EINTERN void ds_shutdown(void);
diff --git a/src/moveresize.c b/src/moveresize.c
index 4cf88f1..5ba3524 100644
--- a/src/moveresize.c
+++ b/src/moveresize.c
@@ -255,7 +255,7 @@ move_start(E_Client *ec)
255 client = ec; 255 client = ec;
256 e_comp_shape_queue_block(ec->comp, 1); 256 e_comp_shape_queue_block(ec->comp, 1);
257 257
258 ds_fade_setup(ec->comp); 258 ds_fade_setup(ec->comp, NULL);
259 259
260 ec->layer_block = 1; 260 ec->layer_block = 1;
261 evas_object_layer_set(ec->frame, E_LAYER_MENU + 1); 261 evas_object_layer_set(ec->frame, E_LAYER_MENU + 1);
@@ -297,7 +297,7 @@ move_end(void *d EINA_UNUSED, E_Client *ec EINA_UNUSED)
297 efx_fade(mr_line_y, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL); 297 efx_fade(mr_line_y, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL);
298 efx_fade(move_text_x, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL); 298 efx_fade(move_text_x, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL);
299 efx_fade(move_text_y, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL); 299 efx_fade(move_text_y, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL);
300 ds_fade_end(_fade_end); 300 ds_fade_end(_fade_end, NULL);
301} 301}
302 302
303static void 303static void
@@ -310,7 +310,7 @@ resize_start(E_Client *ec)
310 client = ec; 310 client = ec;
311 e_comp_shape_queue_block(ec->comp, 1); 311 e_comp_shape_queue_block(ec->comp, 1);
312 312
313 ds_fade_setup(ec->comp); 313 ds_fade_setup(ec->comp, NULL);
314 314
315 ec->layer_block = 1; 315 ec->layer_block = 1;
316 evas_object_layer_set(ec->frame, E_LAYER_MENU + 1); 316 evas_object_layer_set(ec->frame, E_LAYER_MENU + 1);
@@ -379,7 +379,7 @@ resize_end(void *d EINA_UNUSED, E_Client *ec EINA_UNUSED)
379 efx_fade(resize_rect[x], EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL); 379 efx_fade(resize_rect[x], EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, NULL, NULL);
380 efx_queue_clear(resize_rect[x]); 380 efx_queue_clear(resize_rect[x]);
381 } 381 }
382 ds_fade_end(_fade_end); 382 ds_fade_end(_fade_end, NULL);
383} 383}
384 384
385EINTERN void 385EINTERN void
diff --git a/src/pip.c b/src/pip.c
index 45d021b..97e7feb 100644
--- a/src/pip.c
+++ b/src/pip.c
@@ -3,7 +3,7 @@
3static E_Client_Menu_Hook *hook = NULL; 3static E_Client_Menu_Hook *hook = NULL;
4static Eina_Hash *pips = NULL; 4static Eina_Hash *pips = NULL;
5static E_Action *act = NULL; 5static E_Action *act = NULL;
6static Ecore_Event_Handler *handlers[2]; 6static Eina_List *handlers = NULL;
7 7
8static Ecore_Event_Handler *action_handler = NULL; 8static Ecore_Event_Handler *action_handler = NULL;
9 9
@@ -12,57 +12,60 @@ static Eina_Bool editing = EINA_FALSE;
12typedef struct Pip 12typedef struct Pip
13{ 13{
14 Evas_Object *pip; 14 Evas_Object *pip;
15 Evas_Object *clip;
15 Evas_Point down; 16 Evas_Point down;
16 unsigned char opacity; 17 unsigned char opacity;
17 E_Pointer_Mode resize_mode; 18 E_Pointer_Mode resize_mode;
18 Eina_Bool move : 1; 19 Eina_Bool move : 1;
19 Eina_Bool resize : 1; 20 Eina_Bool resize : 1;
21 Eina_Bool crop : 1;
20} Pip; 22} Pip;
21 23
22static void 24static void
23pips_edit(void) 25pips_noedit()
24{ 26{
25 Pip *pip; 27 Pip *pip;
26 Eina_Iterator *it; 28 Eina_Iterator *it;
27 E_Comp *comp;
28 29
29 comp = e_comp_get(NULL); 30 editing = EINA_FALSE;
30 if (comp->nocomp) return; 31 ds_fade_end(NULL, pips_noedit);
31 editing = EINA_TRUE;
32 ds_fade_setup(comp);
33 it = eina_hash_iterator_data_new(pips); 32 it = eina_hash_iterator_data_new(pips);
34 EINA_ITERATOR_FOREACH(it, pip) 33 EINA_ITERATOR_FOREACH(it, pip)
35 { 34 {
36 evas_object_layer_set(pip->pip, E_LAYER_MENU + 1); 35 evas_object_layer_set(pip->pip, E_LAYER_CLIENT_PRIO);
37 evas_object_pass_events_set(pip->pip, 0); 36 evas_object_pass_events_set(pip->pip, 1);
38 } 37 }
39 eina_iterator_free(it); 38 eina_iterator_free(it);
40 e_comp_shape_queue(comp); 39 e_comp_shape_queue(e_comp_get(NULL));
40 E_FREE_FUNC(action_handler, ecore_event_handler_del);
41} 41}
42 42
43static void 43static void
44pips_noedit(void) 44pips_edit(void)
45{ 45{
46 Pip *pip; 46 Pip *pip;
47 Eina_Iterator *it; 47 Eina_Iterator *it;
48 E_Comp *comp;
48 49
49 editing = EINA_FALSE; 50 comp = e_comp_get(NULL);
50 ds_fade_end(NULL); 51 if (comp->nocomp) return;
52 editing = EINA_TRUE;
53 ds_fade_setup(comp, pips_noedit);
51 it = eina_hash_iterator_data_new(pips); 54 it = eina_hash_iterator_data_new(pips);
52 EINA_ITERATOR_FOREACH(it, pip) 55 EINA_ITERATOR_FOREACH(it, pip)
53 { 56 {
54 evas_object_layer_set(pip->pip, E_LAYER_CLIENT_PRIO); 57 evas_object_layer_set(pip->pip, E_LAYER_MENU + 1);
55 evas_object_pass_events_set(pip->pip, 1); 58 evas_object_pass_events_set(pip->pip, 0);
56 } 59 }
57 eina_iterator_free(it); 60 eina_iterator_free(it);
58 e_comp_shape_queue(e_comp_get(NULL)); 61 e_comp_shape_queue(comp);
59 E_FREE_FUNC(action_handler, ecore_event_handler_del);
60} 62}
61 63
62static void 64static void
63pip_free(Pip *pip) 65pip_free(Pip *pip)
64{ 66{
65 evas_object_del(pip->pip); 67 evas_object_del(pip->pip);
68 evas_object_del(pip->clip);
66 free(pip); 69 free(pip);
67} 70}
68 71
@@ -96,6 +99,34 @@ _pip_mouse_move(Pip *pip, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
96 w = MAX((x + w) - (ev->root.x - pip->down.x), 5); 99 w = MAX((x + w) - (ev->root.x - pip->down.x), 5);
97 x = ev->root.x - pip->down.x; 100 x = ev->root.x - pip->down.x;
98 } 101 }
102 {
103 E_Client *ec;
104
105 ec = evas_object_data_get(pip->pip, "E_Client");
106 switch (pip->resize_mode)
107 {
108 case E_POINTER_RESIZE_TL:
109 case E_POINTER_RESIZE_TR:
110 case E_POINTER_RESIZE_BR:
111 case E_POINTER_RESIZE_BL:
112 if (abs(ev->root.x - pip->down.x) > abs(ev->root.y - pip->down.y))
113 h = (ec->h * w) / ec->w;
114 else
115 w = (ec->w * h) / ec->h;
116 break;
117
118 case E_POINTER_RESIZE_T:
119 case E_POINTER_RESIZE_B:
120 w = (ec->w * h) / ec->h;
121 break;
122
123 case E_POINTER_RESIZE_R:
124 case E_POINTER_RESIZE_L:
125 h = (ec->h * w) / ec->w;
126 break;
127 default: break;
128 }
129 }
99 evas_object_geometry_set(pip->pip, x, y, w, h); 130 evas_object_geometry_set(pip->pip, x, y, w, h);
100 } 131 }
101 else if (pip->move) 132 else if (pip->move)
@@ -105,6 +136,20 @@ _pip_mouse_move(Pip *pip, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
105 E_CLAMP(ev->root.x - pip->down.x, 0, comp->man->w - (w / 2)), 136 E_CLAMP(ev->root.x - pip->down.x, 0, comp->man->w - (w / 2)),
106 E_CLAMP(ev->root.y - pip->down.y, 0, comp->man->h - (h / 2))); 137 E_CLAMP(ev->root.y - pip->down.y, 0, comp->man->h - (h / 2)));
107 } 138 }
139 else if (pip->crop)
140 {
141 int cx, cy;
142
143 if (x + pip->down.x < ev->root.x)
144 cx = x + pip->down.x;
145 else
146 cx = ev->root.x;
147 if (y + pip->down.y < ev->root.y)
148 cy = y + pip->down.y;
149 else
150 cy = ev->root.y;
151 evas_object_geometry_set(pip->clip, cx, cy, abs(cx - ev->root.x), abs(cy - ev->root.y));
152 }
108 return ECORE_CALLBACK_RENEW; 153 return ECORE_CALLBACK_RENEW;
109} 154}
110 155
@@ -126,14 +171,19 @@ _pip_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
126{ 171{
127 Pip *pip = data; 172 Pip *pip = data;
128 173
174 if (pip->crop)
175 {
176 evas_object_color_set(pip->clip, 255, 255, 255, 255);
177 evas_object_clip_set(pip->pip, pip->clip);
178 }
129 pip->down.x = pip->down.y = 0; 179 pip->down.x = pip->down.y = 0;
130 pip->move = pip->resize = 0; 180 pip->move = pip->resize = pip->crop = 0;
131 pip->resize_mode = E_POINTER_RESIZE_NONE; 181 pip->resize_mode = E_POINTER_RESIZE_NONE;
132 E_FREE_FUNC(action_handler, ecore_event_handler_del); 182 E_FREE_FUNC(action_handler, ecore_event_handler_del);
133} 183}
134 184
135static void 185static void
136_pip_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info) 186_pip_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
137{ 187{
138 Evas_Event_Mouse_Down *ev = event_info; 188 Evas_Event_Mouse_Down *ev = event_info;
139 Pip *pip = data; 189 Pip *pip = data;
@@ -147,8 +197,13 @@ _pip_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_i
147 evas_object_geometry_get(obj, &x, &y, &w, &h); 197 evas_object_geometry_get(obj, &x, &y, &w, &h);
148 pip->down.x = ev->output.x - x; 198 pip->down.x = ev->output.x - x;
149 pip->down.y = ev->output.y - y; 199 pip->down.y = ev->output.y - y;
150 pip->move = ev->button == 1; 200 if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
151 pip->resize = ev->button == 2; 201 pip->crop = ev->button == 1;
202 else if (!evas_key_modifier_is_set(ev->modifiers, "Control"))
203 {
204 pip->move = ev->button == 1;
205 pip->resize = ev->button == 2;
206 }
152 if (pip->resize) 207 if (pip->resize)
153 { 208 {
154 if ((ev->output.x > (x + w / 5)) && 209 if ((ev->output.x > (x + w / 5)) &&
@@ -196,6 +251,20 @@ _pip_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_i
196 } 251 }
197 } 252 }
198 } 253 }
254 else if (pip->crop)
255 {
256 pip->down.x = E_CLAMP(pip->down.x, 0, w);
257 pip->down.y = E_CLAMP(pip->down.y, 0, h);
258 if (!pip->clip)
259 {
260 pip->clip = evas_object_rectangle_add(e);
261 evas_object_pass_events_set(pip->clip, 1);
262 evas_object_layer_set(pip->clip, evas_object_layer_get(pip->pip) + 1);
263 evas_object_show(pip->clip);
264 }
265 evas_object_clip_unset(pip->pip);
266 evas_object_color_set(pip->clip, 50, 50, 50, 50);
267 }
199 action_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, (Ecore_Event_Handler_Cb)_pip_mouse_move, pip); 268 action_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, (Ecore_Event_Handler_Cb)_pip_mouse_move, pip);
200} 269}
201 270
@@ -215,6 +284,18 @@ _pip_delete(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
215} 284}
216 285
217static void 286static void
287_pip_manage(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
288{
289 pips_edit();
290}
291
292static void
293_pip_fade_end(void *d EINA_UNUSED, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *obj)
294{
295 ecore_job_add((Ecore_Cb)efx_fade_reset, obj);
296}
297
298static void
218_pip_create(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED) 299_pip_create(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
219{ 300{
220 E_Client *ec = data; 301 E_Client *ec = data;
@@ -241,7 +322,7 @@ _pip_create(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
241 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _pip_del, ec); 322 evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _pip_del, ec);
242 323
243 efx_fade(o, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(0, 0, 0), 0, 0.0, NULL, NULL); 324 efx_fade(o, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(0, 0, 0), 0, 0.0, NULL, NULL);
244 efx_fade(o, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(255, 255, 255), 255, 0.2, NULL, NULL); 325 efx_fade(o, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(255, 255, 255), 255, 0.2, _pip_fade_end, NULL);
245 326
246 eina_hash_add(pips, &ec->frame, pip); 327 eina_hash_add(pips, &ec->frame, pip);
247} 328}
@@ -250,6 +331,7 @@ static void
250_pip_hook(void *d EINA_UNUSED, E_Client *ec) 331_pip_hook(void *d EINA_UNUSED, E_Client *ec)
251{ 332{
252 E_Menu_Item *mi; 333 E_Menu_Item *mi;
334 E_Menu *subm;
253 const Eina_List *l; 335 const Eina_List *l;
254 Eina_Bool exists; 336 Eina_Bool exists;
255 337
@@ -263,7 +345,8 @@ _pip_hook(void *d EINA_UNUSED, E_Client *ec)
263 if (mi->separator) break; 345 if (mi->separator) break;
264 346
265 mi = eina_list_data_get(l->prev); 347 mi = eina_list_data_get(l->prev);
266 mi = e_menu_item_new(mi->submenu); 348 subm = mi->submenu;
349 mi = e_menu_item_new(subm);
267 if (exists) 350 if (exists)
268 e_menu_item_label_set(mi, D_("Delete Mini")); 351 e_menu_item_label_set(mi, D_("Delete Mini"));
269 else 352 else
@@ -273,6 +356,12 @@ _pip_hook(void *d EINA_UNUSED, E_Client *ec)
273 e_menu_item_callback_set(mi, _pip_delete, ec); 356 e_menu_item_callback_set(mi, _pip_delete, ec);
274 else 357 else
275 e_menu_item_callback_set(mi, _pip_create, ec); 358 e_menu_item_callback_set(mi, _pip_create, ec);
359 if (!exists) return;
360
361 mi = e_menu_item_new(subm);
362 e_menu_item_label_set(mi, D_("Manage Minis"));
363 e_menu_item_icon_edje_set(mi, mod->edje_file, "icon");
364 e_menu_item_callback_set(mi, _pip_manage, ec);
276} 365}
277 366
278static void 367static void
@@ -307,8 +396,8 @@ pip_init(void)
307{ 396{
308 hook = e_int_client_menu_hook_add(_pip_hook, NULL); 397 hook = e_int_client_menu_hook_add(_pip_hook, NULL);
309 pips = eina_hash_pointer_new((Eina_Free_Cb)pip_free); 398 pips = eina_hash_pointer_new((Eina_Free_Cb)pip_free);
310 handlers[0] = ecore_event_handler_add(E_EVENT_COMPOSITOR_DISABLE, pip_comp_disable, NULL); 399 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMPOSITOR_DISABLE, pip_comp_disable, NULL);
311 handlers[1] = ecore_event_handler_add(E_EVENT_COMPOSITOR_ENABLE, pip_comp_enable, NULL); 400 E_LIST_HANDLER_APPEND(handlers, E_EVENT_COMPOSITOR_ENABLE, pip_comp_enable, NULL);
312 401
313 act = e_action_add("pip"); 402 act = e_action_add("pip");
314 if (act) 403 if (act)
@@ -324,9 +413,8 @@ pip_shutdown(void)
324{ 413{
325 E_FREE_FUNC(hook, e_int_client_menu_hook_del); 414 E_FREE_FUNC(hook, e_int_client_menu_hook_del);
326 E_FREE_FUNC(pips, eina_hash_free); 415 E_FREE_FUNC(pips, eina_hash_free);
327 E_FREE_FUNC(handlers[0], ecore_event_handler_del); 416 E_FREE_LIST(handlers, ecore_event_handler_del);
328 E_FREE_FUNC(handlers[1], ecore_event_handler_del); 417 ds_fade_end(NULL, pips_noedit);
329 ds_fade_end(NULL);
330 e_action_predef_name_del(D_("Compositor"), D_("Manage Minis")); 418 e_action_predef_name_del(D_("Compositor"), D_("Manage Minis"));
331 e_action_del("pips"); 419 e_action_del("pips");
332 act = NULL; 420 act = NULL;