From: Michael Blumenkrantz <mike@zentific.com>
authorMichael Blumenkrantz <mike@zentific.com>
Tue, 27 Apr 2010 05:43:54 +0000 (05:43 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Tue, 27 Apr 2010 05:43:54 +0000 (05:43 +0000)
elm.diff is a patch which implements a number of convenience functions
for various widgets, as well as some new features for toolbar and panel.
With the panel widget, I've written a number of calls related to
toolbar items and the selected item in particular, allowing
manipulation of the selection and toolbar items more easily. These
functions are as follows:
+elm_toolbar_item_get_all() returns a Eina_List* of all the toolbar
items
+elm_toolbar_item_get_first() returns the first toolbar item
+elm_toolbar_item_get_last() returns the last toolbar item
+elm_toolbar_item_get_next() returns the item after the
currently selected item
+elm_toolbar_item_select_next() moves the selection to the next valid
item
+elm_toolbar_item_select_first() selects the first valid item
+elm_toolbar_item_select_last() selects the last valid item
+elm_toolbar_item_find_by_label() returns the first Elm_Toolbar_Item
matching "label"

The new panel functions I have written allow for control of the panel's
state from code, and are as follows:
+elm_panel_hidden_set() sets the panel's toggle state to a bool value
and runs the animation
+elm_panel_hidden_get() returns whether the panel is hidden
+elm_panel_toggle() toggles the panel to its other state

The remainder of the functions are just general wd->data returns which
were missing, the functionality of which may be of use to people.

SVN revision: 48355

src/lib/Elementary.h.in
src/lib/elm_hover.c
src/lib/elm_menu.c
src/lib/elm_panel.c
src/lib/elm_toolbar.c

index c685e75..5e1a5ad 100644 (file)
@@ -635,7 +635,9 @@ extern "C" {
      } Elm_Hover_Axis;
    EAPI Evas_Object *elm_hover_add(Evas_Object *parent);
    EAPI void         elm_hover_target_set(Evas_Object *obj, Evas_Object *target);
+   EAPI Evas_Object *elm_hover_target_get(Evas_Object *obj);
    EAPI void         elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent);
