0

I'm trying to write a widget for Tizen platform. Layout of the widget is described in a EDC file. I needed a block, which contains some text and image parts, to be repeated three times with different text labels. So I decided that I need to create a group with required parts and use it as item in a box part:

group {
    name: "list_item";

    parts {
        part {
            name: "label1";
            type: "TEXT";

            description { ...  }
        }

        part {
            name: "label2";
            type: "TEXT";

            description { ... }
        }
    }
}

group {
    name: "content";

    parts {
        part {
            name: "list";
            type: "BOX";

            box {
                items {
                    item {
                        type: "GROUP";
                        name: "item1";
                        source: "list_item";
                    }

                    item {
                        type: "GROUP";
                        name: "item2";
                        source: "list_item";
                    }

                    item {
                        type: "GROUP";
                        name: "item3";
                        source: "list_item";
                    }
                }
            }

            description { ... }
        }
    }
}

For static text parts, which are placed in primary layout group content, I use elm_object_part_text_set(wid->content, part_name, text) (the language is C, btw), but can't figure out how to set text of label1 part of each instance of list_item.

unnamed777
  • 11
  • 2
  • Tizen does not guide using Box type parts. Related APIs are internal APIs defined in open source and cannot be used in applications. how about create one item layout using edc and put it in elm_box? – Woochan Lee Mar 12 '21 at 04:18
  • Could you show me please where is says that Box related api are internal? I haven't seen such notices yet. I thought if the EDC part is [described](https://docs.tizen.org/application/native/guides/ui/efl/learn-edc-part/), then it can be used and could be somehow accessible from a code. Finally I found this [api](https://docs.tizen.org/application/native/api/wearable/5.5/group__Evas__Object__Box__Group.html) and looks like it's public. But I'm a newbie in Tizen development and this jujdement could be incorrect. – unnamed777 Mar 13 '21 at 08:06

2 Answers2

1

How about using swallow instead of group?

When creating a complex layout using EDC, it can be easily implemented by using a swallow.

In c code, you can set elm_label to swallow content.

And you can also set content to swallow the box after add 2 elm_labels in the box

Or you can create a more complex layout and set the layout to content in swallow. (like your group "list_item").

in EDC :

   group { "list";
      parts {
         swallow { "item1";
            desc { "default";
                ...
            }
         }
         swallow { "item2";
            desc { "default";
                ...
            }
         }
         swallow { "item3";
            desc { "default";
                ...
            }
         }
      }
   }

in C code :

/* ex 1 */
elm_object_part_content_set(layout, "item1", label1);
elm_object_part_content_set(layout, "item2", label2);
elm_object_part_content_set(layout, "item2", label3);

/* ex */
elm_box_pack_end(box, label1);
elm_box_pack_end(box, label2);
elm_object_part_content_set(layout, "item1", box);

/* ex 3 */
elm_object_part_text_set(list_item, "label1", "Text 1 ...");
elm_object_part_text_set(list_item, "label2", "Text 2 ...");
elm_object_part_content_set(layout, "item1", list_item);
  • Probably my approach is wrong. I need a row with three complex blocks and these blocks should be distributed horizontally as `BOX` does. Because `BOX` part allows to use `GROUP` item type only, I used `group` to define my complex block. The idea was to describe the layout entirely in EDC file using `group`s for repeating blocks and set all non-static texts and values via C. Thanks for the suggestion, I'll read about `swallow`. – unnamed777 Mar 13 '21 at 07:47
0

I found a solution. I'm not sure it's a right one, but it works.

// widget_instance_data_s *widget_instance
// Get part by name as object
Evas_Object *evas_list = (Evas_Object*) edje_object_part_object_get(elm_layout_edje_get(widget_instance->content), "list");
// Get items of box
Eina_List *items = evas_object_box_children_get(evas_list);
int items_count = eina_list_count(items);

for (i = 0; i < items_count; i++) {
    list_item = (Evas_Object *) eina_list_nth(items, i);
    // item1, item2, ...
    item_name = evas_object_name_get(list_item);
    ...
    edje_object_part_text_set(list_item, "label1", str);
}
unnamed777
  • 11
  • 2