/**
* @WEARABLE_ONLY
- * @brief Get whether the item can be deleted in the edit mode or not.
+ * @brief Get whether item(s) can be added in the edit mode or not.
*
* @param[in] obj The more option object
- * @see eext_more_option_item_delete_enabled_get()
+ * @see eext_more_option_add_item_enabled_set()
+ * @see eext_more_option_editing_enabled_get()
+ * @see eext_more_option_editing_enabled_set()
+ * @return EINA_TRUE if item(s) can be added, otherwise EINA_FALSE
+ *
+ * @details When add item is enabled, in the editing mode, the add item
+ * is shown at the end of the item list. If users click the add item,
+ * the "add_item,clicked" signal is emitted.
+ *
+ * @if WEARABLE @since_tizen 4.0
+ * @endif
+ */
+EAPI Eina_Bool eext_more_option_add_item_enabled_get(const Evas_Object *obj);
+
+/**
+ * @WEARABLE_ONLY
+ * @brief Set whether item(s) can be added in the edit mode or not.
+ *
+ * @param[in] obj The more option object
+ * @param[in] enabled enable delete item in the edit mode
+ * @see eext_more_option_add_item_enabled_get()
+ * @see eext_more_option_editing_enabled_get()
+ * @see eext_more_option_editing_enabled_set()
+ *
+ * @details When add item is enabled, in the editing mode, the add item
+ * is shown at the end of the item list. If users click the add item,
+ * the "add_item,clicked" signal is emitted.
+ *
+ * @if WEARABLE @since_tizen 4.0
+ * @endif
+ */
+EAPI void eext_more_option_add_item_enabled_set(Evas_Object *obj, Eina_Bool enabled);
+
+/**
+ * @WEARABLE_ONLY
+ * @brief Get whether the item can be deleted in the edit mode or not.
+ *
+ * @param[in] item The more option object item
+ * @see eext_more_option_item_delete_enabled_set()
* @see eext_more_option_editing_enabled_get()
* @see eext_more_option_editing_enabled_set()
* @return EINA_TRUE if item can be deleted, otherwise EINA_FALSE
* @brief Set whether the item can be deleted in the edit mode or not.
* By default, it is enabled.
*
- * @param[in] obj The more option object
+ * @param[in] item The more option object item
* @param[in] enabled enable delete item in the edit mode
* @see eext_more_option_item_delete_enabled_get()
* @see eext_more_option_editing_enabled_get()
/**
* @WEARABLE_ONLY
- * @brief Set whether the item can be deleted in the edit mode or not.
+ * @brief Get whether item(s) can be added in the edit mode or not.
*
* @param[in] obj The rotary selector
+ * @see eext_rotary_selector_add_item_enabled_set()
+ * @see eext_rotary_selector_editing_enabled_set()
+ * @see eext_rotary_selector_editing_enabled_get()
+ * @return EINA_TRUE if item(s) can be added, otherwise EINA_FALSE
+ *
+ * @details When add item is enabled, in the editing mode, the add item
+ * is shown at the end of the item list. If users click the add item,
+ * the "add_item,clicked" signal is emitted.
+ *
+ * @if WEARABLE @since_tizen 4.0
+ * @endif
+ */
+EAPI Eina_Bool eext_rotary_selector_add_item_enabled_get(const Evas_Object *obj);
+
+/**
+ * @WEARABLE_ONLY
+ * @brief Set whether item(s) can be added in the edit mode or not.
+ *
+ * @param[in] obj The rotary selector
+ * @param[in] enabled enable showing add item in editing mode
+ * @see eext_rotary_selector_add_item_enabled_get()
+ * @see eext_rotary_selector_editing_enabled_set()
+ * @see eext_rotary_selector_editing_enabled_get()
+ *
+ * @details When add item is enabled, in the editing mode, the add item
+ * is shown at the end of the item list. If users click the add item,
+ * the "add_item,clicked" signal is emitted.
+ *
+ * @if WEARABLE @since_tizen 4.0
+ * @endif
+ */
+EAPI void eext_rotary_selector_add_item_enabled_set(Evas_Object *obj, Eina_Bool enabled);
+
+/**
+ * @WEARABLE_ONLY
+ * @brief Set whether the item can be deleted in the edit mode or not.
+ *
+ * @param[in] item The rotary selector item
* @param[in] enabled enable delete item in the edit mode
* @see eext_rotary_selector_item_delete_enabled_get()
* @see eext_rotary_selector_editing_enabled_set()
* @WEARABLE_ONLY
* @brief Get whether the item can be deleted in the edit mode or not.
*
- * @param[in] obj The rotary selector
- * @see eext_rotary_selector_item_delete_enabled_get()
+ * @param[in] item The rotary selector item
+ * @see eext_rotary_selector_item_delete_enabled_set()
* @see eext_rotary_selector_editing_enabled_set()
* @see eext_rotary_selector_editing_enabled_get()
* @return EINA_TRUE if item can be deleted, otherwise EINA_FALSE
static void _item_rearrange(Eext_Rotary_Selector_Data *rsd, int selected_index);
static void _item_select(Eext_Rotary_Selector_Data *rsd, int index);
static void _item_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static Eext_Rotary_Selector_Item *_item_create(Eext_Rotary_Selector_Data *rsd);
+static Eext_Rotary_Selector_Item *_item_create(Eext_Rotary_Selector_Data *rsd, Eina_Bool is_add_item);
static void _item_selected_signal_send(Eext_Rotary_Selector_Data *rsd, int previous_item_index, int current_item_index);
static void _item_touched_signal_send(Eext_Rotary_Selector_Data *rsd, int index, Eina_Bool pressed, Eina_Bool sound);
static void _selector_content_update(Eext_Rotary_Selector_Data *rsd);
static void _selector_clicked_signal(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _selector_animation_finished_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
+static void _editing_mode_turnoff(Eext_Rotary_Selector_Data *rsd);
// ----------------------------------------- Accessibility API --------------------------------------//
static Eina_Bool _accessibility_event_area_highlighted_cb(void *data, Evas_Object *obj, Elm_Access_Action_Info *action_info);
int first_index = rsd->current_page * _ROTARY_SELECTOR_PAGE_ITEM_MAX;
const float touchAreaAngle[] = {45.f, 75.f, 105.f, 135.f, 165.f, 195.f,
225.f, 255.f, 285.f, 315.f, 340.f};
+ int count = eina_list_count(rsd->item_list);
//cancel stand timer
if (rsd->stand_timer)
if(angle < touchAreaAngle[i]) break;
}
new_index = first_index + i;
- rsd->drop_item_index = new_index;
- if (new_index != rsd->drag_item_index)
+
+ if ((!rsd->add_enabled && new_index >= count) ||
+ (rsd->add_enabled && new_index >= count - 1))
+ {
+ rsd->drop_item_index = _ROTARY_SELECTOR_PRESSED_ITEM_INDEX_INVALID;
+ }
+ else
{
+ rsd->drop_item_index = new_index;
rsd->stand_timer = ecore_timer_add(rsd->longpress_timeout,
_drag_item_move, rsd);
}
if (yoff) *yoff = rsd->item_height / 2;
- tmp_item = _item_create(rsd);
+ tmp_item = _item_create(rsd, EINA_FALSE);
if (!tmp_item)
return NULL;
evas_object_show(tmp_item->base.obj);
return new_icon;
#endif
-
- ERR("done");
return icon;
}
rsd->pressed_item_index = new_index;
if (rsd->editing)
{
+ int add_idx;
rsd->on_delete_icon = _delete_icon_mouse_on_check(rsd, new_index,
ev->canvas.x, ev->canvas.y);
if (rsd->on_delete_icon)
elm_object_signal_emit(it->base.obj,
"elm,action,button,delete,selected", "");
}
- rsd->drag_item_index = new_index;
if (rsd->longpress_timer)
{
ecore_timer_del(rsd->longpress_timer);
rsd->longpress_timer = NULL;
}
- rsd->longpress_timer = ecore_timer_add(rsd->longpress_timeout,
- _item_longpress_cb, rsd);
+
+ add_idx = eina_list_count(rsd->item_list) - 1;
+ if (!rsd->add_enabled || (new_index != add_idx))
+ {
+ rsd->drag_item_index = new_index;
+ rsd->longpress_timer = ecore_timer_add(rsd->longpress_timeout,
+ _item_longpress_cb, rsd);
+ }
}
else
{
{
if (rsd->editing)
{
+ int add_idx = eina_list_count(rsd->item_list) - 1;
if (rsd->on_delete_icon)
{
Eina_Bool still_on = _delete_icon_mouse_on_check(rsd, new_index, ev->canvas.x, ev->canvas.y);
rsd->item_del_timer = ecore_timer_add(_ROTARY_SELECTOR_DEL_ANIMATION_DURATION, _del_item_timer_cb, rsd);
}
}
+ else if (rsd->add_enabled && (new_index == add_idx))
+ {
+ _editing_mode_turnoff(rsd);
+ evas_object_smart_callback_call(rsd->rotary_selector,
+ "add_item,clicked", NULL);
+ }
}
else
{
}
}
+static void
+_add_item_create(Eext_Rotary_Selector_Data *rsd)
+{
+ Eext_Rotary_Selector_Item *add_item = _item_create(rsd, EINA_TRUE);
+ if (!add_item)
+ return;
+
+ add_item->delete_enabled = EINA_FALSE;
+ rsd->item_list = eina_list_append(rsd->item_list, add_item);
+ add_item->index = rsd->item_count;
+ rsd->item_count++;
+ rsd->add_item = add_item;
+}
+
static Eina_Bool
_editing_timer_cb(void *data)
{
elm_object_part_text_set(elm_object_part_content_get(rsd->rotary_selector, "content"),
"selector,sub_text", "");
rsd->editing = EINA_TRUE;
+ if (rsd->add_enabled)
+ {
+ _add_item_create(rsd);
+
+ _item_rearrange(rsd, rsd->selected_index);
+ _items_transformation_update(rsd);
+ _items_invalidate(rsd);
+ }
_rotary_selector_item_delete_icon_show(rsd);
bg = elm_object_part_content_get(rsd->rotary_selector, "selector,bg_image");
_rotary_selector_item_delete_icon_hide(rsd);
bg = elm_object_part_content_get(rsd->rotary_selector, "selector,bg_image");
elm_object_signal_emit(bg, "elm,selector,bg,show", "elm");
+
+ if (rsd->add_enabled)
+ {
+ rsd->item_list = eina_list_remove(rsd->item_list, rsd->add_item);
+ evas_object_del(rsd->add_item->base.obj);
+ _item_rearrange(rsd, rsd->selected_index);
+ _items_transformation_update(rsd);
+ _items_invalidate(rsd);
+ }
_selector_update(rsd, EINA_FALSE, EINA_FALSE);
+ eext_object_event_callback_del(rsd->rotary_selector, EEXT_CALLBACK_BACK,
+ _back_event_cb);
}
static void
_editing_mode_turnoff(rsd);
rsd->editing = EINA_FALSE;
}
- eext_object_event_callback_del(rsd->rotary_selector, EEXT_CALLBACK_BACK,
- _back_event_cb);
+ else
+ {
+ eext_object_event_callback_del(rsd->rotary_selector, EEXT_CALLBACK_BACK,
+ _back_event_cb);
+ }
}
// ----------------------------------------- item API --------------------------------------//
static void
}
static Eext_Rotary_Selector_Item *
-_item_create(Eext_Rotary_Selector_Data *rsd)
+_item_create(Eext_Rotary_Selector_Data *rsd, Eina_Bool is_add_item)
{
Eext_Rotary_Selector_Item *item = NULL;
Evas_Object *button = NULL;
evas_object_size_hint_weight_set(button,EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_style_set(button, "rotary_selector_item");
+ if (!is_add_item)
+ elm_object_style_set(button, "rotary_selector_item");
+ else
+ elm_object_style_set(button, "rotary_selector_add_item");
evas_object_move(button, -_ROTARY_SELECTOR_SCREEN_WIDTH, -_ROTARY_SELECTOR_SCREEN_HEIGHT);
evas_object_resize(button, rsd->item_width, rsd->item_height);
evas_object_smart_member_add(button, rotary_selector);
- Evas_Object *action_bg = elm_layout_add(button);
- elm_layout_theme_set(action_bg, "rotary_selector", "item", "bg_image");
- elm_object_part_content_set(button, "item,bg_image", action_bg);
+ if (!is_add_item)
+ {
+ Evas_Object *action_bg = elm_layout_add(button);
+ elm_layout_theme_set(action_bg, "rotary_selector", "item", "bg_image");
+ elm_object_part_content_set(button, "item,bg_image", action_bg);
+ }
item = (Eext_Rotary_Selector_Item *)calloc(1, sizeof(Eext_Rotary_Selector_Item));
if (!item)
return NULL;
}
- item = _item_create(rsd);
+ item = _item_create(rsd, EINA_FALSE);
if (!item)
{
ERR("item is NULL!!");
return NULL;
}
- item = _item_create(rsd);
+ item = _item_create(rsd, EINA_FALSE);
if (!item)
{
ERR("item is NULL!!");
return NULL;
}
- item = _item_create(rsd);
+ item = _item_create(rsd, EINA_FALSE);
if (!item)
{
ERR("item is NULL!!");
return NULL;
}
- item = _item_create(rsd);
+ item = _item_create(rsd, EINA_FALSE);
if (!item)
{
ERR("item is NULL!!");
rsd->edit_mode_enabled = enabled;
}
+EAPI Eina_Bool
+eext_rotary_selector_add_item_enabled_get(const Evas_Object *obj)
+{
+ Eext_Rotary_Selector_Data *rsd = _eext_rotary_selector_data_get(obj);
+ if (!rsd)
+ {
+ ERR("rsd is NULL!!");
+ return EINA_FALSE;
+ }
+ return rsd->add_enabled;
+}
+
+EAPI void
+eext_rotary_selector_add_item_enabled_set(Evas_Object *obj, Eina_Bool enabled)
+{
+ Eext_Rotary_Selector_Data *rsd = _eext_rotary_selector_data_get(obj);
+ if (!rsd)
+ {
+ ERR("rsd is NULL!!");
+ return;
+ }
+ rsd->add_enabled = enabled;
+}
+
EAPI Eina_Bool
eext_rotary_selector_item_delete_enabled_get(const Eext_Object_Item *item)
{
rotary_selector_item->delete_enabled = enabled;
}
-
-
// ----------------------------------------- Accessibility API --------------------------------------//
static void
_accessibility_item_btn_highlighted_cb(void *data, Evas_Object *obj, void *event_info)