Languages

Menu
Sites
Language
evas_object_geometry_get returns all 0s

I'm trying to apply a map to a label, but when i call 

evas_object_geometry_get(vc->label1, &x, &y, &w, &h);

i'm doing it inside the _on_create_cb, so i don't know if this information is not yet available during that callback.

Anyway, when i'm tryin to get this information during a click button event, the functon return correct values. 

So i'm wondering if i want to do some initial configuration on an object (i.e. applying a map to rotate it), when i'm supposedo to do it?

 

Responses

7 Replies
K Johnson

Would you please go through this link ? I guess, it'll help you to understand the way of applying rotation to an object.

Ivan Gualandri

Hi, my question in that case was not how to rotate the lable (i have already posted it in this forum), was trying to understand why if i call that function in the _on_create_cb function, it return all 0s, but if the same function on the same object is called for example during a click-handler it return the correct values.

K Johnson

Would you please share your code here?

Ivan Gualandri

This is the code i was using:

Evas_Map *map = evas_map_new(4);
	evas_map_util_points_populate_from_object(map, vc->label1);
	evas_map_util_rotate(map, 180, x + (w / 2), y + (h / 2));
	evas_object_map_set(vc->label1, map);
	evas_object_map_enable_set(vc->label1, EINA_TRUE);
	elm_object_text_set(vc->label1, "Ci-ao");
	evas_map_free(map);

Taken directly from the example. 

The problem is  that if i try to print x,y,w,h they are all 0 if i'm in one of the following functions:

  • static bool _on_create_cb(void *user_data)
  • or the view_created event. 

Obviously this code snippet that should rotate the label it doesn't rotate it, and i'm wondering if the reason is the all 0s returned by the function. 

K Johnson

I guess where you're trying to retrieve the position of given Evas Object (using evas_object_geometry_get() function) in that place those values(i.e. x, y, w, h) are actually zero. You may try using the below code snippet inside any of the functions and check the log whether those values are still zero or not:

ad->layout = elm_layout_add(ad->win);
elm_layout_theme_set(ad->layout, "layout", "application", "default");
evas_object_size_hint_weight_set(ad->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(ad->layout);

/* Create a Button */
Evas_Object *btn = elm_button_add(ad->layout);
elm_object_text_set(btn, "Test Button");
evas_object_move(btn, 100, 100);
evas_object_resize(btn, 300, 300);
evas_object_show(btn);

evas_object_geometry_get(btn, &ad->x, &ad->y, &ad->w, &ad->h);
dlog_print(DLOG_DEBUG, "test_debug", "%d %d %d %d", ad->x, ad->y, ad->w, ad->h);

Looking forward to hear from you.

Ivan Gualandri

I created a new application and tried your code, and in that case it return the correct values. 

But i still don't understand why in my case doesn't. Consider that the UI is created using the UI-Builder (i don't know if this has some sort of impact).

And the same label that is not moved, nor resized, not touched in any way, the geometry is taken into the onclicked event, it return some values (that looks like correct values). 

But when in the function:

static bool _on_create_cb(void *user_data)

defined as a callback of the event create:

ui_app_lifecycle_callback_s cbs =
    {
		.create = _on_create_cb,
		.terminate = _on_terminate_cb,
		.pause = _on_pause_cb,
		.resume = _on_resume_cb,
		.app_control = _on_app_control_cb,
	};

It returns all 0s. But when i'm creating the layout programmatically it works fine (i think because i'm explicitly setting the geometry in that case. But declaring the layout programmatically is not very handy.

K Johnson

The reason behind getting zeros in your case is, if you don't move or resize any evas object it is placed in zero position (x=0, y=0, w=0, h=0) initially in a new project and I think it's normal.