Canvas Functions

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files
- Examples

Modules | Typedefs | Functions
Canvas Functions
Evas

Low level Evas canvas functions. More...

## Modules
| Render Engine Functions
| Functions that are used to set the render engine for a given function, and then get that engine working.
| Coordinate Mapping Functions
| Functions that are used to map coordinates from the canvas to the screen or the screen to the canvas.
| Output and Viewport Resizing Functions
| Functions that set and retrieve the output and viewport size of an evas.
| Canvas Events
| Functions relating to canvas events, which are mainly reports on its internal states changing (an object got focused, the rendering is updated, etc).
| Image Functions
| Functions that deals with images at canvas level.
| Font Functions
| Functions that deals with fonts.
| Key Input Functions
| Functions which feed key events to the canvas.
| Touch Point List Functions
| Functions to get information of touched points in the Evas.
| Rendering GL on Evas
| This group discusses the functions that are used to do OpenGL rendering on Evas.

## Typedefs
typedef Eo | Evas
| An opaque handle to an Evas canvas. More...
typedef struct _Evas_Public_Data | Evas_Public_Data
| Public data for an Evas.

## Functions
EOAPI void | evas_canvas_data_attach_set (void *data)
| Attaches a specific pointer to the evas for fetching later. More...
EOAPI void * | evas_canvas_data_attach_get (void)
| Returns the pointer attached by evas_data_attach_set() More...
EOAPI Eina_Bool | evas_canvas_focus_state_get (void)
| Get the focus state known by the given evas. More...
EOAPI Eina_Bool | evas_canvas_changed_get (void)
| Get the changed marker for the canvas. More...
EOAPI Eina_Bool | evas_canvas_render_async (void)
| Render the given Evas canvas asynchronously. More...
EOAPI Eina_Bool | evas_canvas_render2 (void)
| Render the given Evas canvas using the new rendering infra. More...
EOAPI void | evas_canvas_focus_out (void)
| Inform to the evas that it lost the focus.
EOAPI void | evas_canvas_norender (void)
| Update the canvas internal objects but not triggering immediate renderization. More...
EOAPI void | evas_canvas_nochange_pop (void)
| Pop the nochange flag down 1. More...
EOAPI void | evas_canvas_nochange_push (void)
| Push the nochange flag up 1. More...
EOAPI void | evas_canvas_damage_rectangle_add (int x, int y, int w, int h)
| Add a damage rectangle. More...
EOAPI Eina_List * | evas_canvas_render_updates (void)
| Force immediate renderization of the given Evas canvas. More...
EOAPI void | evas_canvas_focus_in (void)
| Inform to the evas that it got the focus.
EOAPI void | evas_canvas_obscured_rectangle_add (int x, int y, int w, int h)
| Add an "obscured region" to an Evas canvas. More...
EOAPI void | evas_canvas_render_dump (void)
| Make the canvas discard as much data as possible used by the engine at runtime. More...
EOAPI void | evas_canvas_render (void)
| Force renderization of the given canvas.
EOAPI void | evas_canvas_obscured_clear (void)
| Remove all "obscured regions" from an Evas canvas. More...
EOAPI void | evas_canvas_render_idle_flush (void)
| Make the canvas discard internally cached data used for rendering. More...
bool | evas::canvas::render_async () const
| Render the given Evas canvas asynchronously. More...
bool | evas::canvas::render2 () const
| Render the given Evas canvas using the new rendering infra. More...
void | evas::canvas::focus_out () const
| Inform to the evas that it lost the focus.
void | evas::canvas::norender () const
| Update the canvas internal objects but not triggering immediate renderization. More...
void | evas::canvas::nochange_pop () const
| Pop the nochange flag down 1. More...
void | evas::canvas::nochange_push () const
| Push the nochange flag up 1. More...
void | evas::canvas::damage_rectangle_add (int x_, int y_, int w_, int h_) const
| Add a damage rectangle. More...
::efl::eina::list< Eina_Rectangle * > | evas::canvas::render_updates () const
| Force immediate renderization of the given Evas canvas. More...
void | evas::canvas::focus_in () const
| Inform to the evas that it got the focus.
void | evas::canvas::obscured_rectangle_add (int x_, int y_, int w_, int h_) const
| Add an "obscured region" to an Evas canvas. More...
void | evas::canvas::render_dump () const
| Make the canvas discard as much data as possible used by the engine at runtime. More...
void | evas::canvas::render () const
| Force renderization of the given canvas.
void | evas::canvas::obscured_clear () const
| Remove all "obscured regions" from an Evas canvas. More...
void | evas::canvas::render_idle_flush () const
| Make the canvas discard internally cached data used for rendering. More...
void * | evas::canvas::data_attach_get () const
| Returns the pointer attached by evas_data_attach_set() More...
void | evas::canvas::data_attach_set (void *data_) const
| Attaches a specific pointer to the evas for fetching later. More...
bool | evas::canvas::focus_state_get () const
| Get the focus state known by the given evas. More...
bool | evas::canvas::changed_get () const
| Get the changed marker for the canvas. More...
void | evas_data_attach_set (Evas_Canvas *obj, void *data)
| Attaches a specific pointer to the evas for fetching later. More...
void * | evas_data_attach_get (const Evas_Canvas *obj)
| Returns the pointer attached by evas_data_attach_set() More...
Eina_Bool | evas_focus_state_get (const Evas_Canvas *obj)
| Get the focus state known by the given evas. More...
Eina_Bool | evas_changed_get (const Evas_Canvas *obj)
| Get the changed marker for the canvas. More...
Eina_Bool | evas_render_async (Evas_Canvas *obj)
| Render the given Evas canvas asynchronously. More...
Eina_Bool | evas_render2 (Evas_Canvas *obj)
| Render the given Evas canvas using the new rendering infra. More...
void | evas_focus_out (Evas_Canvas *obj)
| Inform to the evas that it lost the focus.
void | evas_norender (Evas_Canvas *obj)
| Update the canvas internal objects but not triggering immediate renderization. More...
void | evas_nochange_pop (Evas_Canvas *obj)
| Pop the nochange flag down 1. More...
void | evas_nochange_push (Evas_Canvas *obj)
| Push the nochange flag up 1. More...
void | evas_damage_rectangle_add (Evas_Canvas *obj, int x, int y, int w, int h)
| Add a damage rectangle. More...
Eina_List * | evas_render_updates (Evas_Canvas *obj)
| Force immediate renderization of the given Evas canvas. More...
void | evas_focus_in (Evas_Canvas *obj)
| Inform to the evas that it got the focus.
void | evas_obscured_rectangle_add (Evas_Canvas *obj, int x, int y, int w, int h)
| Add an "obscured region" to an Evas canvas. More...
void | evas_render_dump (Evas_Canvas *obj)
| Make the canvas discard as much data as possible used by the engine at runtime. More...
void | evas_render (Evas_Canvas *obj)
| Force renderization of the given canvas.
void | evas_obscured_clear (Evas_Canvas *obj)
| Remove all "obscured regions" from an Evas canvas. More...
void | evas_render_idle_flush (Evas_Canvas *obj)
| Make the canvas discard internally cached data used for rendering. More...
void | evas_render_updates_free (Eina_List *updates)
| Free the rectangles returned by evas_render_updates(). More...
Evas * | evas_new (void)
| Creates a new empty evas. More...
void | evas_free (Evas *e)
| Frees the given evas and any objects created on it. More...

## Detailed Description

Low level Evas canvas functions.

Sub groups will present more high level ones, though.

Most of these functions deal with low level Evas actions, like:

- create/destroy raw canvases, not bound to any displaying engine
- tell a canvas i got focused (in a windowing context, for example)
- tell a canvas a region should not be calculated anymore in rendering
- tell a canvas to render its contents, immediately

Most users will be using Evas by means of the `Ecore_Evas` wrapper, which deals with all the above mentioned issues automatically for them. Thus, you'll be looking at this section only if you're building low level stuff.

The groups within present you functions that deal with the canvas directly, too, and not yet with its objects. They are the functions you need to use at a minimum to get a working canvas.

Some of the functions in this group are exemplified here.

## Typedef Documentation

Evas

An opaque handle to an Evas canvas.

See also
  evas_new()
  evas_free()

## Function Documentation

EOAPI void evas_canvas_data_attach_set | ( | void * | data | ) |

Attaches a specific pointer to the evas for fetching later.

Parameters

  [in] | data | The pointer to attach

Referenced by evas_data_attach_set().

EOAPI void* evas_canvas_data_attach_get | ( | void |  | ) |

Returns the pointer attached by evas_data_attach_set()

Returns
  The pointer attached

Referenced by evas_data_attach_get().

EOAPI Eina_Bool evas_canvas_focus_state_get | ( | void |  | ) |

Get the focus state known by the given evas.

Returns
  `EINA_TRUE` if it got the focus, `EINA_FALSE` otherwise.

Referenced by evas_focus_state_get().

EOAPI Eina_Bool evas_canvas_changed_get | ( | void |  | ) |

Get the changed marker for the canvas.

Returns
  `EINA_TRUE` if something has been marked as changed, `EINA_FALSE` otherwise.

Since
  1.11

Referenced by evas_changed_get().

EOAPI Eina_Bool evas_canvas_render_async | ( | void |  | ) |

Render the given Evas canvas asynchronously.

Returns
  EINA_TRUE if the canvas will render, EINA_FALSE otherwise.

This function only returns EINA_TRUE when a frame will be rendered. If the previous frame is still rendering, EINA_FALSE will be returned so the users know not to wait for the updates callback and just return to their main loop.

If a `func` callback is given, a list of updated areas will be generated and the function will be called from the main thread after the rendered frame is flushed to the screen. The resulting list should be freed with evas_render_updates_free(). The list is given in the `event_info` parameter of the callback function.

Since
  1.8

Referenced by evas_render_async().

EOAPI Eina_Bool evas_canvas_render2 | ( | void |  | ) |

Render the given Evas canvas using the new rendering infra.

This is experimental and will change over time until noted here.

Returns
  EINA_TRUE if the canvas will render, EINA_FALSE otherwise.

