add api for manipulating frame collapse
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 4 Jan 2012 03:03:15 +0000 (03:03 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 4 Jan 2012 03:03:15 +0000 (03:03 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@66833 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_frame.c
src/lib/elm_frame.h

index 3ca1d91..400257d 100644 (file)
@@ -8,6 +8,8 @@ struct _Widget_Data
    Evas_Object *frm;
    Evas_Object *content;
    const char *label;
+   Eina_Bool collapsed : 1;
+   Eina_Bool collapsible : 1;
 };
 
 static const char SIG_CLICKED[] = "clicked";
@@ -192,6 +194,9 @@ _signal_click(Evas_Object *fr, Evas_Object *obj __UNUSED__, const char *emission
    wd = elm_widget_data_get(fr);
    if (!wd) return;
    evas_object_smart_callback_call(fr, SIG_CLICKED, NULL);
+   if (!wd->collapsible) return;
+   edje_object_signal_emit(wd->frm, "elm,action,collapse", "elm");
+   wd->collapsed++;
 }
 
 EAPI Evas_Object *
@@ -232,6 +237,50 @@ elm_frame_add(Evas_Object *parent)
 }
 
 EAPI void
+elm_frame_autocollapse_set(Evas_Object *obj, Eina_Bool enable)
+{
+   Widget_Data *wd;
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->collapsible = !!enable;
+}
+
+EAPI Eina_Bool
+elm_frame_autocollapse_get(Evas_Object *obj)
+{
+   Widget_Data *wd;
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->collapsible;
+}
+
+EAPI void
+elm_frame_collapse_set(Evas_Object *obj, Eina_Bool enable)
+{
+   Widget_Data *wd;
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   enable = !!enable;
+   if (wd->collapsed == enable) return;
+   edje_object_signal_emit(wd->frm, "elm,action,collapse", "elm");
+   wd->collapsed = enable;
+}
+
+EAPI Eina_Bool
+elm_frame_collapse_get(Evas_Object *obj)
+{
+   Widget_Data *wd;
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+   return wd->collapsed;
+}
+
+
+EAPI void
 elm_frame_label_set(Evas_Object *obj, const char *label)
 {
    _elm_frame_label_set(obj, NULL, label);
index 7b50749..452d2cf 100644 (file)
 EAPI Evas_Object                 *elm_frame_add(Evas_Object *parent);
 
 /**
+ * @brief Toggle autocollapsing of a frame
+ * @param obj The frame
+ * @param enable Whether to enable autocollapse
+ *
+ * When @p enable is EINA_TRUE, clicking a frame's label will collapse the frame
+ * vertically, shrinking it to the height of the label.
+ * By default, this is DISABLED.
+ */
+EAPI void elm_frame_autocollapse_set(Evas_Object *obj, Eina_Bool enable);
+
+/**
+ * @brief Determine autocollapsing of a frame
+ * @param obj The frame
+ * @return Whether autocollapse is enabled
+ *
+ * When this returns EINA_TRUE, clicking a frame's label will collapse the frame
+ * vertically, shrinking it to the height of the label.
+ * By default, this is DISABLED.
+ */
+EAPI Eina_Bool elm_frame_autocollapse_get(Evas_Object *obj);
+
+/**
+ * @brief Manually collapse a frame
+ * @param obj The frame
+ * @param enable true to collapse, false to expand
+ *
+ * Use this to toggle the collapsed state of a frame.
+ */
+EAPI void elm_frame_collapse_set(Evas_Object *obj, Eina_Bool enable);
+
+/**
+ * @brief Determine the collapse state of a frame
+ * @param obj The frame
+ * @return true if collapsed, false otherwise
+ *
+ * Use this to determine the collapse state of a frame.
+ */
+EAPI Eina_Bool elm_frame_collapse_get(Evas_Object *obj);
+/**
  * @}
  */