hooks.
The former is now issued for all scrollables, with the behavior it had
before, and the latter is a new virtual base function, with a default
implementation leading to values matching the old case where one
didn't implement the hook.
Please help me test if everything is OK -- it seems so, here.
SVN revision: 75904
}
static void
-_on_focus_region_hook(const Evas_Object *obj,
- Evas_Coord *x,
- Evas_Coord *y,
- Evas_Coord *w,
- Evas_Coord *h)
+_elm_entry_smart_on_focus_region(const Evas_Object *obj,
+ Evas_Coord *x,
+ Evas_Coord *y,
+ Evas_Coord *w,
+ Evas_Coord *h)
{
ELM_ENTRY_DATA_GET(obj, sd);
}
static void
-_focus_region_hook(Evas_Object *obj,
- Evas_Coord x,
- Evas_Coord y,
- Evas_Coord w,
- Evas_Coord h)
-{
- ELM_ENTRY_DATA_GET(obj, sd);
-
- if (sd->scroll)
- sd->s_iface->content_region_show(obj, x, y, w, h);
-}
-
-static void
_show_region_hook(void *data,
Evas_Object *obj)
{
elm_layout_text_set(obj, "elm.text", "");
- elm_widget_focus_region_hook_set(obj, _focus_region_hook);
- elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
elm_object_sub_cursor_set
(ELM_WIDGET_DATA(priv)->resize_obj, obj, ELM_CURSOR_XTERM);
elm_widget_can_focus_set(obj, EINA_TRUE);
ELM_WIDGET_CLASS(sc)->base.resize = _elm_entry_smart_resize;
ELM_WIDGET_CLASS(sc)->base.member_add = _elm_entry_smart_member_add;
+ ELM_WIDGET_CLASS(sc)->on_focus_region = _elm_entry_smart_on_focus_region;
ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_entry_smart_sub_object_del;
ELM_WIDGET_CLASS(sc)->on_focus = _elm_entry_smart_on_focus;
ELM_WIDGET_CLASS(sc)->theme = _elm_entry_smart_theme;
}
static void
-_focus_region_hook(Evas_Object *obj,
- Evas_Coord x,
- Evas_Coord y,
- Evas_Coord w,
- Evas_Coord h)
-{
- ELM_SCROLLER_DATA_GET(obj, sd);
-
- sd->s_iface->content_region_show(obj, x, y, w, h);
-}
-
-static void
_changed_size_hints_cb(void *data,
Evas *e __UNUSED__,
Evas_Object *obj __UNUSED__,
evas_object_show(priv->hit_rect);
evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
- /* FIXME: rework it */
- elm_widget_focus_region_hook_set(obj, _focus_region_hook);
-
priv->s_iface = evas_object_smart_interface_get
(obj, ELM_SCROLLABLE_IFACE_NAME);
return EINA_TRUE;
}
+static void
+_elm_widget_on_focus_region_func(const Evas_Object *obj,
+ Evas_Coord *x,
+ Evas_Coord *y,
+ Evas_Coord *w,
+ Evas_Coord *h)
+{
+ evas_object_geometry_get(obj, NULL, NULL, w, h);
+ if (x) *x = 0;
+ if (y) *y = 0;
+}
+
static Eina_Bool
_elm_widget_on_focus_func_unimplemented(Evas_Object *obj)
{
API_DEFAULT_SET_UNIMPLEMENTED(on_focus);
API_DEFAULT_SET_UNIMPLEMENTED(disable);
- api->theme = _elm_widget_theme_func;
+ API_DEFAULT_SET(theme);
+ API_DEFAULT_SET(on_focus_region);
API_DEFAULT_SET_UNIMPLEMENTED(translate);
API_DEFAULT_SET_UNIMPLEMENTED(event);
_elm_widget_focus_region_show(const Evas_Object *obj)
{
Evas_Coord x, y, w, h, ox, oy;
- Elm_Widget_Smart_Data *sd2;
Evas_Object *o;
API_ENTRY return;
elm_widget_focus_region_get(obj, &x, &y, &w, &h);
evas_object_geometry_get(obj, &ox, &oy, NULL, NULL);
+
while (o)
{
Evas_Coord px, py;
- sd2 = evas_object_smart_data_get(o);
- if (sd2->focus_region)
+
+ if (_elm_scrollable_is(o))
{
- sd2->focus_region(o, x, y, w, h);
+ ELM_SCROLLABLE_IFACE_GET(o, s_iface);
+
+ s_iface->content_region_show(o, x, y, w, h);
+
elm_widget_focus_region_get(o, &x, &y, &w, &h);
}
else
sd->on_show_region_data = data;
}
-/**
- * @internal
- *
- * Set the hook to use to show the focused region.
- *
- * Whenever a new widget gets focused or it's needed to show the focused
- * area of the current one, this hook will be called on objects that may
- * want to move their children into their visible area.
- * The area given in the hook function is relative to the @p obj widget.
- *
- * @param obj The widget object
- * @param func The function to call to show the specified area.
- *
- * @ingroup Widget
- */
-EAPI void
-elm_widget_focus_region_hook_set(Evas_Object *obj,
- void (*func)(Evas_Object *obj,
- Evas_Coord x,
- Evas_Coord y,
- Evas_Coord w,
- Evas_Coord h))
-{
- API_ENTRY return;
-
- sd->focus_region = func;
-}
-
-/**
- * @internal
- *
- * Set the hook to retrieve the focused region of a widget.
- *
- * This hook will be called by elm_widget_focus_region_get() whenever
- * it's needed to get the focused area of a widget. The area must be relative
- * to the widget itself and if no hook is set, it will default to the entire
- * object.
- *
- * @param obj The widget object
- * @param func The function used to retrieve the focus region.
- *
- * @ingroup Widget
- */
-EAPI void
-elm_widget_on_focus_region_hook_set(Evas_Object *obj,
- void (*func)(const Evas_Object *obj,
- Evas_Coord *x,
- Evas_Coord *y,
- Evas_Coord *w,
- Evas_Coord *h))
-{
- API_ENTRY return;
-
- sd->on_focus_region = func;
-}
-
EAPI Eina_Bool
elm_widget_sub_object_add(Evas_Object *obj,
Evas_Object *sobj)
Evas_Coord *w,
Evas_Coord *h)
{
- Elm_Widget_Smart_Data *sd;
-
- if (!obj) return;
-
- sd = evas_object_smart_data_get(obj);
- if (!sd || !_elm_widget_is(obj) || !sd->on_focus_region)
+ if (!_elm_widget_is(obj))
{
evas_object_geometry_get(obj, NULL, NULL, w, h);
if (x) *x = 0;
if (y) *y = 0;
return;
}
- sd->on_focus_region(obj, x, y, w, h);
+
+ ELM_WIDGET_DATA_GET(obj, sd);
+
+ sd->api->on_focus_region(obj, x, y, w, h);
}
EAPI Eina_List *
*/
#define ELM_WIDGET_SMART_CLASS_INIT(smart_class_init) \
{smart_class_init, ELM_WIDGET_SMART_CLASS_VERSION, NULL, NULL, NULL, NULL, \
- NULL, NULL, NULL, NULL, NULL, NULL, NULL}
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
/**
* @def ELM_WIDGET_SMART_CLASS_INIT_NULL
Evas_Object *source,
Evas_Callback_Type type,
void *event_info); /**< 'Virtual' function handling input events on the widget */
+ void (*on_focus_region)(const Evas_Object *obj,
+ Evas_Coord *x,
+ Evas_Coord *y,
+ Evas_Coord *w,
+ Evas_Coord *h); /**< 'Virtual' function returning an inner area of a widget that should be brought into the visible are of a broader viewport, may this context arise. On the base Elementary widget class, it defaults to the object's total area, so only override it if you have to. */
Eina_Bool (*focus_next)(const Evas_Object *obj,
Elm_Focus_Direction dir,
Evas_Object **next); /**< 'Virtual' function handling passing focus to sub-objects */
void *on_show_region_data;
void (*on_show_region)(void *data,
Evas_Object *obj);
- void (*focus_region)(Evas_Object *obj,
- Evas_Coord x,
- Evas_Coord y,
- Evas_Coord w,
- Evas_Coord h);
- void (*on_focus_region)(const Evas_Object *obj,
- Evas_Coord *x,
- Evas_Coord *y,
- Evas_Coord *w,
- Evas_Coord *h);
int frozen;
EAPI void elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
EAPI void elm_widget_translate(Evas_Object *obj);
EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data);
-EAPI void elm_widget_focus_region_hook_set(Evas_Object *obj, void (*func)(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h));
-EAPI void elm_widget_on_focus_region_hook_set(Evas_Object *obj, void (*func)(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h));
EAPI Eina_Bool elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
EAPI Eina_Bool elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);
EAPI void elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj);