Languages

Menu
Sites
Language
How to print the rectangle size?

I need to debug following code and to know the size of the rectangle.

   // Event Rect
   ad->rect = evas_object_rectangle_add(evas_object_evas_get(ad->box));
   evas_object_size_hint_weight_set(ad->rect, EVAS_HINT_EXPAND, VAS_HINT_EXPAND);
   evas_object_size_hint_align_set(ad->rect, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_color_set(ad->rect, 204, 204, 204, 255);
   evas_object_repeat_events_set(ad->rect, EINA_TRUE);

Now I know the rect will expand to the size of the box, but how can I print the rectangle size out?

I want to get the value of both the left top point and the right bottom point of the rectangle.

Edited by: Jean Yang on 27 Aug, 2015

Responses

4 Replies
colin Rao

Hi,

I dont find such direct way to get an evas object's size from the IDE help doc. 

But, possible the resize event callback " EVAS_CALLBACK_RESIZE " can let you to get the object's size. 

Alex Dem

Hi,
try to use:

  int x,y,w,h;
  evas_object_geometry_get(ad->rect,&x,&y,&w,&h);
  LOGI("%d %d %d %d",x,y,w,h);

Alexey.

Palitsyna

Hello,

as Alex Dem said, try to use evas_object_geometry_get() method. 

void evas_object_geometry_get (	const Evas_Object * obj,
                                    Evas_Coord * 	x,
                                    Evas_Coord * 	y,
                                    Evas_Coord * 	w,
                                    Evas_Coord * 	h 
                                )		
This method gets the position and (rectangular) size of the given Evas object. The position is relative to the top left corner of the canvas' viewport.
Use NULL pointers on the geometry components you are not interested in: they are ignored by the function.

Parameters:
[in]	obj	The given Evas object
[out]	x	The pointer to an integer in which to store the X coordinate of the object
[out]	y	The pointer to an integer in which to store the Y coordinate of the object
[out]	w	The pointer to an integer in which to store the width of the object
[out]	h	The pointer to an integer in which to store the height of the object

 

Jean Yang

Thanks! it will be useful when we debug.