Panel working nicely now, tho still one issue (content does not initially
authorChristopher Michael <cpmichael1@comcast.net>
Sun, 15 Nov 2009 17:29:22 +0000 (17:29 +0000)
committerChristopher Michael <cpmichael1@comcast.net>
Sun, 15 Nov 2009 17:29:22 +0000 (17:29 +0000)
show until you resize the window/panel. Not sure why)

SVN revision: 43714

data/themes/default.edc
src/bin/test_panel.c
src/lib/elm_panel.c

index 83a3a38..5b6ad19 100644 (file)
@@ -19332,7 +19332,7 @@ collections {
 /////////////////////////////////////////////////////////////////////////////
 group 
 {
-   name: "elm/panel/base/default";
+   name: "elm/panel/base/left";
    images 
      {
         image: "bt_base1.png" COMP;
@@ -19354,14 +19354,13 @@ group
                {
                   state: "default" 0.0;
                   color: 255 255 255 0;
-                  rel1.relative: 0.0 0.0;
-                  rel2.relative: 1.0 1.0;
+                  rel1.offset: 30 0;
+                  rel2.relative: 0.0 1.0;
                }
              description 
                {
                   state: "visible" 0.0;
                   inherit: "default" 0.0;
-                  rel1.relative: 0.0 0.0;
                   rel2.relative: 1.0 1.0;
                }
           }
index df161a8..d9afb0a 100644 (file)
@@ -42,6 +42,7 @@ test_panel(void *data, Evas_Object *obj, void *event_info)
    itc.func.del = _item_del;
 
    list = elm_genlist_add(win);
+   evas_object_size_hint_min_set(list, 100, -1);
    evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_show(list);
index 42efb26..cf243c4 100644 (file)
@@ -1,58 +1,26 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 
-#define PNL_BTN_WIDTH 32
-
-/**
- * @defgroup Panel Panel
- * 
- * This is a panel object
- */
-
 typedef struct _Widget_Data Widget_Data;
 struct _Widget_Data 
 {
-   Evas_Object *parent, *panel, *content;
+   Evas_Object *scr, *bx;
    Elm_Panel_Orient orient;
    Eina_Bool hidden : 1;
 };
 
-static void _del_pre_hook(Evas_Object *obj);
 static void _del_hook(Evas_Object *obj);
 static void _theme_hook(Evas_Object *obj);
-static void _focus_hook(void *data, Evas_Object *obj);
 static void _sizing_eval(Evas_Object *obj);
-static void _parent_resize(void *data, Evas *evas, Evas_Object *obj, void *event);
+static void _resize(void *data, Evas *evas, Evas_Object *obj, void *event);
+static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
 static void _toggle_panel(void *data, Evas_Object *obj, const char *emission, const char *source);
-static void _changed_size_hints(void *data, Evas *evas, Evas_Object *obj, void *event);
-static void _sub_del(void *data, Evas_Object *obj, void *event);
-static void _panel_show(void *data, Evas *evas, Evas_Object *obj, void *event);
-static void _content_resize(void *data, Evas *evas, Evas_Object *obj, void *event);
-static void _calc(Evas_Object *obj);
-
-static void 
-_del_pre_hook(Evas_Object *obj) 
-{
-   Widget_Data *wd = elm_widget_data_get(obj);
-
-   /* delete callback for edje signal */
-   edje_object_signal_callback_del(wd->panel, "elm,action,panel,toggle", 
-                                   "*", _toggle_panel);
-   /* delete parent resize callback */
-   evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_RESIZE, 
-                                       _parent_resize, obj);
-
-   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_SHOW, 
-                                       _panel_show, obj);
-   evas_object_smart_callback_del(obj, "sub-object-del", _sub_del);
-}
 
 static void 
 _del_hook(Evas_Object *obj) 
 {
    Widget_Data *wd = elm_widget_data_get(obj);
 
-   elm_panel_content_set(obj, NULL);
    free(wd);
 }
 
