Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : proto

Dir     : e17/proto/esmart/src/container


Modified Files:
        Makefile.am container.c container.h container_smart.c 
        container_util.c 
Added Files:
        container_plugin.c 


Log Message:

layout plugins in the container
-------------------------------
o separate element layout code into loadable modules (only the default at the
  moment)

o possible examples of future layout plugins
  - OS X dock
  - wireframe.co.za (enstrom)
  - old entice

o this isn't done yet, so there are some bugs
  - CONTAINER_PLUGIN_DIR is hard coded in configure.in and
    layout/default/Makefile.am
    anyone familiar enough with autofoo to fix this?
  - lt_dlerror() returns "unkown error" at all times (so i can't do
    proper error checking yet)
  - probably many more...

===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/esmart/src/container/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- Makefile.am 14 Sep 2003 00:30:38 -0000      1.1
+++ Makefile.am 13 Jan 2004 00:48:29 -0000      1.2
@@ -1,5 +1,7 @@
 ## Process this file with automake to produce Makefile.in
 
+SUBDIRS = layout
+
 INCLUDES = @evas_cflags@ @imlib_cflags@
 
 installed_headersdir = $(prefix)/include/Esmart/
@@ -13,6 +15,7 @@
        container.c container.h \
        container_element.c \
        container_smart.c \
+       container_plugin.c container_plugin.h \
        container_util.c
 
 libecontainer_la_LIBADD = @evas_libs@ @imlib_libs@ -lm
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/esmart/src/container/container.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- container.c 5 Nov 2003 00:11:04 -0000       1.6
+++ container.c 13 Jan 2004 00:48:29 -0000      1.7
@@ -11,6 +11,7 @@
 #include "container.h"
 #include "container_private.h"
 
+void _container_elements_layout_entice(Container *cont);
 
 int _container_scroll_timer(void *data);
 
@@ -265,46 +266,39 @@
 void
 e_container_scroll_start(Evas_Object *container, double velocity)
 {
+  Container *cont = _container_fetch(container);
+  if (!cont) return;
+  
+  if (cont->plugin && cont->plugin->scroll_start)
+    cont->plugin->scroll_start(cont, velocity);
+}
+
+void
+e_container_scroll_stop(Evas_Object *container)
+{
   Container *cont;
-  Scroll_Data *data;
-  double length, size;
 
   cont = _container_fetch(container);
-  length = e_container_elements_length_get(container);
-  size = cont->direction ? cont->h : cont->w;
+  if (!cont) return;
 
-  /* don't scroll unless the elements exceed the size of the container */
-  if (length <= size)
-  {
-    printf(" length smaller than size\n");
-    return;
-  }
-  printf("continue\n");
-  data = calloc(1, sizeof(Scroll_Data));
-  data->velocity = velocity;
-  data->start_time = ecore_time_get();
-  data->cont = cont;
-  data->length = length;
- 
-  cont->scroll_timer = ecore_timer_add(.02, _container_scroll_timer, data);
+  if (cont->plugin && cont->plugin->scroll_stop)
+    cont->plugin->scroll_stop(cont);
 }
 
 void
-e_container_scroll_stop(Evas_Object *container)
+e_container_scroll_to(Evas_Object *container, Evas_Object *element)
 {
   Container *cont;
-
+  Container_Element *el;
+  
   cont = _container_fetch(container);
- 
-  /* FIXME: decelerate on stop? */
-  if (cont->scroll_timer)
-  {
-    ecore_timer_del(cont->scroll_timer);  
-    cont->scroll_timer = NULL;
-  }
-}
+  if (!cont) return;
 
+  el = evas_object_data_get(element, "Container_Element");
 
+  if (cont->plugin && cont->plugin->scroll_to)
+    cont->plugin->scroll_to(cont, el);
+}
 /**************** internal  functions *******************/
 
 Container_Element *
@@ -318,9 +312,9 @@
   el = calloc(1, sizeof(Container_Element));
 
   el->obj = obj;
-  evas_object_data_set(obj, "Container_Element", el);
+  evas_object_data_set(obj, "Container_Element", el); 
   evas_object_show(obj);
-
+ 
   evas_object_geometry_get(obj, NULL, NULL, &w, &h);
   el->orig_w = w;
   el->orig_h = h;
@@ -338,13 +332,19 @@
   evas_object_event_callback_add(el->grabber, EVAS_CALLBACK_MOUSE_UP, _cb_element_up, 
el);
   evas_object_event_callback_add(el->grabber, EVAS_CALLBACK_MOUSE_MOVE, 
_cb_element_move, el);
 
-
   return el;
 }
 
 void
 _container_elements_fix(Container *cont)
 {
+  if (cont->plugin && cont->plugin->layout)
+    cont->plugin->layout(cont);
+}
+
+void
+_contianer_elements_layout_normal(Container *cont)
+{
   Evas_List *l;
   double ax, ay, aw, ah; // element area geom
   double ix, iy, iw, ih; // new x, y, w, h
@@ -376,7 +376,7 @@
   if (cont->direction) iy += cont->scroll_offset;
   else ix += cont->scroll_offset;
 
-  L = _container_elements_orig_length_get(cont);
+  L = e_container_elements_orig_length_get(cont->obj);
   num = evas_list_count(cont->elements);
   
   
@@ -560,11 +560,15 @@
 }
 
 double