+   EAPI Evas_Object *elm_hover_parent_get(Evas_Object *obj);
    EAPI void         elm_hover_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content);
    EAPI const char  *elm_hover_best_content_location_get(const Evas_Object *obj, Elm_Hover_Axis pref_axis);
    /* available styles:
@@ -870,9 +872,20 @@ extern "C" {
    EAPI void              elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled);
    EAPI void              elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator);
    EAPI Eina_Bool         elm_toolbar_item_separator_get(Elm_Toolbar_Item *item);
+   EAPI Eina_List        *elm_toolbar_item_get_all(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_get_first(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_get_last(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_get_next(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_select_next(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_select_first(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_select_last(Evas_Object *obj);
+   EAPI Elm_Toolbar_Item *elm_toolbar_item_find_by_label(Evas_Object *obj, const char *label);
    EAPI void              elm_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable);
+   EAPI Eina_Bool         elm_toolbar_scrollable_get(Evas_Object *obj);
    EAPI void             elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous);
+   EAPI Eina_Bool         elm_toolbar_homogenous_get(Evas_Object *obj);
    EAPI void             elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent);
+   EAPI Evas_Object      *elm_toolbar_menu_parent_get(Evas_Object *obj);
    EAPI void              elm_toolbar_item_unselect_all(Evas_Object *obj);
    EAPI void              elm_toolbar_align_set(Evas_Object *obj, double align);
    EAPI double            elm_toolbar_align_get(const Evas_Object *obj);
@@ -891,8 +904,11 @@ extern "C" {
    EAPI void            elm_menu_item_label_set(Elm_Menu_Item *item, const char *label);
    EAPI const char      *elm_menu_item_label_get(Elm_Menu_Item *item);
    EAPI void            elm_menu_item_icon_set(Elm_Menu_Item *item, Evas_Object *icon);
+   EAPI Evas_Object     *elm_menu_item_icon_get(Elm_Menu_Item *item);
    EAPI void            elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled);
+   EAPI Eina_Bool        elm_menu_item_disabled_get(Elm_Menu_Item *item);
    EAPI Elm_Menu_Item   *elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent);
+   EAPI Eina_Bool        elm_menu_item_is_separator(Elm_Menu_Item *item);
    EAPI void            elm_menu_item_del(Elm_Menu_Item *item);
    EAPI void            elm_menu_item_del_cb_set(Elm_Menu_Item *it, Evas_Smart_Cb func);
    EAPI void           *elm_menu_item_data_get(const Elm_Menu_Item *it);
@@ -1372,9 +1388,14 @@ extern "C" {
           ELM_PANEL_ORIENT_LEFT,
           ELM_PANEL_ORIENT_RIGHT,
      } Elm_Panel_Orient;
-   EAPI Evas_Object *elm_panel_add(Evas_Object *parent);
-   EAPI void         elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient);
-   EAPI void         elm_panel_content_set(Evas_Object *obj, Evas_Object *content);
+   EAPI Evas_Object          *elm_panel_add(Evas_Object *parent);
+   EAPI void                  elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient);
+   EAPI Elm_Panel_Orient      elm_panel_orient_get(Evas_Object *obj);
+   EAPI void                  elm_panel_content_set(Evas_Object *obj, Evas_Object *content);
+EAPI void elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden);
+EAPI Eina_Bool elm_panel_hidden_get(Evas_Object *obj);
+EAPI void elm_panel_toggle(Evas_Object *obj);
+
 
 #if 1 // working on it
    // flip types:
index 248de3c..27c3bde 100644 (file)
@@ -386,6 +386,41 @@ elm_hover_parent_set(Evas_Object *obj, Evas_Object *parent)
    _sizing_eval(obj);
 }
 
+/**
+ * Gets the target object for the hover.
+ *
+ * @param obj The hover object
+ * @return The target object of the hover.
+ * 
+ * @ingroup Hover
+ */
+EAPI Evas_Object *
+elm_hover_target_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   return wd->target;
+}
+
+/**
+ * Gets the parent object for the hover.
+ *
+ * @param obj The hover object
+ * @return The parent object to locate the hover over.
+ *
+ * @ingroup Hover
+ */
+EAPI Evas_Object *
+elm_hover_parent_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   return wd->parent;
+}
 
 /**
  * Sets the content of the hover object and the direction in which
index f220a7e..1304e5f 100644 (file)
@@ -646,6 +646,20 @@ elm_menu_item_disabled_set(Elm_Menu_Item *item, Eina_Bool disabled)
    edje_object_message_signal_process(item->o);
 }
 
+/**
+ * Get the disabled state of @p item.
+ * 
+ * @param it The menu item object.
+ * @return The enabled/disabled state of the item
+ * 
+ * @ingroup Menu
+ */
+EAPI Eina_Bool
+elm_menu_item_disabled_get(Elm_Menu_Item *item)
+{
+   if (!item) return 0;
+   return item->disabled;
+}
 
 /**
  * Add a separator item to menu @p obj under @p parent.
@@ -693,6 +707,36 @@ elm_menu_item_separator_add(Evas_Object *obj, Elm_Menu_Item *parent)
  * @ingroup Menu
  */
 
+/**
+ * Get the icon of a menu item
+ * 
+ * @param it The menu item object.
+ * @return The icon object of @p item or NULL
+ * 
+ * @ingroup Menu
+ */
+EAPI Evas_Object *
+elm_menu_item_icon_get(Elm_Menu_Item *item)
+{
+   if (!item) return NULL;
+   return item->icon;
+}
+
+/**
+ * Returns whether @p item is a separator.
+ *
+ * @param item The item to check
+ * @return If true, @p item is a separator
+ *
+ * @ingroup Menu
+ */
+EAPI Eina_Bool
+elm_menu_item_is_separator(Elm_Menu_Item *item)
+{
+   if (!item) return 0;
+   return item->separator;
+}
+
 EAPI void
 elm_menu_item_del(Elm_Menu_Item *item)
 {
index 79cf4a8..0b312f8 100644 (file)
@@ -211,6 +211,22 @@ elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient)
    _sizing_eval(obj);
 }
 