@@ -60,57 +28,62 @@ static void
 _theme_hook(Evas_Object *obj) 
 {
    Widget_Data *wd = elm_widget_data_get(obj);
+   int scale = 0;
 
-   _elm_theme_set(wd->panel, "panel", "base", "default");
-   edje_object_scale_set(wd->panel, elm_widget_scale_get(obj) * 
-                         _elm_config->scale);
-
-   edje_object_signal_emit(wd->panel, "elm,action,show", "elm");
-   edje_object_message_signal_process(wd->panel);
+   scale = (elm_widget_scale_get(obj) * _elm_config->scale);
+   edje_object_scale_set(wd->scr, scale);
    _sizing_eval(obj);
 }
 
 static void 
-_focus_hook(void *data, Evas_Object *obj) 
+_sizing_eval(Evas_Object *obj) 
 {
    Widget_Data *wd = elm_widget_data_get(obj);
-   if ((elm_widget_focus_get(obj)) && (wd->content))
-     elm_widget_focus_steal(wd->content);
+   Evas_Coord mw = -1, mh = -1;
+   Evas_Coord vw = 0, vh = 0;
+   Evas_Coord w, h;
+
+   evas_object_smart_calculate(wd->bx);
+   edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), 
+                             &mw, &mh);
+   evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+   if (w < mw) w = mw;
+   if (h < mh) h = mh;
+   evas_object_resize(wd->scr, w, h);
+
+   evas_object_size_hint_min_get(wd->bx, &mw, &mh);
+   if (w > mw) mw = w;
+   if (h > mh) mh = h;
+   evas_object_resize(wd->bx, mw, mh);
+
+   elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
+   mw = mw + (w - vw);
+   mh = mh + (h - vh);
+   evas_object_size_hint_min_set(obj, mw, mh);
+   evas_object_size_hint_max_set(obj, -1, -1);
 }
 
 static void 
-_sizing_eval(Evas_Object *obj
+_resize(void *data, Evas *evas, Evas_Object *obj, void *event
 {
-   Widget_Data *wd = elm_widget_data_get(obj);
-   Evas_Coord x, y, w, h;
-   Evas_Coord pw, ph, ow, oh;
+   Widget_Data *wd = elm_widget_data_get(data);
+   Evas_Coord mw, mh, vw, vh, w, h;
 
-   printf("Sizing Eval\n");
-   evas_object_geometry_get(wd->parent, NULL, NULL, &w, &h);
-   edje_object_size_min_calc(wd->panel, &pw, &ph);
-   printf("\tPanel Min Size: %d %d\n", pw, ph);
-   switch (wd->orient) 
+   elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
+   evas_object_size_hint_min_get(wd->bx, &mw, &mh);
+   evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
+   if ((vw >= mw) || (vh >= mh))
      {
-      case ELM_PANEL_ORIENT_TOP:
-        evas_object_resize(obj, w, pw + PNL_BTN_WIDTH);
-        break;
-      case ELM_PANEL_ORIENT_BOTTOM:
-        evas_object_resize(obj, w, pw + PNL_BTN_WIDTH);
-        break;
-      case ELM_PANEL_ORIENT_LEFT:
-        evas_object_move(obj, 0, 0);
-        evas_object_resize(obj, pw + PNL_BTN_WIDTH, h);
-        break;
-      case ELM_PANEL_ORIENT_RIGHT:
-        evas_object_resize(obj, pw + PNL_BTN_WIDTH, h);
-        break;
+        if ((w != vw) || (h != vh)) evas_object_resize(wd->bx, vw, vh);
      }
 }
 
 static void 
-_parent_resize(void *data, Evas *evas, Evas_Object *obj, void *event
+_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data
 {
-   _sizing_eval(data);
+   Widget_Data *wd = data;
+
+   _els_box_layout(o, priv, EINA_TRUE, EINA_FALSE);
 }
 
 static void 
@@ -120,96 +93,18 @@ _toggle_panel(void *data, Evas_Object *obj, const char *emission, const char *so
 
    if (wd->hidden) 
      {
-        edje_object_signal_emit(wd->panel, "elm,action,show", "elm");
+        edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), 
+                                "elm,action,show", "elm");
         wd->hidden = EINA_FALSE;
      }
-   else 
+   else
      {
-        edje_object_signal_emit(wd->panel, "elm,action,hide", "elm");
+        edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), 
+                                "elm,action,hide", "elm");
         wd->hidden = EINA_TRUE;
      }
 }
 