This function only returns EINA_TRUE when a frame will be rendered. If the previous frame is still rendering, EINA_FALSE will be returned so the users know not to wait for the updates callback and just return to their main loop.

Since
  1.14

Referenced by evas_render2().

EOAPI void evas_canvas_norender | ( | void |  | ) |

Update the canvas internal objects but not triggering immediate renderization.

This function updates the canvas internal objects not triggering renderization. To force renderization function evas_render() should be used.

See also
  evas_render.

Referenced by evas_norender().

EOAPI void evas_canvas_nochange_pop | ( | void |  | ) |

Pop the nochange flag down 1.

This tells evas, that while the nochange flag is greater than 0, do not mark objects as "changed" when making changes.

Warning
  Do not use this function unless you know what Evas exactly works with "changed" state.

Referenced by evas_nochange_pop().

EOAPI void evas_canvas_nochange_push | ( | void |  | ) |

Push the nochange flag up 1.

This tells evas, that while the nochange flag is greater than 0, do not mark objects as "changed" when making changes.

Warning
  Do not use this function unless you know what Evas exactly works with "changed" state.

Referenced by evas_nochange_push().

EOAPI void evas_canvas_damage_rectangle_add | ( | int | x,
|  | int | y,
|  | int | w,
|  | int | h
| ) |  |

Add a damage rectangle.

This is the function by which one tells evas that a part of the canvas has to be repainted.

Note
  All newly created Evas rectangles get the default color values of 255 255 255 255 (opaque white).

Parameters

  [in] | x | The rectangle's left position.
  [in] | y | The rectangle's top position.
  [in] | w | The rectangle's width.
  [in] | h | The rectangle's height.

Referenced by evas_damage_rectangle_add().

EOAPI Eina_List* evas_canvas_render_updates | ( | void |  | ) |

Force immediate renderization of the given Evas canvas.

Returns
  A newly allocated list of updated rectangles of the canvas (`Eina.Rectangle` structs). Free this list with evas_render_updates_free().

This function forces an immediate renderization update of the given canvas `e`.

Note
  This is a very low level function, which most of Evas' users wouldn't care about. One would use it, for example, to grab an Evas' canvas update regions and paint them back, using the canvas' pixmap, on a displaying system working below Evas.
  Evas is a stateful canvas. If no operations changing its state took place since the last rendering action, you won't see no changes and this call will be a no-op.

Example code follows.