+/**
+ * Get the orientation of the panel.
+ *
+ * @param obj The panel object
+ * @return The Elm_Panel_Orient, or ELM_PANEL_ORIENT_LEFT on failure.
+ *
+ * @ingroup Panel
+ */
+EAPI Elm_Panel_Orient
+elm_panel_orient_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) ELM_PANEL_ORIENT_LEFT;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return ELM_PANEL_ORIENT_LEFT;
+   return wd->orient;   
+}
 
 /**
  * Set the content of the panel.
@@ -232,3 +248,56 @@ elm_panel_content_set(Evas_Object *obj, Evas_Object *content)
    evas_object_show(content);
    _sizing_eval(obj);
 }
+
+/**
+ * Set the state of the panel.
+ *
+ * @param obj The panel object
+ * @param hidden If true, the panel will run the edje animation to contract
+ *
+ * @ingroup Panel
+ */
+EAPI void
+elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   if (wd->hidden == hidden) return;
+   wd->hidden = hidden;
+   _toggle_panel(obj, NULL, "elm,action,panel,toggle", "*");
+}
+
+/**
+ * Get the state of the panel.
+ *
+ * @param obj The panel object
+ * @param hidden If true, the panel is in the "hide" state
+ *
+ * @ingroup Panel
+ */
+EAPI Eina_Bool
+elm_panel_hidden_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->hidden;
+}
+
+/**
+ * Toggle the state of the panel from code
+ *
+ * @param obj The panel object
+ *
+ * @ingroup Panel
+ */
+EAPI void
+elm_panel_toggle(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->hidden = !(wd->hidden);
+   _toggle_panel(obj, NULL, "elm,action,panel,toggle", "*");
+}
index 4711d23..8f15d1c 100644 (file)
@@ -647,6 +647,24 @@ elm_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable)
 }
 
 /**
+ * Get the scrollable state of toolbar @p obj.
+ *
+ * @param obj The toolbar object
+ * @return If true, the toolbar is scrollable
+ *
+ * @ingroup Toolbar
+ */
+EAPI Eina_Bool
+elm_toolbar_scrollable_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if (!wd) return;
+   return wd->scrollable;
+}
+
+/**
  * Set the homogenous mode of toolbar @p obj.
  *
  * @param obj The toolbar object
@@ -666,6 +684,24 @@ elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
 }
 
 /**
+ * Get the homogenous mode of toolbar @p obj.
+ *
+ * @param obj The toolbar object
+ * @return If true, the toolbar items are uniform in size
+ *
+ * @ingroup Toolbar
+ */
+EAPI Eina_Bool
+elm_toolbar_homogenous_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if (!wd) return;
+   return wd->homogeneous;
+}
+
+/**
  * Set the parent object of the toolbar menu
  *
  * @param obj The toolbar object
@@ -691,6 +727,24 @@ elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
 }
 
 /**
+ * Get the parent object of the toolbar menu
+ *
+ * @param obj The toolbar object
+ * @return The parent of the menu object
+ *
+ * @ingroup Toolbar
+ */
+EAPI Evas_Object *
+elm_toolbar_menu_parent_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+
+   return wd->menu_parent;
+}
+
+/**
  * Unselect all of the items in the toolbar.
  *
  * @param obj The toolbar object
@@ -805,3 +859,221 @@ elm_toolbar_item_menu_get(Elm_Toolbar_Item *item)
    elm_toolbar_item_menu_set(item, 1);
    return item->o_menu;
 }
+
+/**
+ * Return a list of all toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return An Eina_List* of the toolbar items in @p obj
+ *
+ * @ingroup Toolbar
+ */
+EAPI Eina_List *
+elm_toolbar_item_get_all(Evas_Object *obj)
+{
+   Eina_List *l;
+   Elm_Toolbar_Item *it;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+
+   return wd->items;
+}
+
+/**
+ * Return the first toolbar item in the list of toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return The first toolbar item, or NULL on failure
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_get_first(Evas_Object *obj)
+{
+   Eina_List *l;
+   Elm_Toolbar_Item *it;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   if (!(it = eina_list_data_get(wd->items))) return NULL;
+
+   return it;
+}
+
+/**
+ * Return the last toolbar item in the list of toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return The last toolbar item, or NULL on failure
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_get_last(Evas_Object *obj)
+{
+   Eina_List *l, *last;
+   Elm_Toolbar_Item *it;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   if (!(last = eina_list_last(wd->items))) return NULL;
+   it = eina_list_data_get(last);
+
+   return it;
+}
+
+/**
+ * Return the next toolbar item (relative to the currently selected
+ * toolbar item) in the list of toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return The next toolbar item, or NULL on failure
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_get_next(Evas_Object *obj)
+{
+   Eina_List *l, *l2;
+   Elm_Toolbar_Item *it, *next;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if (!wd) return NULL;
+   EINA_LIST_FOREACH_SAFE(wd->items, l, l2, it)
+     {
+        if (it->selected)
+          {
+            if (!(next = eina_list_data_get(l2))) return NULL;
+            return next;
+          }
+     }
+   return NULL;
+}
+
+/**
+ * Selects the next non-disabled, non-separator toolbar item in the list
+ * of toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return The newly selected toolbar item, or NULL on failure
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_select_next(Evas_Object *obj)
+{
+   Eina_List *l, *l2;
+   Elm_Toolbar_Item *it, *next;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if (!wd) return NULL;
+   EINA_LIST_FOREACH(wd->items, l, it)
+     {
+        if (it->selected)
+          {
+             EINA_LIST_FOREACH(l, l2, next)
+               if ((!next->disabled) && (next->separator))
+                 {
+                    _item_select(next);
+                    return next;
+                 }
+          }
+     }
+  return NULL;
+}
+
+/**
+ * Selects the first non-disabled, non-separator toolbar item in the list
+ * of toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return The newly selected toolbar item, or NULL on failure
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_select_first(Evas_Object *obj)
+{
+   Eina_List *l;
+   Elm_Toolbar_Item *it;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   EINA_LIST_FOREACH(wd->items, l, it)
+     {
+        if ((!it->disabled) && (!it->separator))
+          {
+             _item_select(it);
+             return it;
+          }
+     }
+
+   return NULL;
+}
+
+/**
+ * Selects the last non-disabled, non-separator toolbar item in the list
+ * of toolbar items.
+ *
+ * @param obj The toolbar object
+ *
+ * @return The newly selected toolbar item, or NULL on failure
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_select_last(Evas_Object *obj)
+{
+   Eina_List *l;
+   Elm_Toolbar_Item *it;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return NULL;
+   EINA_LIST_REVERSE_FOREACH(wd->items, l, it)
+     {
+        if ((!it->disabled) && (!it->separator))
+          {
+             _item_select(it);
+             return it;
+          }
+     }
+   return NULL;
+}
+
+/**
+ * Returns a pointer to a toolbar item by its label
+ *
+ * @param obj The toolbar object
+ * @param label The label of the item to find
+ *
+ * @return The pointer to the toolbar item matching @p label
+ * Returns NULL on failure.
+ *
+ * @ingroup Toolbar
+ */
+EAPI Elm_Toolbar_Item *
+elm_toolbar_item_find_by_label(Evas_Object *obj, const char *label)
+{
+   Eina_List *l;
+   Elm_Toolbar_Item *it;
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   
+   if (!wd) return NULL;
+   EINA_LIST_FOREACH(wd->items, l, it)
+     {
+        if (!strcmp(it->label, label)) return it;
+     }
+
+   return NULL;
+}