#include <Elementary.h>
#include "elm_priv.h"
+#include "els_scroller.h"
typedef struct _Widget_Data Widget_Data;
elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
elm_scroller_child_size_get(obj, &max_x, &max_y);
- if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
+ if ((!strcmp(ev->keyname, "Left")) ||
+ ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
{
x -= step_x;
}
- else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
+ else if ((!strcmp(ev->keyname, "Right")) ||
+ ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
{
x += step_x;
}
- else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
+ else if ((!strcmp(ev->keyname, "Up")) ||
+ ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
{
y -= step_y;
}
- else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
+ else if ((!strcmp(ev->keyname, "Down")) ||
+ ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
{
y += step_y;
}
- else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home")))
+ else if ((!strcmp(ev->keyname, "Home")) ||
+ ((!strcmp(ev->keyname, "KP_Home")) && (!ev->string)))
{
y = 0;
}
- else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End")))
+ else if ((!strcmp(ev->keyname, "End")) ||
+ ((!strcmp(ev->keyname, "KP_End")) && (!ev->string)))
{
y = max_y - v_h;
}
- else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
+ else if ((!strcmp(ev->keyname, "Prior")) ||
+ ((!strcmp(ev->keyname, "KP_Prior")) && (!ev->string)))
{
if (page_y < 0)
y -= -(page_y * v_h) / 100;
else
y -= page_y;
}
- else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
+ else if ((!strcmp(ev->keyname, "Next")) ||
+ ((!strcmp(ev->keyname, "KP_Next")) && (!ev->string)))
{
if (page_y < 0)
y += -(page_y * v_h) / 100;
if (!wd) return;
if (elm_widget_focus_get(obj))
{
- edje_object_signal_emit(wd->scr, "elm,action,focus", "elm");
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
evas_object_focus_set(wd->scr, EINA_TRUE);
}
else
{
- edje_object_signal_emit(wd->scr, "elm,action,unfocus", "elm");
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
evas_object_focus_set(wd->scr, EINA_FALSE);
}
}
cur = wd->content;
/* Try Focus cycle in subitem */
- if ((elm_widget_can_focus_get(cur)) || (elm_widget_child_can_focus_get(cur)))
- return elm_widget_focus_next_get(cur, dir, next);
+ if (elm_widget_focus_get(obj))
+ {
+ if ((elm_widget_can_focus_get(cur)) || (elm_widget_child_can_focus_get(cur)))
+ return elm_widget_focus_next_get(cur, dir, next);
+ }
/* Return */
*next = (Evas_Object *)obj;
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord vw, vh, minw = 0, minh = 0, maxw = 0, maxh = 0, w, h, vmw, vmh;
+ Evas_Coord vw = 0, vh = 0, minw = 0, minh = 0, maxw = 0, maxh = 0, w, h, vmw, vmh;
double xw = 0.0, yw = 0.0;
if (!wd) return;
evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
}
+Evas_Object *
+_elm_scroller_edje_object_get(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return elm_smart_scroller_edje_object_get(wd->scr);
+}
+
+static void
+_content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd;
+ if (part && strcmp(part, "default")) return;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->content == content) return;
+ if (wd->content) evas_object_del(wd->content);
+ wd->content = content;
+ if (content)
+ {
+ elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
+ elm_widget_sub_object_add(obj, content);
+ if (wd->scr)
+ elm_smart_scroller_child_set(wd->scr, content);
+ evas_object_event_callback_add(content,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ }
+ _sizing_eval(obj);
+}
+
+static Evas_Object *
+_content_get_hook(const Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd;
+ if (part && strcmp(part, "default")) return NULL;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ return wd->content;
+}
+
+static Evas_Object *
+_content_unset_hook(Evas_Object *obj, const char *part)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd;
+ Evas_Object *content;
+ if (part && strcmp(part, "default")) return NULL;
+ wd = elm_widget_data_get(obj);
+ if (!wd) return NULL;
+ if (!wd->content) return NULL;
+ content = wd->content;
+ elm_widget_sub_object_del(obj, wd->content);
+ evas_object_event_callback_del_full(wd->content,
+ EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, obj);
+ edje_object_part_unswallow(elm_smart_scroller_edje_object_get(wd->scr),
+ wd->content);
+ wd->content = NULL;
+ return content;
+}
+
EAPI Evas_Object *
elm_scroller_add(Evas_Object *parent)
{
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_event_hook_set(obj, _event_hook);
elm_widget_focus_region_hook_set(obj, _focus_region_hook);
+ elm_widget_content_set_hook_set(obj, _content_set_hook);
+ elm_widget_content_get_hook_set(obj, _content_get_hook);
+ elm_widget_content_unset_hook_set(obj, _content_unset_hook);
wd->widget_name = eina_stringshare_add("scroller");
wd->widget_base = eina_stringshare_add("base");
return obj;
}
-Evas_Object *
-_elm_scroller_edje_object_get(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return elm_smart_scroller_edje_object_get(wd->scr);
-}
-
-EAPI void
-elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (wd->content == content) return;
- if (wd->content) evas_object_del(wd->content);
- wd->content = content;
- if (content)
- {
- elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
- elm_widget_sub_object_add(obj, content);
- if (wd->scr)
- elm_smart_scroller_child_set(wd->scr, content);
- evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _changed_size_hints, obj);
- }
- _sizing_eval(obj);
-}
-
-EAPI Evas_Object *
-elm_scroller_content_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- return wd->content;
-}
-
-EAPI Evas_Object *
-elm_scroller_content_unset(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Object *content;
- if (!wd) return NULL;
- if (!wd->content) return NULL;
- content = wd->content;
- elm_widget_sub_object_del(obj, wd->content);
- edje_object_part_unswallow(wd->scr, wd->content);
- wd->content = NULL;
- return content;
-}
-
EAPI void
elm_scroller_custom_widget_base_theme_set(Evas_Object *obj, const char *widget, const char *base)
{
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- const Elm_Scroller_Policy map[3] =
- {
- ELM_SMART_SCROLLER_POLICY_AUTO,
- ELM_SMART_SCROLLER_POLICY_ON,
- ELM_SMART_SCROLLER_POLICY_OFF
- };
if ((!wd) || (!wd->scr)) return;
- if ((policy_h >= 3) || (policy_v >= 3)) return;
- elm_smart_scroller_policy_set(wd->scr, map[policy_h], map[policy_v]);
+ if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
+ (policy_v >= ELM_SCROLLER_POLICY_LAST))
+ return;
+ elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
}
EAPI void
}
EAPI void
+elm_scroller_current_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->scr)
+ elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber);
+}
+
+EAPI void
+elm_scroller_last_page_get(const Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->scr)
+ elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber);
+}
+
+EAPI void
+elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->scr)
+ elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber);
+}
+
+EAPI void
+elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+ if (wd->scr)
+ elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber);
+}
+
+EAPI void
elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- elm_smart_scroller_propagate_events_set(wd->scr, propagation);
+ evas_object_propagate_events_set(wd->scr, propagation);
}
EAPI Eina_Bool
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
- return elm_smart_scroller_propagate_events_get(wd->scr);
+ return evas_object_propagate_events_get(wd->scr);
}
EAPI void
elm_smart_scroller_gravity_get(wd->scr, x, y);
}
-
-EAPI void
-elm_scroller_page_move_set(Evas_Object *obj, Eina_Bool set)
-{
- return ;
-}