summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorabhi <a.aryadipta@samsung.com>2013-11-28 00:27:13 +0900
committerDaniel Juyung Seo <juyung.seo@samsung.com>2013-11-30 16:28:06 +0900
commitbea0c9496233e7430e390aa8d14b10a63ea5f11a (patch)
treeb11aebc92211f15bf4648c08709ae5f0efb56d02
parent8ba691544ad1f786c786f89cb987b46ce1beb517 (diff)
downloadelementary-devs/seoz/pre1.9.tar.gz
tooltip: Adding elm_object_tooltip_orient_set APIdevs/seoz/pre1.9
Summary: Eight fixed orientations provided to orient tooltip around event area Test Plan: elementary_test -to tooltip, elm_object_tooltip_orient_set Reviewers: seoz, singh.amitesh, Anusha Reviewed By: seoz CC: Anusha Differential Revision: https://phab.enlightenment.org/D326
-rw-r--r--ChangeLog4
-rw-r--r--NEWS2
-rw-r--r--src/bin/test_tooltip.c93
-rw-r--r--src/lib/elm_tooltip.h52
-rw-r--r--src/lib/els_tooltip.c85
5 files changed, 234 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6703d4773..c03559806 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1760,3 +1760,7 @@
2013-11-28 Daniel Juyung Seo (SeoZ)
* spinner: fix mouse wheel support.
+
+2013-11-28 Abhinandan Aryadipta (aryarockstar)
+
+ * tooltip: Added elm_object_tooltip_orient_set() and elm_object_tooltip_orient_get().
diff --git a/NEWS b/NEWS
index 6d973a588..3fd7969ed 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ Changes since Elementary 1.8.0:
Additions:
+ * Add elm_object_tooltip_orient_set() and elm_object_tooltip_orient_get().
+
Improvements:
Fixes:
diff --git a/src/bin/test_tooltip.c b/src/bin/test_tooltip.c
index 241f04f78..70de973d2 100644
--- a/src/bin/test_tooltip.c
+++ b/src/bin/test_tooltip.c
@@ -201,6 +201,91 @@ _tt_text_replace(void *data EINA_UNUSED,
}
static void
+_tt_orient_text_replace(void *data EINA_UNUSED,
+ Evas_Object *obj,
+ void *event_info EINA_UNUSED)
+{
+ static Elm_Tooltip_Orient orient;
+
+ orient = elm_object_tooltip_orient_get(obj);
+ orient++;
+ if (orient >= ELM_TOOLTIP_ORIENT_LAST)
+ orient = ELM_TOOLTIP_ORIENT_TOP_LEFT;
+ switch(orient)
+ {
+ case ELM_TOOLTIP_ORIENT_TOP_LEFT:
+ {
+ elm_object_tooltip_text_set(obj, "Top Left");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_TOP_LEFT);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_TOP_LEFT\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_TOP:
+ {
+ elm_object_tooltip_text_set(obj, "Top");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_TOP);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_TOP\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_TOP_RIGHT:
+ {
+ elm_object_tooltip_text_set(obj, "Top Right");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_TOP_RIGHT);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_TOP_RIGHT\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_LEFT:
+ {
+ elm_object_tooltip_text_set(obj, "Left");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_LEFT);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_LEFT\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_CENTER:
+ {
+ elm_object_tooltip_text_set(obj, "Center");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_CENTER);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_CENTER\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_RIGHT:
+ {
+ elm_object_tooltip_text_set(obj, "Right");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_RIGHT);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_RIGHT\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_BOTTOM_LEFT:
+ {
+ elm_object_tooltip_text_set(obj, "Bottom Left");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_BOTTOM_LEFT);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_BOTTOM_LEFT\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_BOTTOM:
+ {
+ elm_object_tooltip_text_set(obj, "Bottom");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_BOTTOM);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_BOTTOM\n");
+ break;
+ }
+ case ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT:
+ {
+ elm_object_tooltip_text_set(obj, "Bottom Right");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT\n");
+ break;
+ }
+ default:
+ {
+ elm_object_tooltip_text_set(obj, "No Orientation");
+ elm_object_tooltip_orient_set(obj, ELM_TOOLTIP_ORIENT_NONE);
+ printf("elm_object_tooltip_orient_get :: Orientation: ELM_TOOLTIP_ORIENT_NONE\n");
+ }
+ };
+}
+
+static void
_tt_timer_del(void *data EINA_UNUSED,
Evas *e EINA_UNUSED,
Evas_Object *obj,
@@ -405,6 +490,14 @@ test_tooltip(void *data EINA_UNUSED,
evas_object_show(bt);
bt = elm_button_add(win);
+ elm_object_text_set(bt, "Orient Tooltip, click to change");
+ elm_object_tooltip_text_set(bt, "Top Left");
+ elm_object_tooltip_orient_set(bt, ELM_TOOLTIP_ORIENT_TOP_LEFT);
+ evas_object_smart_callback_add(bt, "clicked", _tt_orient_text_replace, NULL);
+ elm_box_pack_end(bx, bt);
+ evas_object_show(bt);
+
+ bt = elm_button_add(win);
elm_object_text_set(bt, "Simple text tooltip, click to change");
elm_object_tooltip_text_set(bt, "Initial");
evas_object_smart_callback_add(bt, "clicked", _tt_text_replace, NULL);
diff --git a/src/lib/elm_tooltip.h b/src/lib/elm_tooltip.h
index 3daf1c7ea..21bbfcd46 100644
--- a/src/lib/elm_tooltip.h
+++ b/src/lib/elm_tooltip.h
@@ -10,6 +10,58 @@
*/
/**
+ * @brief Possible orient values for tooltip.
+ *
+ * These values should be used in conjunction to elm_object_tooltip_orient_set() to
+ * set the position around which the tooltip should appear(relative to its parent)
+ *
+ * @ingroup Tooltips
+ */
+typedef enum
+{
+ ELM_TOOLTIP_ORIENT_NONE = 0, /**< Default value, Tooltip moves with mouse pointer */
+ ELM_TOOLTIP_ORIENT_TOP_LEFT, /**< Tooltip should appear at the top left of parent */
+ ELM_TOOLTIP_ORIENT_TOP, /**< Tooltip should appear at the top of parent */
+ ELM_TOOLTIP_ORIENT_TOP_RIGHT, /**< Tooltip should appear at the top right of parent */
+ ELM_TOOLTIP_ORIENT_LEFT, /**< Tooltip should appear at the left of parent */
+ ELM_TOOLTIP_ORIENT_CENTER, /**< Tooltip should appear at the center of parent */
+ ELM_TOOLTIP_ORIENT_RIGHT, /**< Tooltip should appear at the right of parent */
+ ELM_TOOLTIP_ORIENT_BOTTOM_LEFT, /**< Tooltip should appear at the bottom left of parent */
+ ELM_TOOLTIP_ORIENT_BOTTOM, /**< Tooltip should appear at the bottom of parent */
+ ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT, /**< Tooltip should appear at the bottom right of parent */
+ ELM_TOOLTIP_ORIENT_LAST /**< Sentinel value, @b don't use */
+ } Elm_Tooltip_Orient;
+
+/**
+ * @def elm_object_tooltip_orient_set
+ * @since 1.9
+ *
+ * @brief Sets the orientation of the tooltip around the owner region
+ *
+ * Sets the position in which tooltip will appear around its owner. By default,
+ * #ELM_TOOLTIP_ORIENT_NONE is set.
+ *
+ * @param[in] obj owner widget.
+ * @param[in] orient orientation.
+ *
+ * @ingroup Tooltips
+ * @see @ref Elm_Tooltip_Orient for possible values.
+ */
+EAPI void elm_object_tooltip_orient_set(Evas_Object *obj, Elm_Tooltip_Orient orient);
+
+/**
+ * @brief Returns the orientation of Tooltip
+ *
+ * @param obj The owner object
+ * @return The orientation of the tooltip
+ *
+ * @ingroup Tooltips
+ * @see elm_object_tooltip_orient_set()
+ * @ref Elm_Tooltip_Orient for possible values.
+ */
+EAPI Elm_Tooltip_Orient elm_object_tooltip_orient_get(const Evas_Object *obj);
+
+/**
* Called back when a widget's tooltip is activated and needs content.
* @param data user-data given to elm_object_tooltip_content_cb_set()
* @param obj owner widget.
diff --git a/src/lib/els_tooltip.c b/src/lib/els_tooltip.c
index 9f5dd58d7..63cbb57f0 100644
--- a/src/lib/els_tooltip.c
+++ b/src/lib/els_tooltip.c
@@ -56,6 +56,7 @@ struct _Elm_Tooltip
{
double x, y;
} rel_pos;
+ Elm_Tooltip_Orient orient; /** orientation for tooltip */
double hide_timeout; /* from theme */
Eina_Bool visible_lock:1;
Eina_Bool changed_style:1;
@@ -155,8 +156,12 @@ _elm_tooltip_show(Elm_Tooltip *tt)
(tt->eventarea, EVAS_CALLBACK_MOVE, _elm_tooltip_obj_move_cb, tt);
evas_object_event_callback_add
(tt->eventarea, EVAS_CALLBACK_RESIZE, _elm_tooltip_obj_resize_cb, tt);
- evas_object_event_callback_add
- (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_move_cb, tt);
+ //No movement of tooltip upon mouse move if orientation set
+ if ((tt->orient <= ELM_TOOLTIP_ORIENT_NONE) || (tt->orient >= ELM_TOOLTIP_ORIENT_LAST))
+ {
+ evas_object_event_callback_add
+ (tt->eventarea, EVAS_CALLBACK_MOUSE_MOVE, (Evas_Object_Event_Cb)_elm_tooltip_obj_mouse_move_cb, tt);
+ }
tt->changed_style = EINA_TRUE;
_elm_tooltip_reconfigure_job_start(tt);
@@ -520,6 +525,60 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
msg = alloca(sizeof(Edje_Message_Float_Set) + sizeof(double));
msg->count = 2;
+ //Orient calculations if orient set
+ switch(tt->orient)
+ {
+ case ELM_TOOLTIP_ORIENT_TOP_LEFT:
+ evas_object_move(tt->tooltip, ox - tw, oy - th);
+ rel_x = 1.1;
+ rel_y = 1.1;
+ break;
+ case ELM_TOOLTIP_ORIENT_TOP:
+ evas_object_move(tt->tooltip, ox + ((ow - tw) / 2), oy - th);
+ rel_x = 0.5;
+ rel_y = 1.1;
+ break;
+ case ELM_TOOLTIP_ORIENT_TOP_RIGHT:
+ evas_object_move(tt->tooltip, ox + ow, oy - th);
+ rel_x = -1.1;
+ rel_y = 1.1;
+ break;
+ case ELM_TOOLTIP_ORIENT_LEFT:
+ evas_object_move(tt->tooltip, ox - tw, oy + ((oh - th) / 2));
+ rel_x = 1.1;
+ rel_y = 0.5;
+ break;
+ case ELM_TOOLTIP_ORIENT_CENTER:
+ evas_object_move(tt->tooltip, ox + ((ow - tw) / 2), oy + ((oh - th) / 2));
+ rel_x = 0.5;
+ rel_y = 0.5;
+ break;
+ case ELM_TOOLTIP_ORIENT_RIGHT:
+ evas_object_move(tt->tooltip, ox + ow, oy + ((oh - th) / 2));
+ rel_x = -1.1;
+ rel_y = 0.5;
+ break;
+ case ELM_TOOLTIP_ORIENT_BOTTOM_LEFT:
+ evas_object_move(tt->tooltip, ox - tw, oy + oh);
+ rel_x = 1.1;
+ rel_y = -1.1;
+ break;
+ case ELM_TOOLTIP_ORIENT_BOTTOM:
+ evas_object_move(tt->tooltip, ox + ((ow - tw) / 2), oy + oh);
+ rel_x = 0.5;
+ rel_y = -1.1;
+ break;
+ case ELM_TOOLTIP_ORIENT_BOTTOM_RIGHT:
+ evas_object_move(tt->tooltip, ox + ow, oy + oh);
+ rel_x = -1.1;
+ rel_y = -1.1;
+ break;
+ default:
+ { /*Do Nothing!!*/
+ }
+ };
+ evas_object_show(tt->tooltip);
+
msg->val[0] = rel_x;
msg->val[1] = rel_y;
tt->rel_pos.x = rel_x;
@@ -665,6 +724,28 @@ _elm_tooltip_data_clean(Elm_Tooltip *tt)
tt->del_cb = NULL;
}
+EAPI void
+elm_object_tooltip_orient_set(Evas_Object *obj, Elm_Tooltip_Orient orient)
+{
+ ELM_TOOLTIP_GET_OR_RETURN(tt, obj);
+
+ if ((orient > ELM_TOOLTIP_ORIENT_NONE) && (orient < ELM_TOOLTIP_ORIENT_LAST))
+ tt->orient = orient;
+ else
+ tt->orient = ELM_TOOLTIP_ORIENT_NONE;
+}
+
+EAPI Elm_Tooltip_Orient
+elm_object_tooltip_orient_get(const Evas_Object *obj)
+{
+ ELM_TOOLTIP_GET_OR_RETURN(tt, obj, ELM_TOOLTIP_ORIENT_NONE);
+
+ Elm_Tooltip_Orient orient = ELM_TOOLTIP_ORIENT_NONE;
+
+ orient = tt->orient;
+ return orient;
+}
+
/**
* Notify tooltip should recalculate its theme.
* @internal