Languages

Menu
Sites
Language
Problem with align GUI components.

Hi to all, I am trying to put a label aligned to the top and a button in the middle, I have this code: (My target is mobile 2.4)

    ad->label = elm_label_add(ad->conform);
    elm_object_text_set(ad->label, "<align=center>Waiting GPS status</align>");
    evas_object_size_hint_weight_set(ad->label, 0.5, 0.5);
    evas_object_size_hint_align_set(ad->label, 0.0, 0.0);
    elm_object_content_set(ad->conform, ad->label);
    ad->btn = elm_button_add(ad->conform);
    elm_object_text_set(ad->btn, "Button");
    evas_object_smart_callback_add(ad->btn, "clicked", btn_clicked_cb, ad);
    evas_object_size_hint_weight_set(ad->btn, 0.3, 0.3);
    evas_object_size_hint_align_set(ad->btn, 0.5, 0.5);
    elm_object_content_set(ad->conform, ad->btn);

  
    evas_object_show(ad->win);

Well, you can see only one super huge button in the screen covering everything.

I couldnt find any compilable example for API 2.4 in the ducumentation for play with values and underestand how is working.

Please, cuuld anyone help me? Thanks!

Responses

3 Replies
Carlos Dominguez

Actually this also not make any change...

ad->label = elm_label_add(ad->conform);
    elm_object_text_set(ad->label, "<align=center>Waiting GPS status</align>");
    evas_object_move(ad->label, 0, 50);
    evas_object_resize(ad->label, 600, 80);
    elm_object_content_set(ad->conform, ad->label);

    /* Button */
    ad->btn = elm_button_add(ad->conform);
    elm_object_text_set(ad->btn, "Button");
    evas_object_smart_callback_add(ad->btn, "clicked", btn_clicked_cb, ad);
    evas_object_move(ad->btn, 0, 200);
    evas_object_resize(ad->btn, 300, 80);
    elm_object_content_set(ad->conform, ad->btn);

    /* Show window after base gui is set up */
    evas_object_show(ad->win);

The button still covering everything!

Mehedi Alamgir

Hi Carlos

i always use box container to display widgets on the screen. I can control widgets in box container easily.

The following  function is used to add widget in box and use that function for every widget.

static void pack(Evas_Object *b, Evas_Object *c, double h_weight,double v_weight,double h_align,double v_align)
{

	Evas_Object *frame = elm_frame_add(b);
	elm_object_style_set(frame,"pad_small");
	evas_object_size_hint_weight_set(frame,h_weight,v_weight);	
	evas_object_size_hint_align_set(frame,h_align,v_align);	
	evas_object_size_hint_weight_set(c,EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(c,EVAS_HINT_FILL,EVAS_HINT_FILL);	
	evas_object_show(c);	
	elm_object_content_set(frame,c);
	elm_box_pack_end(b,frame);
	evas_object_show(frame);	
	elm_box_pack_end(b,frame);

}

Here

h_weight value range: 0-1
v_weight value range: 0-1
h_align value : 0.0 = left. 0.5 = center. 1.0 = right. -1 = full
v_align value : 0.0 = top. 0.5 = middle. 1.0 = bottom. -1 = full

If elm_frame_add() shows error , goto project header file --> efl_extension.h --> elm_frame.h, then remove the comment of following line
EAPI Evas_Object   *elm_frame_add(Evas_Object *parent) ;

Now from create_base_gui() function call  the above function after creating a widget.

 ad->label = elm_label_add(ad->conform);
 elm_object_text_set(ad->label, "<align=center>Waiting GPS status</align>");
 pack(box,ad->label,0.0,0.0,0.0,0.0);

 ad->btn = elm_button_add(ad->conform);
 elm_object_text_set(ad->btn, "Button");
 evas_object_smart_callback_add(ad->btn, "clicked", btn_clicked_cb, ad);	 
 pack(box,ad->btn,0.0,1.0,-1.0,0.0);

 

Carlos Dominguez

Thanks a lot. But

elm_frame_add

Is not defined, at las in Elementary.h of TizenSDK 2.4, I guess is deprecated because is commented. However, is solver, you are right, using box is the solution (without frame...). I finnish the first funtional code of a GPS tracker who can write GPX files, maybe you wanna have a look and make any suggestion or contribution, is GPL.

https://github.com/zipotron/Tizen-GPS-trackRecorder

Thanks a lot