Languages

Menu
Sites
Language
How to set frame of label in top left corner of watch-app screen

I am new in Tizen native app development. How to set frame of a label in watch-app so that it is placed at top-left, center-left and bottom of the watch-app screen. I checked the button documentation and googled a lot but did not find any solution.

I am aware of 

elm_object_text_set(ad->label, "<align=Center>Hello Tizen</align>");

only.

Edited by: Deepak Thakur on 23 May, 2016

Responses

9 Replies
Nafisul Islam Kiron

You can use

evas_object_size_hint_align_set (     Evas_Object *  	obj,
		double  	x,
		double  	y 
	)
[in] obj The given Evas object to query hints from
[in] x The horizontal alignment hint as double value ranging from 0.0 to 1.0 or with the special value EVAS_HINT_FILL
[in] y The vertical alignment hint as double value ranging from 0.0 to 1.0 or with the special value EVAS_HINT_FILL

These are hints on how to align an object inside the boundaries of a container/manager.

This kinda looks about "SIZE" but it is actually about the "alignment".

 

From here:

https://developer.tizen.org/dev-guide/2.3.1/org.tizen.native.mobile.apireference/group__Evas__Object__Group__Size__Hints.html#ga44b67b368e5cda723129c2852bd81ead

 

Hope that helps.

Deepak Thakur

I added evas_object_size_hint_align_set inside create_base_gui method as follows

ad->label = elm_label_add(ad->conform);

elm_object_text_set(ad->label, "<align=Center>Hello Tizen</align>");

//evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

elm_object_content_set(ad->conform, ad->label);

evas_object_size_hint_align_set(ad->label, 0.5, 0.5);

As per the documentation, Hello Tizen should be at the center, but the label is in top left corner. Please let me know where am I going wrong?

 

Nafisul Islam Kiron

Please try like this:

Evas_Object *box;

box = elm_box_add(parent);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_padding_set(box, 0, 5 * elm_config_scale_get());
evas_object_show(box);

 

Deepak Thakur

I am new to this. I tried following but still did not solve the issue.

 

static void

create_base_gui(appdata_s *ad)

{

/* Window */

    ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);

    elm_win_autodel_set(ad->win, EINA_TRUE);

 

if (elm_win_wm_rotation_supported_get(ad->win)) {

        int rots[4] = { 0, 90, 180, 270 };

        elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);

    }

 

    evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);

eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);

 

/* Conformant */

    ad->conform = elm_conformant_add(ad->win);

elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);

elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);

    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

elm_win_resize_object_add(ad->win, ad->conform);

evas_object_show(ad->conform);

 

/* Label */

    ad->label = elm_label_add(ad->conform);

    elm_object_text_set(ad->label, "<align=Center>Hello Tizen</align>");

    evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

    elm_object_content_set(ad->conform, ad->label);

evas_object_size_hint_align_set(ad->label, 0.5, 0.5);

 

Evas_Object *box;

 

    box = elm_box_add(ad->label);

    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

    evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);

elm_box_padding_set(box, 0, 5 * elm_config_scale_get());

    elm_object_text_set(ad->label, "<align=Center>Hello Tizen</align>");

evas_object_show(box);

 

/* Show window after base gui is set up */

evas_object_show(ad->win);

}

Chanwook Jung

How about using elm_grid?

Deepak Thakur

Where shall I use elm_grid?

Deepak Thakur
Where shall I use elm_grid?
Nafisul Islam Kiron
static Evas_Object*
create_grid_view(Evas_Object *parent)
{
   Evas_Object *grid, *item;

   grid = elm_grid_add(parent);
   evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);

   // Red background for the grid
   item = create_bg(grid, 255, 0, 0);
   elm_grid_pack(grid, item, 0, 0, 100, 100);

   // Add the item to the grid
   item = create_content(grid, "Item1");
   elm_grid_pack(grid, item, 1, 1, 98, 98);

   item = create_content(grid, "Item2");
   elm_grid_pack(grid, item, 2, 5, 20, 20);

   item = create_content(grid, "Item3");
   elm_grid_pack(grid, item, 23, 5, 76, 94);

   item = create_content(grid, "Item4");
   elm_grid_pack(grid, item, 2, 27, 20, 70);

   // Black background for the box view item
   item = create_bg(grid, 40, 40, 40);
   elm_grid_pack(grid, item, 25, 10, 73, 87);

   // Add the box view item to the grid
   item = create_box_view(grid);
   evas_object_show(item);
   elm_grid_pack(grid, item, 26, 11, 71, 85);

   return grid;
}

From here: https://developer.tizen.org/ko/development/ui-practices/native-application/efl/ui-containers/creating-ui-screen-layouts?langredirect=1

Deepak Thakur

I added the above and build the project. I get compile time errors as follows

item = create_bg(grid, 255, 0, 0); //Compile time error: implicit declaration of function 'create_bg' is invalid in C99
//Invalid integer to pointer conversion assigning to 'Evas_Object*' (aka struct _Evas_Object*) from 'int' [-Wint-conversion]

item = create_content(grid, "Item2"); //Warning: Invalid integer to pointer conversion assigning to 'Evas_Object*' (aka struct _Evas_Object*) from 'int' [-Wint-conversion]