-static void 
-_changed_size_hints(void *data, Evas *evas, Evas_Object *obj, void *event) 
-{
-   _sizing_eval(data);
-}
-
-static void 
-_sub_del(void *data, Evas_Object *obj, void *event) 
-{
-   Widget_Data *wd = elm_widget_data_get(obj);
-   Evas_Object *sub = event;
-
-   if (sub == wd->content) 
-     {
-        evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, 
-                                            _changed_size_hints, obj);
-        wd->content = NULL;
-        _sizing_eval(obj);
-     }
-}
-
-static void 
-_panel_show(void *data, Evas *evas, Evas_Object *obj, void *event) 
-{
-//   printf("Panel Show Event\n");
-}
-
-static void 
-_content_resize(void *data, Evas *evas, Evas_Object *obj, void *event) 
-{
-//   _calc(data);
-//   printf("Content Resize\n");
-//   _sizing_eval(data);
-}
-
-static void 
-_calc(Evas_Object *obj) 
-{
-   Widget_Data *wd = elm_widget_data_get(obj);
-   Evas_Coord x, y, w, h;
-   Evas_Coord pw, ph;
-
-   printf("Calc\n");
-   evas_object_size_hint_min_get(wd->panel, &pw, &ph);
-   printf("Size Hint: %d %d\n", pw, ph);
-
-   edje_object_size_min_calc(wd->panel, &pw, &ph);
-   printf("\tPanel Min Size: %d %d\n", pw, ph);
-//   if ((pw < 1) || (ph < 1)) return;
-
-   evas_object_geometry_get(wd->parent, NULL, NULL, &w, &h);
-   printf("\tParent Size: %d %d\n", w, h);
-//   if ((w <= 1) || (h <= 1)) return;
-
-   switch (wd->orient) 
-     {
-      case ELM_PANEL_ORIENT_TOP:
-        evas_object_resize(obj, w, pw + PNL_BTN_WIDTH);
-        break;
-      case ELM_PANEL_ORIENT_BOTTOM:
-        evas_object_resize(obj, w, pw + PNL_BTN_WIDTH);
-        break;
-      case ELM_PANEL_ORIENT_LEFT:
-        evas_object_move(wd->panel, 0, 0);
-        evas_object_resize(wd->panel, pw + PNL_BTN_WIDTH, h);
-        break;
-      case ELM_PANEL_ORIENT_RIGHT:
-        evas_object_resize(obj, pw + PNL_BTN_WIDTH, h);
-        break;
-     }
-}
-
-/**
- * Add a new panel to the parent
- * 
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- * 
- * @ingroup Panel
- */
 EAPI Evas_Object *
 elm_panel_add(Evas_Object *parent) 
 {
@@ -218,49 +113,42 @@ elm_panel_add(Evas_Object *parent)
    Widget_Data *wd;
 
    wd = ELM_NEW(Widget_Data);
-   wd->parent = parent;
-   wd->hidden = EINA_FALSE;
    evas = evas_object_evas_get(parent);
-
    obj = elm_widget_add(evas);
    elm_widget_type_set(obj, "panel");
    elm_widget_sub_object_add(parent, obj);
    elm_widget_data_set(obj, wd);
-   elm_widget_del_pre_hook_set(obj, _del_pre_hook);
    elm_widget_del_hook_set(obj, _del_hook);
    elm_widget_theme_hook_set(obj, _theme_hook);
-   elm_widget_on_focus_hook_set(obj, _focus_hook, NULL);
-   elm_widget_can_focus_set(obj, 1);
+   elm_widget_can_focus_set(obj, 0);
 
-   wd->panel = edje_object_add(evas);
-   elm_panel_orient_set(obj, ELM_PANEL_ORIENT_LEFT);
-   elm_widget_resize_object_set(obj, wd->panel);
+   wd->scr = elm_smart_scroller_add(evas);
+   elm_smart_scroller_bounce_allow_set(wd->scr, 0, 0);
+   elm_smart_scroller_theme_set(wd->scr, "panel", "base", "left");
+   elm_widget_resize_object_set(obj, wd->scr);
+   elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF, 
+                                 ELM_SMART_SCROLLER_POLICY_OFF);
 
