Evas_Object *genlist;
Elm_Object_Item *first;
+ Elm_Object_Item *refresh;
Elm_Object_Item *last;
- Elm_Genlist_Item_Class *itc;
+ Elm_Genlist_Item_Class *car_itc;
} s_connect_to_car;
static s_connect_to_car s_info = { {0,}, };
+static void _create_default_genlist_items();
+
static void _layout_back_cb(void *data, Evas_Object *obj, void *event_info)
{
elm_win_lower(view_manager_get_win());
return NULL;
}
-static void _create_guard_items(void)
+Elm_Genlist_Item_Class *_create_genlist_item_class(char *style,
+ Elm_Gen_Item_Text_Get_Cb text_get_cb,
+ Elm_Gen_Item_Content_Get_Cb content_get_cb,
+ Elm_Gen_Item_Del_Cb del_cb)
{
- Elm_Gengrid_Item_Class* itc1 = elm_genlist_item_class_new();
- ASSERT_MEMORY(!itc1);
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ ASSERT_MEMORY(!itc);
- itc1->item_style = "title";
- itc1->func.text_get = _genlist_set_text_cb;
+ itc->item_style = style;
+ itc->func.text_get = text_get_cb;
+ itc->func.content_get = content_get_cb;
+ itc->func.del = del_cb;
+
+ return itc;
+}
+
+static void _create_guard_items(void)
+{
+ Elm_Gengrid_Item_Class* itc1 = _create_genlist_item_class("title", _genlist_set_text_cb, NULL, NULL);
s_info.first = elm_genlist_item_append(s_info.genlist, itc1, "<color=#F0233D font_size=30>Select a car</color>", NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
s_info.last = elm_genlist_item_append(s_info.genlist, itc1, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_select_mode_set(s_info.last, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
}
+static void _refresh_button_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_genlist_clear(s_info.genlist);
+ _create_default_genlist_items();
+ controller_car_selection_start_get_car_names();
+}
+
+static Evas_Object *_full_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *button = view_base_create_button(obj, NULL, "Refresh", NULL, "racing_middle", _refresh_button_clicked, NULL);
+
+ evas_object_size_hint_min_set(button, 0, 80);
+ return button;
+}
+
+static void _create_refresh_item(void)
+{
+ Elm_Gengrid_Item_Class* itc = _create_genlist_item_class("full", NULL, _full_content_get_cb, NULL);
+ s_info.refresh = elm_genlist_item_insert_before(s_info.genlist, itc, NULL, NULL,
+ s_info.last,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+}
+
static void _job_cb(void *data)
{
Elm_Object_Item *central = elm_genlist_at_xy_item_get(s_info.genlist, 180, 180, NULL);
evas_object_smart_callback_add(s_info.genlist, "drag,stop", _genlist_scroll_cb, (void *)SCROLL_DRAG_STOP);
}
-void _set_circular_parameters(Eext_Circle_Surface* circle_surface)
+
+static void _create_default_genlist_items()
+{
+ _create_guard_items();
+ _create_refresh_item();
+ _add_scroll_end_callbacks();
+}
+
+static void _set_circular_parameters(Eext_Circle_Surface* circle_surface)
{
bool is_circular = false;
system_info_get_platform_bool("http://tizen.org/feature/screen.shape.circle", &is_circular);
_set_circular_parameters(circle_surface);
- s_info.itc = elm_genlist_item_class_new();
- ASSERT_MEMORY(!s_info.itc);
-
- s_info.itc->item_style = "racing_list_item";
- s_info.itc->func.text_get = _genlist_car_set_text_cb;
+ s_info.car_itc = _create_genlist_item_class("racing_list_item", _genlist_car_set_text_cb, NULL, NULL);
elm_layout_content_set(s_info.view_base.view, "list", s_info.genlist);
-
- _create_guard_items();
- _add_scroll_end_callbacks();
+ _create_default_genlist_items();
}
static void _genlist_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
elm_layout_signal_emit(s_info.view_base.view, "cars.found", "");
int ind = elm_genlist_items_count(s_info.genlist) - START_LIST_ITEMS_NUMBER;
- elm_genlist_item_insert_before(s_info.genlist, s_info.itc, data, NULL,
- s_info.last,
+ elm_genlist_item_insert_before(s_info.genlist, s_info.car_itc, data, NULL,
+ s_info.refresh,
ELM_GENLIST_ITEM_NONE, _genlist_item_selected_cb, (void *)ind);
}
}
-static void _refresh_button_clicked(void *data, Evas_Object *obj, void *event_info)
-{
- controller_car_selection_start_get_car_names();
-}
-
static void _car_selection_create_gui(Evas_Object *parent, Eext_Circle_Surface *circle_surface)
{
s_info.view_base.view = view_base_create_layout(parent, "edje/car_selection.edj", GRP_MAIN);