Languages

Menu
Sites
Language
Setting Time Sample

How can I add a label into layout with "circle" "datetime" theme? When I add a label as elm_object_part_content_set(layout, "elm.swallow.content", label) I can't click a button, which I added before or after as elm_object_part_content_set(layout, "elm.swallow.btn", button).

Edited by: Oleksander Orel on 20 Oct, 2015
View Selected Answer

Responses

10 Replies
colin Rao

it's nice if you can share your sample code here. i can't debug/testing without sample code. :)

Oleksander Orel
Here is main code of functions which I try to use.

typedef struct appdata { Evas_Object *win; Evas_Object *conform; Evas_Object *nf; Evas_Object *datetime; Eext_Circle_Surface *circle_surface; } appdata_s; static void set_clicked_cb(void *data, Evas_Object *obj, void *event_info) { appdata_s *ad = data; elm_naviframe_item_pop(ad->nf); } static void create_main_view(appdata_s *ad) { Evas_Object *button = NULL; Evas_Object *layout = NULL; Evas_Object *circle_datetime = NULL; Elm_Object_Item *nf_it = NULL; layout = elm_layout_add(ad->nf); elm_layout_theme_set(layout, "layout", "circle", "datetime"); Evas_Object *label = elm_label_add(layout); elm_object_style_set(label, "label"); elm_object_text_set(label, "Duration: "); elm_object_part_content_set(layout, "elm.swallow.content", label); evas_object_show(label); /* Button */ button = elm_button_add(layout); elm_object_style_set(button, "bottom"); elm_object_text_set(button, "Set"); evas_object_show(button); elm_object_part_content_set(layout, "elm.swallow.btn", button); evas_object_smart_callback_add(button, "clicked", set_clicked_cb, ad); elm_object_part_text_set(layout, "elm.text", "Set time"); /* Timepicker */ // ad->datetime = elm_datetime_add(layout); // circle_datetime = eext_circle_object_datetime_add(ad->datetime, ad->circle_surface); // elm_datetime_value_set(ad->datetime, &ad->saved_time); // elm_object_style_set(ad->datetime, "timepicker/circle"); // elm_object_part_content_set(layout, "elm.swallow.content", ad->datetime); // evas_object_smart_callback_add(ad->datetime, "changed", _volume_changed_cb, layout); // eext_rotary_object_event_activated_set(circle_datetime, EINA_TRUE); nf_it = elm_naviframe_item_push(ad->nf, "Time picker", NULL, NULL, layout, NULL); elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE); } 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); evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); // Conformant ad->conform = elm_conformant_add(ad->win); 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); // Naviframe ad->nf = elm_naviframe_add(ad->conform); create_main_view(ad); elm_object_content_set(ad->conform, ad->nf); eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL); // Add a surface for the circle object ad->circle_surface = eext_circle_surface_naviframe_add(ad->nf); /* Show window after base gui is set up */ evas_object_show(ad->win); }

Oleksander Orel

Sorry for bad input. There is no preview and I can't edit posted message :(

Oleksander Orel
typedef struct appdata 
​{
   Evas_Object *win;
   Evas_Object *conform;
   Evas_Object *nf;
   Evas_Object *datetime;
   Eext_Circle_Surface *circle_surface;
} appdata_s;

static void
set_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
   appdata_s *ad = data;

   elm_naviframe_item_pop(ad->nf);
}

static void
create_main_view(appdata_s *ad)
{
   Evas_Object *button = NULL;
   Evas_Object *layout = NULL;
   Evas_Object *circle_datetime = NULL;
   Elm_Object_Item *nf_it = NULL;

   layout = elm_layout_add(ad->nf);
   elm_layout_theme_set(layout, "layout", "circle", "datetime");

   Evas_Object *label = elm_label_add(layout);
   elm_object_style_set(label, "label");
   elm_object_text_set(label, "<align=center><font_size=32>Duration: </font_size></align>");
   elm_object_part_content_set(layout, "elm.swallow.content", label);
   evas_object_show(label);

   /* Button */
   button = elm_button_add(layout);
   elm_object_style_set(button, "bottom");
   elm_object_text_set(button, "Set");
   evas_object_show(button);
   elm_object_part_content_set(layout, "elm.swallow.btn", button);
   evas_object_smart_callback_add(button, "clicked", set_clicked_cb, ad);


   elm_object_part_text_set(layout, "elm.text", "Set time");

   /* Timepicker */
   //   ad->datetime = elm_datetime_add(layout);
   //   circle_datetime = eext_circle_object_datetime_add(ad->datetime, ad->circle_surface);
   //   elm_datetime_value_set(ad->datetime, &ad->saved_time);
   //   elm_object_style_set(ad->datetime, "timepicker/circle");
   //   elm_object_part_content_set(layout, "elm.swallow.content", ad->datetime);
   //   evas_object_smart_callback_add(ad->datetime, "changed", _volume_changed_cb, layout);
   //   eext_rotary_object_event_activated_set(circle_datetime, EINA_TRUE);

   nf_it = elm_naviframe_item_push(ad->nf, "Time picker", NULL, NULL, layout, NULL);
   elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
}

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);

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

   // Conformant
   ad->conform = elm_conformant_add(ad->win);
   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);

   // Naviframe
   ad->nf = elm_naviframe_add(ad->conform);
   create_main_view(ad);
   elm_object_content_set(ad->conform, ad->nf);
   eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
   
   // Add a surface for the circle object
   ad->circle_surface = eext_circle_surface_naviframe_add(ad->nf);

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

 