-   /* callback for edje signal */
-   edje_object_signal_callback_add(wd->panel, "elm,action,panel,toggle", 
-                                   "*", _toggle_panel, obj);
-   /* callback to know when parent resizes */
-   evas_object_event_callback_add(wd->parent, EVAS_CALLBACK_RESIZE, 
-                                  _parent_resize, obj);
+   wd->hidden = FALSE;
+   wd->orient = ELM_PANEL_ORIENT_LEFT;
 
-   /* let's find out when our panel shows itself */
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _panel_show, obj);
+   wd->bx = evas_object_box_add(evas);
+   evas_object_size_hint_align_set(wd->bx, 0.5, 0.5);
+   evas_object_box_layout_set(wd->bx, _layout, wd, NULL);
+   elm_widget_sub_object_add(obj, wd->bx);
+   elm_smart_scroller_child_set(wd->scr, wd->bx);
+   evas_object_show(wd->bx);
 
-   /* and we want to know when the content gets removed */
-   evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
+   edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr), 
+                                   "elm,action,panel,toggle", "*", 
+                                   _toggle_panel, obj);
+
+   evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
 
    _sizing_eval(obj);
    return obj;
 }
 
-/**
- * Set the panel orientation
- * 
- * @param obj The panel object
- * @param orient The orientation to set for this panel object
- * 
- * @ingroup Panel
- */
 EAPI void 
 elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient) 
 {
@@ -270,55 +158,26 @@ elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient)
    switch (orient) 
      {
       case ELM_PANEL_ORIENT_TOP:
-        _elm_theme_set(wd->panel, "panel", "base", "top");
-        break;
       case ELM_PANEL_ORIENT_BOTTOM:
-        _elm_theme_set(wd->panel, "panel", "base", "bottom");
         break;
       case ELM_PANEL_ORIENT_LEFT:
-        _elm_theme_set(wd->panel, "panel", "base", "left");
-        break;
+        elm_smart_scroller_theme_set(wd->scr, "panel", "base", "left");
       case ELM_PANEL_ORIENT_RIGHT:
-        _elm_theme_set(wd->panel, "panel", "base", "right");
+        break;
+      default:
         break;
      }
    _sizing_eval(obj);
 }
 
-/**
- * Set the panel content
- * 
- * @param obj The panel object
- * @param content The content will be filled in this panel object
- * 
- * @ingroup Panel
- */
 EAPI void 
 elm_panel_content_set(Evas_Object *obj, Evas_Object *content) 
 {
    Widget_Data *wd = elm_widget_data_get(obj);
 
-   if ((wd->content) && (wd->content != 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);
-        evas_object_event_callback_del_full(wd->content, EVAS_CALLBACK_RESIZE, 
-                                       _content_resize, obj);
-        evas_object_del(wd->content);
-     }
-   wd->content = content;
-   if (content) 
-     {
-        elm_widget_sub_object_add(obj, content);
-        edje_object_part_swallow(wd->panel, "elm.swallow.content", content);
-        evas_object_event_callback_add(content, 
-                                       EVAS_CALLBACK_CHANGED_SIZE_HINTS, 
-                                       _changed_size_hints, obj);
-        evas_object_event_callback_add(content, EVAS_CALLBACK_RESIZE, 
-                                       _content_resize, obj);
-        _sizing_eval(obj);
-     }
-   _calc(obj);
+   evas_object_box_remove_all(wd->bx, EINA_TRUE);
+   if (!content) return;
+   evas_object_box_append(wd->bx, content);
+   evas_object_show(content);
+   _sizing_eval(obj);
 }