1 "\tControl + o - add an obscured rectangle\n"
2 "\th - print help\n";
3
4 struct test_data
5 {
6 Ecore_Evas *ee;
7 Evas *canvas;
8 Evas_Object *img, *bg;
9 Ecore_Timer *resize_timer, *freeze_timer;
10 Eina_Bool obscured, focus;
11 };
12
13 static struct test_data d = {0};
14
15 /* here to keep our example's window size and background image's
16 * size in synchrony */
17 static void
18 _canvas_resize_cb(Ecore_Evas *ee)
19 {
20 int w, h;
21
22 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
23 evas_object_resize(d.bg, w, h);
24 }
25
26 /* called when our rectangle gets focus */
27 static void
28 _object_focus_in_cb(void *data EINA_UNUSED,
29 Evas *e,
30 void *event_info)
31 {
32 fprintf(stdout, "An object got focused: %s\n",
33 evas_object_name_get(event_info));
34
35 fprintf(stdout, "Let's recheck it: %s\n",
36 evas_object_name_get(evas_focus_get(e)));
37
38 fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
39 "OK!" : "Oops, something is bad.");
40 }
41
42 /* render flush callback */
43 static void
44 _render_flush_cb(void *data EINA_UNUSED,
45 Evas *e EINA_UNUSED,
46 void *event_info EINA_UNUSED)
47 {
48 fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
49 }
50
51 /* put some action in the canvas */
52 static Eina_Bool
53 _resize_cb(void *data EINA_UNUSED)
54 {
55 int w, h, cw, ch;
56
57 evas_object_geometry_get(d.img, NULL, NULL, &w, &h);
58 ecore_evas_geometry_get(d.ee, NULL, NULL, &cw, &ch);
59
60 if (w < cw)
61 evas_object_resize(d.img, cw, ch);
62 else
63 evas_object_resize(d.img, cw / 2, ch / 2);
64
65 return EINA_TRUE; /* re-issue the timer */
66 }
67
68 /* let's have our events back */
69 static Eina_Bool
70 _thaw_cb(void *data EINA_UNUSED)
71 {
72 fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
73 evas_event_freeze_get(d.canvas));
74 evas_event_thaw(d.canvas);
75 return EINA_FALSE; /* do not re-issue the timer */
76 }
77
78 /* mouse enters the object's area */
79 static void
80 _on_mouse_in(void *data EINA_UNUSED,
81 Evas *evas EINA_UNUSED,
82 Evas_Object *o EINA_UNUSED,
83 void *einfo EINA_UNUSED)
84 {
85 fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
86 }
87
88 static void
89 _on_mouse_out(void *data EINA_UNUSED,
90 Evas *evas EINA_UNUSED,
91 Evas_Object *o EINA_UNUSED,
92 void *einfo EINA_UNUSED)
93 {
94 fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
95 } /* mouse exits the object's area */
96
97 /* examine the keys pressed */
98 static void
99 _on_keydown(void *data EINA_UNUSED,
100 Evas *evas,
101 Evas_Object *o EINA_UNUSED,
102 void *einfo)
103 {
104 const Evas_Modifier *mods;
105 Evas_Event_Key_Down *ev = einfo;
106
107 fprintf(stdout, "We've got key input: %s\n", ev->key);
108 fprintf(stdout, "It actually came from %s\n", d.focus ?
109 "focus" : "key grab");
110
111 if (strcmp(ev->key, "h") == 0) /* print help */
112 {
113 puts(commands);
114 return;
115 }
116
117 if (strcmp(ev->key, "a") == 0) /* toggle animation timer */
118 {
119 if (d.resize_timer != NULL)
120 {
121 fprintf(stdout, "Stopping animation timer\n");
122 ecore_timer_del(d.resize_timer);
123 d.resize_timer = NULL;
124 }
125 else
126 {
127 fprintf(stdout, "Re-issuing animation timer\n");
128 d.resize_timer = ecore_timer_add(2, _resize_cb, NULL);
129 }
130 return;
131 }
132
133 if (strcmp(ev->key, "c") == 0) /* cycle between focus and key
134 * grabs for key input */
135 {
136 Eina_Bool ret;
137 Evas_Modifier_Mask mask =
138 evas_key_modifier_mask_get(d.canvas, "Control");
139
140 fprintf(stdout, "Switching to %s for key input\n", d.focus ?
141 "key grabs" : "focus");
142
143 if (d.focus)
144 {
145 evas_object_focus_set(d.bg, EINA_FALSE);
146 fprintf(stdout, "Focused object is now %s\n",
147 evas_focus_get(d.canvas) ?
148 "still valid! Something went wrong." : "none.");
149
150 ret = evas_object_key_grab(d.bg, "a", 0, 0, EINA_TRUE);
151 if (!ret)
152 {
153 fprintf(stdout, "Something went wrong with key grabs.\n");
154 goto c_end;
155 }
156 ret = evas_object_key_grab(d.bg, "c", 0, 0, EINA_TRUE);
157 if (!ret)
158 {
159 fprintf(stdout, "Something went wrong with key grabs.\n");
160 goto c_end;
161 }
162 ret = evas_object_key_grab(d.bg, "d", 0, 0, EINA_TRUE);
163 if (!ret)
164 {
165 fprintf(stdout, "Something went wrong with key grabs.\n");
166 goto c_end;
167 }
168 ret = evas_object_key_grab(d.bg, "f", 0, 0, EINA_TRUE);
169 if (!ret)
170 {
171 fprintf(stdout, "Something went wrong with key grabs.\n");
172 goto c_end;
173 }
174 ret = evas_object_key_grab(d.bg, "p", 0, 0, EINA_TRUE);
175 if (!ret)
176 {
177 fprintf(stdout, "Something went wrong with key grabs.\n");
178 goto c_end;
179 }
180 ret = evas_object_key_grab(d.bg, "o", mask, 0, EINA_TRUE);
181 if (!ret)
182 {
183 fprintf(stdout, "Something went wrong with key grabs.\n");
184 goto c_end;
185 }
186 ret = evas_object_key_grab(d.bg, "h", 0, 0, EINA_TRUE);
187 if (!ret)
188 {
189 fprintf(stdout, "Something went wrong with key grabs.\n");
190 goto c_end;
191 }
192 }
193 else /* got here by key grabs */
194 {
195 evas_object_key_ungrab(d.bg, "a", 0, 0);
196 evas_object_key_ungrab(d.bg, "c", 0, 0);
197 evas_object_key_ungrab(d.bg, "d", 0, 0);
198 evas_object_key_ungrab(d.bg, "f", 0, 0);
199 evas_object_key_ungrab(d.bg, "p", 0, 0);
200 evas_object_key_ungrab(d.bg, "o", mask, 0);
201 evas_object_key_ungrab(d.bg, "h", 0, 0);
202
203 evas_object_focus_set(d.bg, EINA_TRUE);
204 }
205
206 c_end:
207 d.focus = !d.focus;
208
209 return;
210 }
211
212 if (strcmp(ev->key, "d") == 0) /* delete canvas' callbacks */
213 {
214 fprintf(stdout, "Deleting canvas event callbacks\n");
215 evas_event_callback_del_full(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE,
216 _render_flush_cb, NULL);
217 evas_event_callback_del_full(
218 evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
219 _object_focus_in_cb, NULL);
220 return;
221 }
222
223 if (strcmp(ev->key, "f") == 0) /* freeze input for 3 seconds */
224 {
225 fprintf(stdout, "Freezing input for 3 seconds\n");
226 evas_event_freeze(evas);
227 d.freeze_timer = ecore_timer_add(3, _thaw_cb, NULL);
228 return;
229 }
230
231 if (strcmp(ev->key, "p") == 0) /* toggle precise point
232 * collision detection */
233 {
234 Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
235
236 fprintf(stdout, "Toggling precise point collision detection %s on"
237 " Enlightenment logo\n", precise ? "off" : "on");
238 evas_object_precise_is_inside_set(d.img, !precise);
239
240 return;
241 }
242
243 mods = evas_key_modifier_get(evas);
244 if (evas_key_modifier_is_set(mods, "Control") &&
245 (strcmp(ev->key, "o") == 0)) /* add an obscured
246 * rectangle to the middle
247 * of the canvas */
248 {
249 fprintf(stdout, "Toggling obscured rectangle on canvas\n");
250 if (!d.obscured)
251 {
252 int w, h;
253 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
254 evas_obscured_rectangle_add(evas, w / 4, h / 4, w / 2, h / 2);
255 }
256 else
257 {
258 int w, h;
259 Eina_Rectangle *rect;
260 Eina_List *updates, *l;
261
262 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
263 evas_obscured_clear(evas);
264
265 /* we have to flag a damage region here because
266 * evas_obscured_clear() doesn't change the canvas'
267 * state. we'd have to wait for an animation step, for
268 * example, to get the result, without it */
269 evas_damage_rectangle_add(evas, 0, 0, w, h);
270
271 updates = evas_render_updates(evas);
272
273 EINA_LIST_FOREACH(updates, l, rect)
274 {
275 fprintf(stdout, "Rectangle (%d, %d, %d, %d) on canvas got a"
276 " rendering update.\n", rect->x, rect->y,
277 rect->w,
278 rect->h);
279 }
280 evas_render_updates_free(updates);
281 }
282 d.obscured = !d.obscured;

See the full example.

Referenced by evas_render_updates().

EOAPI void evas_canvas_obscured_rectangle_add | ( | int | x,
|  | int | y,
|  | int | w,
|  | int | h
| ) |  |

Add an "obscured region" to an Evas canvas.

This is the function by which one tells an Evas canvas that a part of it must not be repainted. The region must be rectangular and its coordinates inside the canvas viewport are passed in the call. After this call, the region specified won't participate in any form in Evas' calculations and actions during its rendering updates, having its displaying content frozen as it was just after this function took place.

We call it "obscured region" because the most common use case for this rendering (partial) freeze is something else (most probably other canvas) being on top of the specified rectangular region, thus shading it completely from the user's final scene in a display. To avoid unnecessary processing, one should indicate to the obscured canvas not to bother about the non-important area.

The majority of users won't have to worry about this function, as they'll be using just one canvas in their applications, with nothing inset or on top of it in any form.

To make this region one that has to be repainted again, call the function evas_obscured_clear().

Note
  This is a very low level function, which most of Evas' users wouldn't care about.
  This function does not flag the canvas as having its state changed. If you want to re-render it afterwards expecting new contents, you have to add "damage" regions yourself (see evas_damage_rectangle_add()).

See also
  evas_obscured_clear()
  evas_render_updates()

Example code follows.

1 "\tControl + o - add an obscured rectangle\n"
2 "\th - print help\n";
3
4 struct test_data
5 {
6 Ecore_Evas *ee;
7 Evas *canvas;
8 Evas_Object *img, *bg;
9 Ecore_Timer *resize_timer, *freeze_timer;
10 Eina_Bool obscured, focus;
11 };
12
13 static struct test_data d = {0};
14
15 /* here to keep our example's window size and background image's
16 * size in synchrony */
17 static void
18 _canvas_resize_cb(Ecore_Evas *ee)
19 {
20 int w, h;
21
22 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
23 evas_object_resize(d.bg, w, h);
24 }
25
26 /* called when our rectangle gets focus */
27 static void
28 _object_focus_in_cb(void *data EINA_UNUSED,
29 Evas *e,
30 void *event_info)
31 {
32 fprintf(stdout, "An object got focused: %s\n",
33 evas_object_name_get(event_info));
34
35 fprintf(stdout, "Let's recheck it: %s\n",
36 evas_object_name_get(evas_focus_get(e)));
37
38 fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
39 "OK!" : "Oops, something is bad.");
40 }
41
42 /* render flush callback */
43 static void
44 _render_flush_cb(void *data EINA_UNUSED,
45 Evas *e EINA_UNUSED,
46 void *event_info EINA_UNUSED)
47 {
48 fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
49 }
50
51 /* put some action in the canvas */
52 static Eina_Bool
53 _resize_cb(void *data EINA_UNUSED)
54 {
55 int w, h, cw, ch;
56
57 evas_object_geometry_get(d.img, NULL, NULL, &w, &h);
58 ecore_evas_geometry_get(d.ee, NULL, NULL, &cw, &ch);
59
60 if (w < cw)
61 evas_object_resize(d.img, cw, ch);
62 else
63 evas_object_resize(d.img, cw / 2, ch / 2);
64
65 return EINA_TRUE; /* re-issue the timer */
66 }
67
68 /* let's have our events back */
69 static Eina_Bool
70 _thaw_cb(void *data EINA_UNUSED)
71 {
72 fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
73 evas_event_freeze_get(d.canvas));
74 evas_event_thaw(d.canvas);
75 return EINA_FALSE; /* do not re-issue the timer */
76 }
77
78 /* mouse enters the object's area */
79 static void
80 _on_mouse_in(void *data EINA_UNUSED,
81 Evas *evas EINA_UNUSED,
82 Evas_Object *o EINA_UNUSED,
83 void *einfo EINA_UNUSED)
84 {
85 fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
86 }
87
88 static void
89 _on_mouse_out(void *data EINA_UNUSED,
90 Evas *evas EINA_UNUSED,
91 Evas_Object *o EINA_UNUSED,
92 void *einfo EINA_UNUSED)
93 {
94 fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
95 } /* mouse exits the object's area */
96
97 /* examine the keys pressed */
98 static void
99 _on_keydown(void *data EINA_UNUSED,
100 Evas *evas,
101 Evas_Object *o EINA_UNUSED,
102 void *einfo)
103 {
104 const Evas_Modifier *mods;
105 Evas_Event_Key_Down *ev = einfo;
106
107 fprintf(stdout, "We've got key input: %s\n", ev->key);
108 fprintf(stdout, "It actually came from %s\n", d.focus ?
109 "focus" : "key grab");
110
111 if (strcmp(ev->key, "h") == 0) /* print help */
112 {
113 puts(commands);
114 return;
115 }
116
117 if (strcmp(ev->key, "a") == 0) /* toggle animation timer */
118 {
119 if (d.resize_timer != NULL)
120 {
121 fprintf(stdout, "Stopping animation timer\n");
122 ecore_timer_del(d.resize_timer);
123 d.resize_timer = NULL;
124 }
125 else
126 {
127 fprintf(stdout, "Re-issuing animation timer\n");
128 d.resize_timer = ecore_timer_add(2, _resize_cb, NULL);
129 }
130 return;
131 }
132
133 if (strcmp(ev->key, "c") == 0) /* cycle between focus and key
134 * grabs for key input */
135 {
136 Eina_Bool ret;
137 Evas_Modifier_Mask mask =
138 evas_key_modifier_mask_get(d.canvas, "Control");
139
140 fprintf(stdout, "Switching to %s for key input\n", d.focus ?
141 "key grabs" : "focus");
142
143 if (d.focus)
144 {
145 evas_object_focus_set(d.bg, EINA_FALSE);
146 fprintf(stdout, "Focused object is now %s\n",
147 evas_focus_get(d.canvas) ?
148 "still valid! Something went wrong." : "none.");
149
150 ret = evas_object_key_grab(d.bg, "a", 0, 0, EINA_TRUE);
151 if (!ret)
152 {
153 fprintf(stdout, "Something went wrong with key grabs.\n");
154 goto c_end;
155 }
156 ret = evas_object_key_grab(d.bg, "c", 0, 0, EINA_TRUE);
157 if (!ret)
158 {
159 fprintf(stdout, "Something went wrong with key grabs.\n");
160 goto c_end;
161 }
162 ret = evas_object_key_grab(d.bg, "d", 0, 0, EINA_TRUE);
163 if (!ret)
164 {
165 fprintf(stdout, "Something went wrong with key grabs.\n");
166 goto c_end;
167 }
168 ret = evas_object_key_grab(d.bg, "f", 0, 0, EINA_TRUE);
169 if (!ret)
170 {
171 fprintf(stdout, "Something went wrong with key grabs.\n");
172 goto c_end;
173 }
174 ret = evas_object_key_grab(d.bg, "p", 0, 0, EINA_TRUE);
175 if (!ret)
176 {
177 fprintf(stdout, "Something went wrong with key grabs.\n");
178 goto c_end;
179 }
180 ret = evas_object_key_grab(d.bg, "o", mask, 0, EINA_TRUE);
181 if (!ret)
182 {
183 fprintf(stdout, "Something went wrong with key grabs.\n");
184 goto c_end;
185 }
186 ret = evas_object_key_grab(d.bg, "h", 0, 0, EINA_TRUE);
187 if (!ret)
188 {
189 fprintf(stdout, "Something went wrong with key grabs.\n");
190 goto c_end;
191 }
192 }
193 else /* got here by key grabs */
194 {
195 evas_object_key_ungrab(d.bg, "a", 0, 0);
196 evas_object_key_ungrab(d.bg, "c", 0, 0);
197 evas_object_key_ungrab(d.bg, "d", 0, 0);
198 evas_object_key_ungrab(d.bg, "f", 0, 0);
199 evas_object_key_ungrab(d.bg, "p", 0, 0);
200 evas_object_key_ungrab(d.bg, "o", mask, 0);
201 evas_object_key_ungrab(d.bg, "h", 0, 0);
202
203 evas_object_focus_set(d.bg, EINA_TRUE);
204 }
205
206 c_end:
207 d.focus = !d.focus;
208
209 return;
210 }
211
212 if (strcmp(ev->key, "d") == 0) /* delete canvas' callbacks */
213 {
214 fprintf(stdout, "Deleting canvas event callbacks\n");
215 evas_event_callback_del_full(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE,
216 _render_flush_cb, NULL);
217 evas_event_callback_del_full(
218 evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
219 _object_focus_in_cb, NULL);
220 return;
221 }
222
223 if (strcmp(ev->key, "f") == 0) /* freeze input for 3 seconds */
224 {
225 fprintf(stdout, "Freezing input for 3 seconds\n");
226 evas_event_freeze(evas);
227 d.freeze_timer = ecore_timer_add(3, _thaw_cb, NULL);
228 return;
229 }
230
231 if (strcmp(ev->key, "p") == 0) /* toggle precise point
232 * collision detection */
233 {
234 Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
235
236 fprintf(stdout, "Toggling precise point collision detection %s on"
237 " Enlightenment logo\n", precise ? "off" : "on");
238 evas_object_precise_is_inside_set(d.img, !precise);
239
240 return;
241 }
242
243 mods = evas_key_modifier_get(evas);
244 if (evas_key_modifier_is_set(mods, "Control") &&
245 (strcmp(ev->key, "o") == 0)) /* add an obscured
246 * rectangle to the middle
247 * of the canvas */
248 {
249 fprintf(stdout, "Toggling obscured rectangle on canvas\n");
250 if (!d.obscured)
251 {
252 int w, h;
253 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
254 evas_obscured_rectangle_add(evas, w / 4, h / 4, w / 2, h / 2);
255 }
256 else
257 {
258 int w, h;
259 Eina_Rectangle *rect;
260 Eina_List *updates, *l;
261
262 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
263 evas_obscured_clear(evas);

In that example, pressing the "Ctrl" and "o" keys will impose or remove an obscured region in the middle of the canvas. You'll get the same contents at the time the key was pressed, if toggling it on, until you toggle it off again (make sure the animation is running on to get the idea better). See the full example.

Parameters

  [in] | x | The rectangle's top left corner's horizontal coordinate.
  [in] | y | The rectangle's top left corner's vertical coordinate
  [in] | w | The rectangle's width.
  [in] | h | The rectangle's height.

Referenced by evas_obscured_rectangle_add().

EOAPI void evas_canvas_render_dump | ( | void |  | ) |

Make the canvas discard as much data as possible used by the engine at runtime.

This function will unload images, delete textures and much more, where possible. You may also want to call evas_render_idle_flush() immediately prior to this to perhaps discard a little more, though evas_render_dump() should implicitly delete most of what evas_render_idle_flush() might discard too.

Referenced by evas_render_dump().

EOAPI void evas_canvas_obscured_clear | ( | void |  | ) |

Remove all "obscured regions" from an Evas canvas.

This function removes all the rectangles from the obscured regions list of the canvas `e`. It takes obscured areas added with evas_obscured_rectangle_add() and make them again a regions that have to be repainted on rendering updates.

Note
  This is a very low level function, which most of Evas' users wouldn't care about.
  This function does not flag the canvas as having its state changed. If you want to re-render it afterwards expecting new contents, you have to add "damage" regions yourself (see evas_damage_rectangle_add()).

See also
  evas_obscured_rectangle_add() for an example
  evas_render_updates()

Referenced by evas_obscured_clear().

EOAPI void evas_canvas_render_idle_flush | ( | void |  | ) |

Make the canvas discard internally cached data used for rendering.

This function flushes the arrays of delete, active and render objects. Other things it may also discard are: shared memory segments, temporary scratch buffers, cached data to avoid re-compute of that data etc.

Referenced by evas_render_idle_flush().

bool evas::canvas::render_async | ( |  | ) | const

Render the given Evas canvas asynchronously.

Returns
  EINA_TRUE if the canvas will render, EINA_FALSE otherwise.

This function only returns EINA_TRUE when a frame will be rendered. If the previous frame is still rendering, EINA_FALSE will be returned so the users know not to wait for the updates callback and just return to their main loop.

If a `func` callback is given, a list of updated areas will be generated and the function will be called from the main thread after the rendered frame is flushed to the screen. The resulting list should be freed with evas_render_updates_free(). The list is given in the `event_info` parameter of the callback function.

Since
  1.8

bool evas::canvas::render2 | ( |  | ) | const

Render the given Evas canvas using the new rendering infra.

This is experimental and will change over time until noted here.

Returns
  EINA_TRUE if the canvas will render, EINA_FALSE otherwise.

This function only returns EINA_TRUE when a frame will be rendered. If the previous frame is still rendering, EINA_FALSE will be returned so the users know not to wait for the updates callback and just return to their main loop.

Since
  1.14

void evas::canvas::norender | ( |  | ) | const

Update the canvas internal objects but not triggering immediate renderization.

This function updates the canvas internal objects not triggering renderization. To force renderization function evas_render() should be used.

See also
  evas_render.

void evas::canvas::nochange_pop | ( |  | ) | const

Pop the nochange flag down 1.

This tells evas, that while the nochange flag is greater than 0, do not mark objects as "changed" when making changes.

Warning
  Do not use this function unless you know what Evas exactly works with "changed" state.

void evas::canvas::nochange_push | ( |  | ) | const

Push the nochange flag up 1.

This tells evas, that while the nochange flag is greater than 0, do not mark objects as "changed" when making changes.

Warning
  Do not use this function unless you know what Evas exactly works with "changed" state.

void evas::canvas::damage_rectangle_add | ( | int | x_,
|  | int | y_,
|  | int | w_,
|  | int | h_
| ) |  | const

Add a damage rectangle.

This is the function by which one tells evas that a part of the canvas has to be repainted.

Note
  All newly created Evas rectangles get the default color values of 255 255 255 255 (opaque white).

Parameters

  x | The rectangle's left position.
  y | The rectangle's top position.
  w | The rectangle's width.
  h | The rectangle's height.

::efl::eina::list< Eina_Rectangle * > evas::canvas::render_updates | ( |  | ) | const

Force immediate renderization of the given Evas canvas.

Returns
  A newly allocated list of updated rectangles of the canvas (`Eina.Rectangle` structs). Free this list with evas_render_updates_free().

This function forces an immediate renderization update of the given canvas `e`.

Note
  This is a very low level function, which most of Evas' users wouldn't care about. One would use it, for example, to grab an Evas' canvas update regions and paint them back, using the canvas' pixmap, on a displaying system working below Evas.
  Evas is a stateful canvas. If no operations changing its state took place since the last rendering action, you won't see no changes and this call will be a no-op.

Example code follows.

"\tControl + o - add an obscured rectangle\n"
"\th - print help\n";
struct test_data
{
Ecore_Evas *ee;
Evas *canvas;
Evas_Object *img, *bg;
Ecore_Timer *resize_timer, *freeze_timer;
Eina_Bool obscured, focus;
};
static struct test_data d = {0};
/* here to keep our example's window size and background image's
* size in synchrony */
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
evas_object_resize(d.bg, w, h);
}
/* called when our rectangle gets focus */
static void
_object_focus_in_cb(void *data EINA_UNUSED,
Evas *e,
void *event_info)
{
fprintf(stdout, "An object got focused: %s\n",
evas_object_name_get(event_info));
fprintf(stdout, "Let's recheck it: %s\n",
evas_object_name_get(evas_focus_get(e)));
fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
"OK!" : "Oops, something is bad.");
}
/* render flush callback */
static void
_render_flush_cb(void *data EINA_UNUSED,
Evas *e EINA_UNUSED,
void *event_info EINA_UNUSED)
{
fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
}
/* put some action in the canvas */
static Eina_Bool
_resize_cb(void *data EINA_UNUSED)
{
int w, h, cw, ch;
evas_object_geometry_get(d.img, NULL, NULL, &w, &h);
ecore_evas_geometry_get(d.ee, NULL, NULL, &cw, &ch);
if (w < cw)
evas_object_resize(d.img, cw, ch);
else
evas_object_resize(d.img, cw / 2, ch / 2);
return EINA_TRUE; /* re-issue the timer */
}
/* let's have our events back */
static Eina_Bool
_thaw_cb(void *data EINA_UNUSED)
{
fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
evas_event_freeze_get(d.canvas));
evas_event_thaw(d.canvas);
return EINA_FALSE; /* do not re-issue the timer */
}
/* mouse enters the object's area */
static void
_on_mouse_in(void *data EINA_UNUSED,
Evas *evas EINA_UNUSED,
Evas_Object *o EINA_UNUSED,
void *einfo EINA_UNUSED)
{
fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
}
static void
_on_mouse_out(void *data EINA_UNUSED,
Evas *evas EINA_UNUSED,
Evas_Object *o EINA_UNUSED,
void *einfo EINA_UNUSED)
{
fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
} /* mouse exits the object's area */
/* examine the keys pressed */
static void
_on_keydown(void *data EINA_UNUSED,
Evas *evas,
Evas_Object *o EINA_UNUSED,
void *einfo)
{
const Evas_Modifier *mods;
Evas_Event_Key_Down *ev = einfo;
fprintf(stdout, "We've got key input: %s\n", ev->key);
fprintf(stdout, "It actually came from %s\n", d.focus ?
"focus" : "key grab");
if (strcmp(ev->key, "h") == 0) /* print help */
{
puts(commands);
return;
}
if (strcmp(ev->key, "a") == 0) /* toggle animation timer */
{
if (d.resize_timer != NULL)
{
fprintf(stdout, "Stopping animation timer\n");
ecore_timer_del(d.resize_timer);
d.resize_timer = NULL;
}
else
{
fprintf(stdout, "Re-issuing animation timer\n");
d.resize_timer = ecore_timer_add(2, _resize_cb, NULL);
}
return;
}
if (strcmp(ev->key, "c") == 0) /* cycle between focus and key
* grabs for key input */
{
Eina_Bool ret;
Evas_Modifier_Mask mask =
evas_key_modifier_mask_get(d.canvas, "Control");
fprintf(stdout, "Switching to %s for key input\n", d.focus ?
"key grabs" : "focus");
if (d.focus)
{
evas_object_focus_set(d.bg, EINA_FALSE);
fprintf(stdout, "Focused object is now %s\n",
evas_focus_get(d.canvas) ?
"still valid! Something went wrong." : "none.");
ret = evas_object_key_grab(d.bg, "a", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "c", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "d", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "f", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "p", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "o", mask, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "h", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
}
else /* got here by key grabs */
{
evas_object_key_ungrab(d.bg, "a", 0, 0);
evas_object_key_ungrab(d.bg, "c", 0, 0);
evas_object_key_ungrab(d.bg, "d", 0, 0);
evas_object_key_ungrab(d.bg, "f", 0, 0);
evas_object_key_ungrab(d.bg, "p", 0, 0);
evas_object_key_ungrab(d.bg, "o", mask, 0);
evas_object_key_ungrab(d.bg, "h", 0, 0);
evas_object_focus_set(d.bg, EINA_TRUE);
}
c_end:
d.focus = !d.focus;
return;
}
if (strcmp(ev->key, "d") == 0) /* delete canvas' callbacks */
{
fprintf(stdout, "Deleting canvas event callbacks\n");
evas_event_callback_del_full(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE,
_render_flush_cb, NULL);
evas_event_callback_del_full(
evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
_object_focus_in_cb, NULL);
return;
}
if (strcmp(ev->key, "f") == 0) /* freeze input for 3 seconds */
{
fprintf(stdout, "Freezing input for 3 seconds\n");
evas_event_freeze(evas);
d.freeze_timer = ecore_timer_add(3, _thaw_cb, NULL);
return;
}
if (strcmp(ev->key, "p") == 0) /* toggle precise point
* collision detection */
{
Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
fprintf(stdout, "Toggling precise point collision detection %s on"
" Enlightenment logo\n", precise ? "off" : "on");
evas_object_precise_is_inside_set(d.img, !precise);
return;
}
mods = evas_key_modifier_get(evas);
if (evas_key_modifier_is_set(mods, "Control") &&
(strcmp(ev->key, "o") == 0)) /* add an obscured
* rectangle to the middle
* of the canvas */
{
fprintf(stdout, "Toggling obscured rectangle on canvas\n");
if (!d.obscured)
{
int w, h;
evas_output_viewport_get(evas, NULL, NULL, &w, &h);
evas_obscured_rectangle_add(evas, w / 4, h / 4, w / 2, h / 2);
}
else
{
int w, h;
Eina_Rectangle *rect;
Eina_List *updates, *l;
evas_output_viewport_get(evas, NULL, NULL, &w, &h);
evas_obscured_clear(evas);
/* we have to flag a damage region here because
* evas_obscured_clear() doesn't change the canvas'
* state. we'd have to wait for an animation step, for
* example, to get the result, without it */
evas_damage_rectangle_add(evas, 0, 0, w, h);
updates = evas_render_updates(evas);
EINA_LIST_FOREACH(updates, l, rect)
{
fprintf(stdout, "Rectangle (%d, %d, %d, %d) on canvas got a"
" rendering update.\n", rect->x, rect->y,
rect->w,
rect->h);
}
evas_render_updates_free(updates);
}
d.obscured = !d.obscured;

See the full example.

void evas::canvas::obscured_rectangle_add | ( | int | x_,
|  | int | y_,
|  | int | w_,
|  | int | h_
| ) |  | const

Add an "obscured region" to an Evas canvas.

This is the function by which one tells an Evas canvas that a part of it must not be repainted. The region must be rectangular and its coordinates inside the canvas viewport are passed in the call. After this call, the region specified won't participate in any form in Evas' calculations and actions during its rendering updates, having its displaying content frozen as it was just after this function took place.

We call it "obscured region" because the most common use case for this rendering (partial) freeze is something else (most probably other canvas) being on top of the specified rectangular region, thus shading it completely from the user's final scene in a display. To avoid unnecessary processing, one should indicate to the obscured canvas not to bother about the non-important area.

The majority of users won't have to worry about this function, as they'll be using just one canvas in their applications, with nothing inset or on top of it in any form.

To make this region one that has to be repainted again, call the function evas_obscured_clear().

Note
  This is a very low level function, which most of Evas' users wouldn't care about.
  This function does not flag the canvas as having its state changed. If you want to re-render it afterwards expecting new contents, you have to add "damage" regions yourself (see evas_damage_rectangle_add()).

See also
  evas_obscured_clear()
  evas_render_updates()

Example code follows.

"\tControl + o - add an obscured rectangle\n"
"\th - print help\n";
struct test_data
{
Ecore_Evas *ee;
Evas *canvas;
Evas_Object *img, *bg;
Ecore_Timer *resize_timer, *freeze_timer;
Eina_Bool obscured, focus;
};
static struct test_data d = {0};
/* here to keep our example's window size and background image's
* size in synchrony */
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
evas_object_resize(d.bg, w, h);
}
/* called when our rectangle gets focus */
static void
_object_focus_in_cb(void *data EINA_UNUSED,
Evas *e,
void *event_info)
{
fprintf(stdout, "An object got focused: %s\n",
evas_object_name_get(event_info));
fprintf(stdout, "Let's recheck it: %s\n",
evas_object_name_get(evas_focus_get(e)));
fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
"OK!" : "Oops, something is bad.");
}
/* render flush callback */
static void
_render_flush_cb(void *data EINA_UNUSED,
Evas *e EINA_UNUSED,
void *event_info EINA_UNUSED)
{
fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
}
/* put some action in the canvas */
static Eina_Bool
_resize_cb(void *data EINA_UNUSED)
{
int w, h, cw, ch;
evas_object_geometry_get(d.img, NULL, NULL, &w, &h);
ecore_evas_geometry_get(d.ee, NULL, NULL, &cw, &ch);
if (w < cw)
evas_object_resize(d.img, cw, ch);
else
evas_object_resize(d.img, cw / 2, ch / 2);
return EINA_TRUE; /* re-issue the timer */
}
/* let's have our events back */
static Eina_Bool
_thaw_cb(void *data EINA_UNUSED)
{
fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
evas_event_freeze_get(d.canvas));
evas_event_thaw(d.canvas);
return EINA_FALSE; /* do not re-issue the timer */
}
/* mouse enters the object's area */
static void
_on_mouse_in(void *data EINA_UNUSED,
Evas *evas EINA_UNUSED,
Evas_Object *o EINA_UNUSED,
void *einfo EINA_UNUSED)
{
fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
}
static void
_on_mouse_out(void *data EINA_UNUSED,
Evas *evas EINA_UNUSED,
Evas_Object *o EINA_UNUSED,
void *einfo EINA_UNUSED)
{
fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
} /* mouse exits the object's area */
/* examine the keys pressed */
static void
_on_keydown(void *data EINA_UNUSED,
Evas *evas,
Evas_Object *o EINA_UNUSED,
void *einfo)
{
const Evas_Modifier *mods;
Evas_Event_Key_Down *ev = einfo;
fprintf(stdout, "We've got key input: %s\n", ev->key);
fprintf(stdout, "It actually came from %s\n", d.focus ?
"focus" : "key grab");
if (strcmp(ev->key, "h") == 0) /* print help */
{
puts(commands);
return;
}
if (strcmp(ev->key, "a") == 0) /* toggle animation timer */
{
if (d.resize_timer != NULL)
{
fprintf(stdout, "Stopping animation timer\n");
ecore_timer_del(d.resize_timer);
d.resize_timer = NULL;
}
else
{
fprintf(stdout, "Re-issuing animation timer\n");
d.resize_timer = ecore_timer_add(2, _resize_cb, NULL);
}
return;
}
if (strcmp(ev->key, "c") == 0) /* cycle between focus and key
* grabs for key input */
{
Eina_Bool ret;
Evas_Modifier_Mask mask =
evas_key_modifier_mask_get(d.canvas, "Control");
fprintf(stdout, "Switching to %s for key input\n", d.focus ?
"key grabs" : "focus");
if (d.focus)
{
evas_object_focus_set(d.bg, EINA_FALSE);
fprintf(stdout, "Focused object is now %s\n",
evas_focus_get(d.canvas) ?
"still valid! Something went wrong." : "none.");
ret = evas_object_key_grab(d.bg, "a", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "c", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "d", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "f", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "p", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "o", mask, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
ret = evas_object_key_grab(d.bg, "h", 0, 0, EINA_TRUE);
if (!ret)
{
fprintf(stdout, "Something went wrong with key grabs.\n");
goto c_end;
}
}
else /* got here by key grabs */
{
evas_object_key_ungrab(d.bg, "a", 0, 0);
evas_object_key_ungrab(d.bg, "c", 0, 0);
evas_object_key_ungrab(d.bg, "d", 0, 0);
evas_object_key_ungrab(d.bg, "f", 0, 0);
evas_object_key_ungrab(d.bg, "p", 0, 0);
evas_object_key_ungrab(d.bg, "o", mask, 0);
evas_object_key_ungrab(d.bg, "h", 0, 0);
evas_object_focus_set(d.bg, EINA_TRUE);
}
c_end:
d.focus = !d.focus;
return;
}
if (strcmp(ev->key, "d") == 0) /* delete canvas' callbacks */
{
fprintf(stdout, "Deleting canvas event callbacks\n");
evas_event_callback_del_full(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE,
_render_flush_cb, NULL);
evas_event_callback_del_full(
evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
_object_focus_in_cb, NULL);
return;
}
if (strcmp(ev->key, "f") == 0) /* freeze input for 3 seconds */
{
fprintf(stdout, "Freezing input for 3 seconds\n");
evas_event_freeze(evas);
d.freeze_timer = ecore_timer_add(3, _thaw_cb, NULL);
return;
}
if (strcmp(ev->key, "p") == 0) /* toggle precise point
* collision detection */
{
Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
fprintf(stdout, "Toggling precise point collision detection %s on"
" Enlightenment logo\n", precise ? "off" : "on");
evas_object_precise_is_inside_set(d.img, !precise);
return;
}
mods = evas_key_modifier_get(evas);
if (evas_key_modifier_is_set(mods, "Control") &&
(strcmp(ev->key, "o") == 0)) /* add an obscured
* rectangle to the middle
* of the canvas */
{
fprintf(stdout, "Toggling obscured rectangle on canvas\n");
if (!d.obscured)
{
int w, h;
evas_output_viewport_get(evas, NULL, NULL, &w, &h);
evas_obscured_rectangle_add(evas, w / 4, h / 4, w / 2, h / 2);
}
else
{
int w, h;
Eina_Rectangle *rect;
Eina_List *updates, *l;
evas_output_viewport_get(evas, NULL, NULL, &w, &h);
evas_obscured_clear(evas);

In that example, pressing the "Ctrl" and "o" keys will impose or remove an obscured region in the middle of the canvas. You'll get the same contents at the time the key was pressed, if toggling it on, until you toggle it off again (make sure the animation is running on to get the idea better). See the full example.

Parameters

  x | The rectangle's top left corner's horizontal coordinate.
  y | The rectangle's top left corner's vertical coordinate
  w | The rectangle's width.
  h | The rectangle's height.

void evas::canvas::render_dump | ( |  | ) | const

Make the canvas discard as much data as possible used by the engine at runtime.

This function will unload images, delete textures and much more, where possible. You may also want to call evas_render_idle_flush() immediately prior to this to perhaps discard a little more, though evas_render_dump() should implicitly delete most of what evas_render_idle_flush() might discard too.

void evas::canvas::obscured_clear | ( |  | ) | const

Remove all "obscured regions" from an Evas canvas.

This function removes all the rectangles from the obscured regions list of the canvas `e`. It takes obscured areas added with evas_obscured_rectangle_add() and make them again a regions that have to be repainted on rendering updates.

Note
  This is a very low level function, which most of Evas' users wouldn't care about.
  This function does not flag the canvas as having its state changed. If you want to re-render it afterwards expecting new contents, you have to add "damage" regions yourself (see evas_damage_rectangle_add()).

See also
  evas_obscured_rectangle_add() for an example
  evas_render_updates()

void evas::canvas::render_idle_flush | ( |  | ) | const

Make the canvas discard internally cached data used for rendering.

This function flushes the arrays of delete, active and render objects. Other things it may also discard are: shared memory segments, temporary scratch buffers, cached data to avoid re-compute of that data etc.

void* evas::canvas::data_attach_get | ( |  | ) | const

Returns the pointer attached by evas_data_attach_set()

Returns
  The pointer attached

Parameters

  data | The pointer to attach

void evas::canvas::data_attach_set | ( | void * | data_ | ) | const

Attaches a specific pointer to the evas for fetching later.

Parameters

  data | The pointer to attach

bool evas::canvas::focus_state_get | ( |  | ) | const

Get the focus state known by the given evas.

Returns
  `EINA_TRUE` if it got the focus, `EINA_FALSE` otherwise.

bool evas::canvas::changed_get | ( |  | ) | const

Get the changed marker for the canvas.

Returns
  `EINA_TRUE` if something has been marked as changed, `EINA_FALSE` otherwise.

Since
  1.11

void evas_data_attach_set | ( | Evas_Canvas * | obj,
|  | void * | data
| ) |  |

Attaches a specific pointer to the evas for fetching later.

Parameters

  [in] | data | The pointer to attach

References evas_canvas_data_attach_set().

Referenced by ecore_evas_buffer_allocfunc_new(), ecore_evas_ews_new(), and ecore_evas_object_image_new().

void* evas_data_attach_get | ( | const Evas_Canvas * | obj | ) |

Returns the pointer attached by evas_data_attach_set()

Returns
  The pointer attached

References evas_canvas_data_attach_get().

Referenced by ecore_evas_ecore_evas_get().

Eina_Bool evas_focus_state_get | ( | const Evas_Canvas * | obj | ) |

Get the focus state known by the given evas.

Returns
  `EINA_TRUE` if it got the focus, `EINA_FALSE` otherwise.

References evas_canvas_focus_state_get().

Eina_Bool evas_changed_get | ( | const Evas_Canvas * | obj | ) |

Get the changed marker for the canvas.

Returns
  `EINA_TRUE` if something has been marked as changed, `EINA_FALSE` otherwise.

Since
  1.11

References evas_canvas_changed_get().

Eina_Bool evas_render_async | ( | Evas_Canvas * | obj | ) |

Render the given Evas canvas asynchronously.

Returns
  EINA_TRUE if the canvas will render, EINA_FALSE otherwise.

This function only returns EINA_TRUE when a frame will be rendered. If the previous frame is still rendering, EINA_FALSE will be returned so the users know not to wait for the updates callback and just return to their main loop.

If a `func` callback is given, a list of updated areas will be generated and the function will be called from the main thread after the rendered frame is flushed to the screen. The resulting list should be freed with evas_render_updates_free(). The list is given in the `event_info` parameter of the callback function.

Since
  1.8

References evas_canvas_render_async().

Eina_Bool evas_render2 | ( | Evas_Canvas * | obj | ) |

Render the given Evas canvas using the new rendering infra.

This is experimental and will change over time until noted here.

Returns
  EINA_TRUE if the canvas will render, EINA_FALSE otherwise.

This function only returns EINA_TRUE when a frame will be rendered. If the previous frame is still rendering, EINA_FALSE will be returned so the users know not to wait for the updates callback and just return to their main loop.

Since
  1.14

References evas_canvas_render2().

void evas_norender | ( | Evas_Canvas * | obj | ) |

Update the canvas internal objects but not triggering immediate renderization.

This function updates the canvas internal objects not triggering renderization. To force renderization function evas_render() should be used.

See also
  evas_render.

References evas_canvas_norender().

void evas_nochange_pop | ( | Evas_Canvas * | obj | ) |

Pop the nochange flag down 1.

This tells evas, that while the nochange flag is greater than 0, do not mark objects as "changed" when making changes.

Warning
  Do not use this function unless you know what Evas exactly works with "changed" state.

References evas_canvas_nochange_pop().

void evas_nochange_push | ( | Evas_Canvas * | obj | ) |

Push the nochange flag up 1.

This tells evas, that while the nochange flag is greater than 0, do not mark objects as "changed" when making changes.

Warning
  Do not use this function unless you know what Evas exactly works with "changed" state.

References evas_canvas_nochange_push().

void evas_damage_rectangle_add | ( | Evas_Canvas * | obj,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h
| ) |  |

Add a damage rectangle.

This is the function by which one tells evas that a part of the canvas has to be repainted.

Note
  All newly created Evas rectangles get the default color values of 255 255 255 255 (opaque white).

Parameters

  [in] | x | The rectangle's left position.
  [in] | y | The rectangle's top position.
  [in] | w | The rectangle's width.
  [in] | h | The rectangle's height.

References evas_canvas_damage_rectangle_add().

Referenced by ecore_evas_rotation_set(), and ecore_evas_rotation_with_resize_set().

Eina_List* evas_render_updates | ( | Evas_Canvas * | obj | ) |

Force immediate renderization of the given Evas canvas.

Returns
  A newly allocated list of updated rectangles of the canvas (`Eina.Rectangle` structs). Free this list with evas_render_updates_free().

This function forces an immediate renderization update of the given canvas `e`.

Note
  This is a very low level function, which most of Evas' users wouldn't care about. One would use it, for example, to grab an Evas' canvas update regions and paint them back, using the canvas' pixmap, on a displaying system working below Evas.
  Evas is a stateful canvas. If no operations changing its state took place since the last rendering action, you won't see no changes and this call will be a no-op.

Example code follows.

1 "\tControl + o - add an obscured rectangle\n"
2 "\th - print help\n";
3
4 struct test_data
5 {
6 Ecore_Evas *ee;
7 Evas *canvas;
8 Evas_Object *img, *bg;
9 Ecore_Timer *resize_timer, *freeze_timer;
10 Eina_Bool obscured, focus;
11 };
12
13 static struct test_data d = {0};
14
15 /* here to keep our example's window size and background image's
16 * size in synchrony */
17 static void
18 _canvas_resize_cb(Ecore_Evas *ee)
19 {
20 int w, h;
21
22 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
23 evas_object_resize(d.bg, w, h);
24 }
25
26 /* called when our rectangle gets focus */
27 static void
28 _object_focus_in_cb(void *data EINA_UNUSED,
29 Evas *e,
30 void *event_info)
31 {
32 fprintf(stdout, "An object got focused: %s\n",
33 evas_object_name_get(event_info));
34
35 fprintf(stdout, "Let's recheck it: %s\n",
36 evas_object_name_get(evas_focus_get(e)));
37
38 fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
39 "OK!" : "Oops, something is bad.");
40 }
41
42 /* render flush callback */
43 static void
44 _render_flush_cb(void *data EINA_UNUSED,
45 Evas *e EINA_UNUSED,
46 void *event_info EINA_UNUSED)
47 {
48 fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
49 }
50
51 /* put some action in the canvas */
52 static Eina_Bool
53 _resize_cb(void *data EINA_UNUSED)
54 {
55 int w, h, cw, ch;
56
57 evas_object_geometry_get(d.img, NULL, NULL, &w, &h);
58 ecore_evas_geometry_get(d.ee, NULL, NULL, &cw, &ch);
59
60 if (w < cw)
61 evas_object_resize(d.img, cw, ch);
62 else
63 evas_object_resize(d.img, cw / 2, ch / 2);
64
65 return EINA_TRUE; /* re-issue the timer */
66 }
67
68 /* let's have our events back */
69 static Eina_Bool
70 _thaw_cb(void *data EINA_UNUSED)
71 {
72 fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
73 evas_event_freeze_get(d.canvas));
74 evas_event_thaw(d.canvas);
75 return EINA_FALSE; /* do not re-issue the timer */
76 }
77
78 /* mouse enters the object's area */
79 static void
80 _on_mouse_in(void *data EINA_UNUSED,
81 Evas *evas EINA_UNUSED,
82 Evas_Object *o EINA_UNUSED,
83 void *einfo EINA_UNUSED)
84 {
85 fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
86 }
87
88 static void
89 _on_mouse_out(void *data EINA_UNUSED,
90 Evas *evas EINA_UNUSED,
91 Evas_Object *o EINA_UNUSED,
92 void *einfo EINA_UNUSED)
93 {
94 fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
95 } /* mouse exits the object's area */
96
97 /* examine the keys pressed */
98 static void
99 _on_keydown(void *data EINA_UNUSED,
100 Evas *evas,
101 Evas_Object *o EINA_UNUSED,
102 void *einfo)
103 {
104 const Evas_Modifier *mods;
105 Evas_Event_Key_Down *ev = einfo;
106
107 fprintf(stdout, "We've got key input: %s\n", ev->key);
108 fprintf(stdout, "It actually came from %s\n", d.focus ?
109 "focus" : "key grab");
110
111 if (strcmp(ev->key, "h") == 0) /* print help */
112 {
113 puts(commands);
114 return;
115 }
116
117 if (strcmp(ev->key, "a") == 0) /* toggle animation timer */
118 {
119 if (d.resize_timer != NULL)
120 {
121 fprintf(stdout, "Stopping animation timer\n");
122 ecore_timer_del(d.resize_timer);
123 d.resize_timer = NULL;
124 }
125 else
126 {
127 fprintf(stdout, "Re-issuing animation timer\n");
128 d.resize_timer = ecore_timer_add(2, _resize_cb, NULL);
129 }
130 return;
131 }
132
133 if (strcmp(ev->key, "c") == 0) /* cycle between focus and key
134 * grabs for key input */
135 {
136 Eina_Bool ret;
137 Evas_Modifier_Mask mask =
138 evas_key_modifier_mask_get(d.canvas, "Control");
139
140 fprintf(stdout, "Switching to %s for key input\n", d.focus ?
141 "key grabs" : "focus");
142
143 if (d.focus)
144 {
145 evas_object_focus_set(d.bg, EINA_FALSE);
146 fprintf(stdout, "Focused object is now %s\n",
147 evas_focus_get(d.canvas) ?
148 "still valid! Something went wrong." : "none.");
149
150 ret = evas_object_key_grab(d.bg, "a", 0, 0, EINA_TRUE);
151 if (!ret)
152 {
153 fprintf(stdout, "Something went wrong with key grabs.\n");
154 goto c_end;
155 }
156 ret = evas_object_key_grab(d.bg, "c", 0, 0, EINA_TRUE);
157 if (!ret)
158 {
159 fprintf(stdout, "Something went wrong with key grabs.\n");
160 goto c_end;
161 }
162 ret = evas_object_key_grab(d.bg, "d", 0, 0, EINA_TRUE);
163 if (!ret)
164 {
165 fprintf(stdout, "Something went wrong with key grabs.\n");
166 goto c_end;
167 }
168 ret = evas_object_key_grab(d.bg, "f", 0, 0, EINA_TRUE);
169 if (!ret)
170 {
171 fprintf(stdout, "Something went wrong with key grabs.\n");
172 goto c_end;
173 }
174 ret = evas_object_key_grab(d.bg, "p", 0, 0, EINA_TRUE);
175 if (!ret)
176 {
177 fprintf(stdout, "Something went wrong with key grabs.\n");
178 goto c_end;
179 }
180 ret = evas_object_key_grab(d.bg, "o", mask, 0, EINA_TRUE);
181 if (!ret)
182 {
183 fprintf(stdout, "Something went wrong with key grabs.\n");
184 goto c_end;
185 }
186 ret = evas_object_key_grab(d.bg, "h", 0, 0, EINA_TRUE);
187 if (!ret)
188 {
189 fprintf(stdout, "Something went wrong with key grabs.\n");
190 goto c_end;
191 }
192 }
193 else /* got here by key grabs */
194 {
195 evas_object_key_ungrab(d.bg, "a", 0, 0);
196 evas_object_key_ungrab(d.bg, "c", 0, 0);
197 evas_object_key_ungrab(d.bg, "d", 0, 0);
198 evas_object_key_ungrab(d.bg, "f", 0, 0);
199 evas_object_key_ungrab(d.bg, "p", 0, 0);
200 evas_object_key_ungrab(d.bg, "o", mask, 0);
201 evas_object_key_ungrab(d.bg, "h", 0, 0);
202
203 evas_object_focus_set(d.bg, EINA_TRUE);
204 }
205
206 c_end:
207 d.focus = !d.focus;
208
209 return;
210 }
211
212 if (strcmp(ev->key, "d") == 0) /* delete canvas' callbacks */
213 {
214 fprintf(stdout, "Deleting canvas event callbacks\n");
215 evas_event_callback_del_full(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE,
216 _render_flush_cb, NULL);
217 evas_event_callback_del_full(
218 evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
219 _object_focus_in_cb, NULL);
220 return;
221 }
222
223 if (strcmp(ev->key, "f") == 0) /* freeze input for 3 seconds */
224 {
225 fprintf(stdout, "Freezing input for 3 seconds\n");
226 evas_event_freeze(evas);
227 d.freeze_timer = ecore_timer_add(3, _thaw_cb, NULL);
228 return;
229 }
230
231 if (strcmp(ev->key, "p") == 0) /* toggle precise point
232 * collision detection */
233 {
234 Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
235
236 fprintf(stdout, "Toggling precise point collision detection %s on"
237 " Enlightenment logo\n", precise ? "off" : "on");
238 evas_object_precise_is_inside_set(d.img, !precise);
239
240 return;
241 }
242
243 mods = evas_key_modifier_get(evas);
244 if (evas_key_modifier_is_set(mods, "Control") &&
245 (strcmp(ev->key, "o") == 0)) /* add an obscured
246 * rectangle to the middle
247 * of the canvas */
248 {
249 fprintf(stdout, "Toggling obscured rectangle on canvas\n");
250 if (!d.obscured)
251 {
252 int w, h;
253 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
254 evas_obscured_rectangle_add(evas, w / 4, h / 4, w / 2, h / 2);
255 }
256 else
257 {
258 int w, h;
259 Eina_Rectangle *rect;
260 Eina_List *updates, *l;
261
262 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
263 evas_obscured_clear(evas);
264
265 /* we have to flag a damage region here because
266 * evas_obscured_clear() doesn't change the canvas'
267 * state. we'd have to wait for an animation step, for
268 * example, to get the result, without it */
269 evas_damage_rectangle_add(evas, 0, 0, w, h);
270
271 updates = evas_render_updates(evas);
272
273 EINA_LIST_FOREACH(updates, l, rect)
274 {
275 fprintf(stdout, "Rectangle (%d, %d, %d, %d) on canvas got a"
276 " rendering update.\n", rect->x, rect->y,
277 rect->w,
278 rect->h);
279 }
280 evas_render_updates_free(updates);
281 }
282 d.obscured = !d.obscured;

See the full example.

References evas_canvas_render_updates().

void evas_obscured_rectangle_add | ( | Evas_Canvas * | obj,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h
| ) |  |

Add an "obscured region" to an Evas canvas.

This is the function by which one tells an Evas canvas that a part of it must not be repainted. The region must be rectangular and its coordinates inside the canvas viewport are passed in the call. After this call, the region specified won't participate in any form in Evas' calculations and actions during its rendering updates, having its displaying content frozen as it was just after this function took place.

We call it "obscured region" because the most common use case for this rendering (partial) freeze is something else (most probably other canvas) being on top of the specified rectangular region, thus shading it completely from the user's final scene in a display. To avoid unnecessary processing, one should indicate to the obscured canvas not to bother about the non-important area.

The majority of users won't have to worry about this function, as they'll be using just one canvas in their applications, with nothing inset or on top of it in any form.

To make this region one that has to be repainted again, call the function evas_obscured_clear().

Note
  This is a very low level function, which most of Evas' users wouldn't care about.
  This function does not flag the canvas as having its state changed. If you want to re-render it afterwards expecting new contents, you have to add "damage" regions yourself (see evas_damage_rectangle_add()).

See also
  evas_obscured_clear()
  evas_render_updates()

Example code follows.

1 "\tControl + o - add an obscured rectangle\n"
2 "\th - print help\n";
3
4 struct test_data
5 {
6 Ecore_Evas *ee;
7 Evas *canvas;
8 Evas_Object *img, *bg;
9 Ecore_Timer *resize_timer, *freeze_timer;
10 Eina_Bool obscured, focus;
11 };
12
13 static struct test_data d = {0};
14
15 /* here to keep our example's window size and background image's
16 * size in synchrony */
17 static void
18 _canvas_resize_cb(Ecore_Evas *ee)
19 {
20 int w, h;
21
22 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
23 evas_object_resize(d.bg, w, h);
24 }
25
26 /* called when our rectangle gets focus */
27 static void
28 _object_focus_in_cb(void *data EINA_UNUSED,
29 Evas *e,
30 void *event_info)
31 {
32 fprintf(stdout, "An object got focused: %s\n",
33 evas_object_name_get(event_info));
34
35 fprintf(stdout, "Let's recheck it: %s\n",
36 evas_object_name_get(evas_focus_get(e)));
37
38 fprintf(stdout, "And again: %s\n", evas_object_focus_get(event_info) ?
39 "OK!" : "Oops, something is bad.");
40 }
41
42 /* render flush callback */
43 static void
44 _render_flush_cb(void *data EINA_UNUSED,
45 Evas *e EINA_UNUSED,
46 void *event_info EINA_UNUSED)
47 {
48 fprintf(stdout, "Canvas is about to flush its rendering pipeline!\n");
49 }
50
51 /* put some action in the canvas */
52 static Eina_Bool
53 _resize_cb(void *data EINA_UNUSED)
54 {
55 int w, h, cw, ch;
56
57 evas_object_geometry_get(d.img, NULL, NULL, &w, &h);
58 ecore_evas_geometry_get(d.ee, NULL, NULL, &cw, &ch);
59
60 if (w < cw)
61 evas_object_resize(d.img, cw, ch);
62 else
63 evas_object_resize(d.img, cw / 2, ch / 2);
64
65 return EINA_TRUE; /* re-issue the timer */
66 }
67
68 /* let's have our events back */
69 static Eina_Bool
70 _thaw_cb(void *data EINA_UNUSED)
71 {
72 fprintf(stdout, "Canvas was frozen %d times, now thawing.\n",
73 evas_event_freeze_get(d.canvas));
74 evas_event_thaw(d.canvas);
75 return EINA_FALSE; /* do not re-issue the timer */
76 }
77
78 /* mouse enters the object's area */
79 static void
80 _on_mouse_in(void *data EINA_UNUSED,
81 Evas *evas EINA_UNUSED,
82 Evas_Object *o EINA_UNUSED,
83 void *einfo EINA_UNUSED)
84 {
85 fprintf(stdout, "Enlightenment logo has had the mouse in.\n");
86 }
87
88 static void
89 _on_mouse_out(void *data EINA_UNUSED,
90 Evas *evas EINA_UNUSED,
91 Evas_Object *o EINA_UNUSED,
92 void *einfo EINA_UNUSED)
93 {
94 fprintf(stdout, "Enlightenment logo has had the mouse out.\n");
95 } /* mouse exits the object's area */
96
97 /* examine the keys pressed */
98 static void
99 _on_keydown(void *data EINA_UNUSED,
100 Evas *evas,
101 Evas_Object *o EINA_UNUSED,
102 void *einfo)
103 {
104 const Evas_Modifier *mods;
105 Evas_Event_Key_Down *ev = einfo;
106
107 fprintf(stdout, "We've got key input: %s\n", ev->key);
108 fprintf(stdout, "It actually came from %s\n", d.focus ?
109 "focus" : "key grab");
110
111 if (strcmp(ev->key, "h") == 0) /* print help */
112 {
113 puts(commands);
114 return;
115 }
116
117 if (strcmp(ev->key, "a") == 0) /* toggle animation timer */
118 {
119 if (d.resize_timer != NULL)
120 {
121 fprintf(stdout, "Stopping animation timer\n");
122 ecore_timer_del(d.resize_timer);
123 d.resize_timer = NULL;
124 }
125 else
126 {
127 fprintf(stdout, "Re-issuing animation timer\n");
128 d.resize_timer = ecore_timer_add(2, _resize_cb, NULL);
129 }
130 return;
131 }
132
133 if (strcmp(ev->key, "c") == 0) /* cycle between focus and key
134 * grabs for key input */
135 {
136 Eina_Bool ret;
137 Evas_Modifier_Mask mask =
138 evas_key_modifier_mask_get(d.canvas, "Control");
139
140 fprintf(stdout, "Switching to %s for key input\n", d.focus ?
141 "key grabs" : "focus");
142
143 if (d.focus)
144 {
145 evas_object_focus_set(d.bg, EINA_FALSE);
146 fprintf(stdout, "Focused object is now %s\n",
147 evas_focus_get(d.canvas) ?
148 "still valid! Something went wrong." : "none.");
149
150 ret = evas_object_key_grab(d.bg, "a", 0, 0, EINA_TRUE);
151 if (!ret)
152 {
153 fprintf(stdout, "Something went wrong with key grabs.\n");
154 goto c_end;
155 }
156 ret = evas_object_key_grab(d.bg, "c", 0, 0, EINA_TRUE);
157 if (!ret)
158 {
159 fprintf(stdout, "Something went wrong with key grabs.\n");
160 goto c_end;
161 }
162 ret = evas_object_key_grab(d.bg, "d", 0, 0, EINA_TRUE);
163 if (!ret)
164 {
165 fprintf(stdout, "Something went wrong with key grabs.\n");
166 goto c_end;
167 }
168 ret = evas_object_key_grab(d.bg, "f", 0, 0, EINA_TRUE);
169 if (!ret)
170 {
171 fprintf(stdout, "Something went wrong with key grabs.\n");
172 goto c_end;
173 }
174 ret = evas_object_key_grab(d.bg, "p", 0, 0, EINA_TRUE);
175 if (!ret)
176 {
177 fprintf(stdout, "Something went wrong with key grabs.\n");
178 goto c_end;
179 }
180 ret = evas_object_key_grab(d.bg, "o", mask, 0, EINA_TRUE);
181 if (!ret)
182 {
183 fprintf(stdout, "Something went wrong with key grabs.\n");
184 goto c_end;
185 }
186 ret = evas_object_key_grab(d.bg, "h", 0, 0, EINA_TRUE);
187 if (!ret)
188 {
189 fprintf(stdout, "Something went wrong with key grabs.\n");
190 goto c_end;
191 }
192 }
193 else /* got here by key grabs */
194 {
195 evas_object_key_ungrab(d.bg, "a", 0, 0);
196 evas_object_key_ungrab(d.bg, "c", 0, 0);
197 evas_object_key_ungrab(d.bg, "d", 0, 0);
198 evas_object_key_ungrab(d.bg, "f", 0, 0);
199 evas_object_key_ungrab(d.bg, "p", 0, 0);
200 evas_object_key_ungrab(d.bg, "o", mask, 0);
201 evas_object_key_ungrab(d.bg, "h", 0, 0);
202
203 evas_object_focus_set(d.bg, EINA_TRUE);
204 }
205
206 c_end:
207 d.focus = !d.focus;
208
209 return;
210 }
211
212 if (strcmp(ev->key, "d") == 0) /* delete canvas' callbacks */
213 {
214 fprintf(stdout, "Deleting canvas event callbacks\n");
215 evas_event_callback_del_full(evas, EVAS_CALLBACK_RENDER_FLUSH_PRE,
216 _render_flush_cb, NULL);
217 evas_event_callback_del_full(
218 evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
219 _object_focus_in_cb, NULL);
220 return;
221 }
222
223 if (strcmp(ev->key, "f") == 0) /* freeze input for 3 seconds */
224 {
225 fprintf(stdout, "Freezing input for 3 seconds\n");
226 evas_event_freeze(evas);
227 d.freeze_timer = ecore_timer_add(3, _thaw_cb, NULL);
228 return;
229 }
230
231 if (strcmp(ev->key, "p") == 0) /* toggle precise point
232 * collision detection */
233 {
234 Eina_Bool precise = evas_object_precise_is_inside_get(d.img);
235
236 fprintf(stdout, "Toggling precise point collision detection %s on"
237 " Enlightenment logo\n", precise ? "off" : "on");
238 evas_object_precise_is_inside_set(d.img, !precise);
239
240 return;
241 }
242
243 mods = evas_key_modifier_get(evas);
244 if (evas_key_modifier_is_set(mods, "Control") &&
245 (strcmp(ev->key, "o") == 0)) /* add an obscured
246 * rectangle to the middle
247 * of the canvas */
248 {
249 fprintf(stdout, "Toggling obscured rectangle on canvas\n");
250 if (!d.obscured)
251 {
252 int w, h;
253 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
254 evas_obscured_rectangle_add(evas, w / 4, h / 4, w / 2, h / 2);
255 }
256 else
257 {
258 int w, h;
259 Eina_Rectangle *rect;
260 Eina_List *updates, *l;
261
262 evas_output_viewport_get(evas, NULL, NULL, &w, &h);
263 evas_obscured_clear(evas);

In that example, pressing the "Ctrl" and "o" keys will impose or remove an obscured region in the middle of the canvas. You'll get the same contents at the time the key was pressed, if toggling it on, until you toggle it off again (make sure the animation is running on to get the idea better). See the full example.

Parameters

  [in] | x | The rectangle's top left corner's horizontal coordinate.
  [in] | y | The rectangle's top left corner's vertical coordinate
  [in] | w | The rectangle's width.
  [in] | h | The rectangle's height.

References evas_canvas_obscured_rectangle_add().

void evas_render_dump | ( | Evas_Canvas * | obj | ) |

Make the canvas discard as much data as possible used by the engine at runtime.

This function will unload images, delete textures and much more, where possible. You may also want to call evas_render_idle_flush() immediately prior to this to perhaps discard a little more, though evas_render_dump() should implicitly delete most of what evas_render_idle_flush() might discard too.

References evas_canvas_render_dump().

void evas_obscured_clear | ( | Evas_Canvas * | obj | ) |

Remove all "obscured regions" from an Evas canvas.

This function removes all the rectangles from the obscured regions list of the canvas `e`. It takes obscured areas added with evas_obscured_rectangle_add() and make them again a regions that have to be repainted on rendering updates.

Note
  This is a very low level function, which most of Evas' users wouldn't care about.
  This function does not flag the canvas as having its state changed. If you want to re-render it afterwards expecting new contents, you have to add "damage" regions yourself (see evas_damage_rectangle_add()).

See also
  evas_obscured_rectangle_add() for an example
  evas_render_updates()

References evas_canvas_obscured_clear().

void evas_render_idle_flush | ( | Evas_Canvas * | obj | ) |

Make the canvas discard internally cached data used for rendering.

This function flushes the arrays of delete, active and render objects. Other things it may also discard are: shared memory segments, temporary scratch buffers, cached data to avoid re-compute of that data etc.

References evas_canvas_render_idle_flush().

void evas_render_updates_free | ( | Eina_List * | updates | ) |

Free the rectangles returned by evas_render_updates().

Parameters

  updates | The list of updated rectangles of the canvas.

This function removes the region from the render updates list. It makes the region doesn't be render updated anymore.

See also
  evas_render_updates() for an example

References EINA_LIST_FREE, and eina_rectangle_free().

Evas* evas_new | ( | void |  | ) |

Creates a new empty evas.

Note that before you can use the evas, you will to at a minimum:

- Set its render method with evas_output_method_set .
- Set its viewport size with evas_output_viewport_set .
- Set its size of the canvas with evas_output_size_set .
- Ensure that the render engine is given the correct settings with evas_engine_info_set .

This function should only fail if the memory allocation fails

Note
  this function is very low level. Instead of using it directly, consider using the high level functions in Ecore_Evas wrapper/helper set of functions such as `ecore_evas_new()`. See Ecore.

Attention
  it is recommended that one calls evas_init() before creating new canvas.

Returns
  A new uninitialised Evas canvas on success. Otherwise, `NULL`.

Referenced by ecore_evas_buffer_allocfunc_new(), ecore_evas_ews_new(), and ecore_evas_object_image_new().

void evas_free | ( | Evas * | e | ) |

Frees the given evas and any objects created on it.

Any objects with 'free' callbacks will have those callbacks called in this function.

Parameters

  e | The given evas.