Mark as answer
Jeongsu Kim

Unfortunately, "elm.swallow.btn" is under the "elm.swallow.content" so button can't get mouse event.

https://review.tizen.org/git/?p=framework/uifw/efl-theme-tizen.git;a=blob;f=2.3-wearable-circle/widgets/layout.edc;h=6135a792f58cd604e725be14d30ab4c5f5699acb#l2476

But you can pass event below using evas_object_repeat_events_set on label widget.

   Evas_Object *label = elm_label_add(layout);
   elm_object_style_set(label, "label");
   elm_object_text_set(label, "<align=center><font_size=32>Duration: </font_size></align>");
   elm_object_part_content_set(layout, "elm.swallow.content", label);
   evas_object_repeat_events_set(label, EINA_TRUE);
   evas_object_show(label);

 

Alex Dem

Hi,
fyi, but looks like in Native UI FW app example -> UI Components->Eext Dataime
"clicked" works for  elm_button even if elm_datatime object was set into "elm.swallow.content" using elm_object_part_content_set
Alexey.

Oleksander Orel

Exactly. That's why I was surprised such behavior of the label element. But anyway, my final target was add label and datetime at the same time. Unfortunately, it's impossible in this layout theme.

Jeongsu Kim

You can add label and datetime at the same time with an EDC file.

   group {
      name: "content";
      parts {
         part {
             name: "datetime";
         	type: SWALLOW;
         	repeat_events: 1;
         	description {
         	   state: "default" 0.0;
         	}
         }
         part {
         	name: "label";
         	type: SWALLOW;
         	repeat_events: 1;
         	description {
         	   state: "default" 0.0;
         	}
         }
      }
   }

 

Add an layout object that uses above edc then add label and datetime to the label like below.

   Evas_Object* content_layout = elm_layout_add(layout);

   char edj_path[PATH_MAX] = {0, };
   app_get_resource("edje/basicuiapplication.edj", edj_path, (int)PATH_MAX);
   elm_layout_file_set(content_layout, edj_path, "content");
   elm_object_part_content_set(layout, "elm.swallow.content", content_layout);

   Evas_Object *label = elm_label_add(layout);
   elm_object_style_set(label, "label");
   elm_object_text_set(label, "<align=center><font_size=32>Duration: </font_size></align>");
//   evas_object_repeat_events_set(label, EINA_TRUE);
   elm_object_part_content_set(content_layout, "label", label);
   evas_object_show(label);

   /* Timepicker */
      ad->datetime = elm_datetime_add(layout);
      circle_datetime = eext_circle_object_datetime_add(ad->datetime, ad->circle_surface);
//      elm_datetime_value_set(ad->datetime, &ad->saved_time);
      elm_object_style_set(ad->datetime, "timepicker/circle");
//      elm_object_part_content_set(layout, "elm.swallow.content", ad->datetime);
      elm_object_part_content_set(content_layout, "datetime", ad->datetime);
//      evas_object_smart_callback_add(ad->datetime, "changed", _volume_changed_cb, layout);
      eext_rotary_object_event_activated_set(circle_datetime, EINA_TRUE);

I commented out some lines to fix build break but I think it's enough.

Oleksander Orel

Thank you very much! This and previous advices have solved my problem. Now I can implement needed functionality!

Palitsyna

Hello,

try to use the code, provided by Joengsu Kim. And just FYI, here you can find information about evas_object_repeat_events_set:  https://developer.tizen.org/dev-guide/2.3.1/org.tizen.native.mobile.apireference/group__Evas__Object__Group__Events.html#ga0b2c5324c7d3927f96949c2d2488e3e9