-_container_elements_orig_length_get(Container *cont)
+e_container_elements_orig_length_get(Evas_Object *container)
 {
+  Container *cont;
   Evas_List *l;
   double length = 0;
 
+  cont = _container_fetch(container);
+  if (!cont) return 0.0;
+
   for (l = cont->elements; l; l = l->next)
   {
     Container_Element *el = l->data;
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/esmart/src/container/container.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- container.h 19 Dec 2003 18:38:43 -0000      1.8
+++ container.h 13 Jan 2004 00:48:29 -0000      1.9
@@ -7,17 +7,23 @@
 #include <stdio.h>
 #include <dirent.h>
 
+/* FIXME: do this right... */
+//#define CONTAINER_PLUGIN_DIR "/usr/local/share/esmart/layout"
+
 /*****
  Todo:
 
    o add a "mover" object that tracks where moving element will go
 
 ****/
+
 typedef struct _Container Container;
 typedef struct _Container_Element Container_Element;
 typedef struct _Scroll_Data Scroll_Data;
 typedef enum _Container_Alignment Container_Alignment;
 typedef enum _Container_Fill_Policy Container_Fill_Policy;
+typedef struct _Container_Layout_Plugin Container_Layout_Plugin;
+
 
 enum _Container_Alignment
 {
@@ -45,6 +51,8 @@
   Evas_Object *clipper; /* element clip */
   Evas_Object *grabber; /* event grabber (for the container as a whole) */
 
+  Container_Layout_Plugin *plugin;
+
   Evas_List *elements;  /* things contained */
 
   struct
@@ -98,6 +106,18 @@
 
 Evas_Object *e_container_new(Evas *evas);
 
+struct _Container_Layout_Plugin{
+  void *handle;
+
+  void (*shutdown)();
+  
+  void (*layout)(Container *cont);
+  
+  void (*scroll_start)(Container *cont, double velocity);
+  void (*scroll_stop)(Container *cont);
+  void (*scroll_to)(Container *cont, Container_Element *el);
+};
+
 
 void e_container_direction_set(Evas_Object *container, int direction);
 int  e_container_direction_get(Evas_Object *container);
@@ -157,4 +177,10 @@
                                            void *data);
 
 double e_container_elements_length_get(Evas_Object *container);
+double e_container_elements_orig_length_get(Evas_Object *container);
+
+int e_container_layout_plugin_set(Evas_Object *container, const char *name);
+
+
+
 #endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/esmart/src/container/container_smart.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- container_smart.c   5 Nov 2003 00:11:04 -0000       1.6
+++ container_smart.c   13 Jan 2004 00:48:29 -0000      1.7
@@ -29,6 +29,17 @@
   Evas_Object *container;
 
   container = evas_object_smart_add(evas, _container_smart_get());
+ 
+  {
+    Container *cont = _container_fetch(container);
+    if (!cont) printf("wtf! (%s)\n", evas_object_type_get(container));
+  }
+  /* load the default layout plugin */
+  if (!e_container_layout_plugin_set(container, "default"))
+  {
+    evas_object_del(container);
+    return NULL;
+  }
 
   return container;
 }
@@ -86,6 +97,7 @@
   evas_object_event_callback_add(data->grabber, EVAS_CALLBACK_MOUSE_DOWN, 
_cb_container, data);
   evas_object_event_callback_add(data->grabber, EVAS_CALLBACK_MOUSE_UP, 
_cb_container, data);
   evas_object_event_callback_add(data->grabber, EVAS_CALLBACK_MOUSE_MOVE, 
_cb_container, data);
+
 }
 
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/esmart/src/container/container_util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- container_util.c    21 Oct 2003 22:08:34 -0000      1.2
+++ container_util.c    13 Jan 2004 00:48:29 -0000      1.3
@@ -1,3 +1,4 @@
+#include <sys/stat.h>
 #include "container.h"
 #include "container_private.h"
 
@@ -33,3 +34,38 @@
 
   
 }
+
+int is_dir(const char *dir) {
+       struct stat st;
+
+       if (stat(dir, &st))
+               return 0;
+
+       return (S_ISDIR(st.st_mode));
+}
+
+
+Evas_List *_dir_get_files(const char *directory) {
+       Evas_List *list = NULL;
+       DIR *dir;
+       struct dirent *entry;
+
+       if (!(dir = opendir(directory)))
+               return NULL;
+
+       while ((entry = readdir(dir))) {
+               if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
+                       continue;
+
+               if (!is_dir(entry->d_name))
+                       list = evas_list_prepend(list, strdup(entry->d_name));
+       }
+
+       closedir(dir);
+
+       if (list)
+               list = evas_list_reverse(list);
+
+       return list;
+}
+




-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to