Hi all,
Sometime ago I've written a smart object, that is very similiar to
Esmart_Draggies, actually I started to modify a copy of draggies. The
purpose of this object is to resize a borderless window. You can set, in
which directions it will resize the window. I named it Esmart_Resize.
Find a patch attached and a test app here: mowem.de/esmart/esr.tar.bz2.
Please let me know if you find it useful and I will commit it.
pfritz
P.S. Sorry that I already commit the subdir. I wonder if it is possible
to add a dir with out committing it.
Index: configure.in
===================================================================
RCS file: /cvs/e/e17/libs/esmart/configure.in,v
retrieving revision 1.19
diff -u -r1.19 configure.in
--- configure.in 5 May 2007 15:14:17 -0000 1.19
+++ configure.in 24 Jun 2007 09:38:39 -0000
@@ -57,6 +57,15 @@
]
)
+PKG_CHECK_MODULES(RESIZE, [
+ evas >= 0.9.9
+ ecore-evas >= 0.9.9
+ ], [
+ have_esmart_resize=yes
+ requirements="$requirements ecore-evas"
+ ]
+)
+
PKG_CHECK_MODULES(TRANSX11, [
evas >= 0.9.9
ecore-x >= 0.9.9
@@ -107,6 +116,7 @@
AM_CONDITIONAL(BUILD_ESMART_CONTAINER, test $have_esmart_container = yes)
AM_CONDITIONAL(BUILD_ESMART_DRAGGIES, test $have_esmart_draggies = yes)
+AM_CONDITIONAL(BUILD_ESMART_RESIZE, test $have_esmart_draggies = yes)
AM_CONDITIONAL(BUILD_ESMART_FILE_DIALOG, test $have_esmart_file_dialog = yes)
AM_CONDITIONAL(BUILD_ESMART_TEXT_ENTRY, test $have_esmart_text_entry = yes)
AM_CONDITIONAL(BUILD_ESMART_TEXTAREA, test $have_esmart_textarea = yes)
@@ -137,6 +147,7 @@
src/lib/esmart_thumb/Makefile
src/lib/esmart_trans_x11/Makefile
src/lib/esmart_draggies/Makefile
+src/lib/esmart_resize/Makefile
src/bin/Makefile
data/Makefile
data/images/Makefile
@@ -158,6 +169,7 @@
echo "Components:"
echo " Container...............: $have_esmart_container"
echo " Draggies................: $have_esmart_draggies"
+echo " Resize..................: $have_esmart_draggies"
echo " File Dialog.............: $have_esmart_file_dialog"
echo " Text Entry..............: $have_esmart_text_entry"
echo " Text Area...............: $have_esmart_textarea"
Index: src/lib/Makefile.am
===================================================================
RCS file: /cvs/e/e17/libs/esmart/src/lib/Makefile.am,v
retrieving revision 1.4
diff -u -r1.4 Makefile.am
--- src/lib/Makefile.am 21 Mar 2007 13:22:42 -0000 1.4
+++ src/lib/Makefile.am 24 Jun 2007 09:38:39 -0000
@@ -6,6 +6,10 @@
draggies_subdir = esmart_draggies
endif
+if BUILD_ESMART_RESIZE
+resize_subdir = esmart_resize
+endif
+
if BUILD_ESMART_FILE_DIALOG
file_dialog_subdir = esmart_file_dialog
endif
@@ -28,7 +32,7 @@
SUBDIRS = \
$(container_subdir) $(draggies_subdir) $(text_entry_subdir) \
- $(file_dialog_subdir) $(thumb_subdir) $(trans_subdir)
+ $(file_dialog_subdir) $(thumb_subdir) $(trans_subdir) $(resize_subdir)
# adding textarea_subdir breaks distcheck
# $(textarea_subdir)
Index: src/lib/esmart_resize/Esmart_Resize.h
===================================================================
RCS file: src/lib/esmart_resize/Esmart_Resize.h
diff -N src/lib/esmart_resize/Esmart_Resize.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/esmart_resize/Esmart_Resize.h 24 Jun 2007 09:38:39 -0000
@@ -0,0 +1,74 @@
+#ifndef ESMART_RESIZE_H
+#define ESMART_RESIZE_H
+
+#ifdef EAPI
+#undef EAPI
+#endif
+#ifdef WIN32
+# ifdef BUILDING_DLL
+# define EAPI __declspec(dllexport)
+# else
+# define EAPI __declspec(dllimport)
+# endif
+#else
+# ifdef __GNUC__
+# if __GNUC__ >= 4
+# define EAPI __attribute__ ((visibility("default")))
+# else
+# define EAPI
+# endif
+# else
+# define EAPI
+# endif
+#endif
+
+#include<Evas.h>
+#include<Ecore_Evas.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * How to use Esmart Resize.
+ */
+typedef struct _Esmart_Resize Esmart_Resize;
+
+struct _Esmart_Resize
+{
+ Ecore_Evas *ee; /* The ecore_evas that should resize */
+ int dx, dy; /* offset from 0,0 of the window */
+ int w, h; /* The size of the window at the begining*/
+ int x, y; /* The position of the window at the
+ beginning */
+ int resize_x, resize_y; /* the resize direction */
+ int clicked; /* Whether the mouse is down now or not */
+ int button; /* the button that handles dragging */
+ Evas_Object *obj; /* the rectangle that gets events */
+};
+
+typedef enum {
+ ESMART_RESIZE_LEFT = 0,
+ ESMART_RESIZE_RIGHT,
+ ESMART_RESIZE_TOP,
+ ESMART_RESIZE_BOTTOM,
+ ESMART_RESIZE_LEFT_TOP,
+ ESMART_RESIZE_RIGHT_TOP,
+ ESMART_RESIZE_LEFT_BOTTOM,
+ ESMART_RESIZE_RIGHT_BOTTOM
+} Esmart_Resize_Type;
+
+EAPI Evas_Object *esmart_resize_new (Ecore_Evas * evas);
+EAPI void esmart_resize_button_set (Evas_Object * o, int button);
+EAPI void esmart_resize_event_callback_add (Evas_Object * o,
+ Evas_Callback_Type type,
+ void (*func) (void *data, Evas * e,
+ Evas_Object * o,
+ void *ev),
+ const void *data);
+EAPI void esmart_resize_type_set(Evas_Object * o, Esmart_Resize_Type type);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: src/lib/esmart_resize/Makefile.am
===================================================================
RCS file: src/lib/esmart_resize/Makefile.am
diff -N src/lib/esmart_resize/Makefile.am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/esmart_resize/Makefile.am 24 Jun 2007 09:38:39 -0000
@@ -0,0 +1,15 @@
+pkgdir = @libdir@
+pkg_LTLIBRARIES = libesmart_resize.la
+
+INCLUDES = -I$(top_srcdir)/src/lib/esmart_resize \
+ @RESIZE_CFLAGS@
+
+installed_headersdir = $(prefix)/include/Esmart
+installed_headers_DATA = Esmart_Resize.h
+
+libesmart_resize_la_SOURCES = esmart_resize.c \
+ Esmart_Resize.h
+
+libesmart_resize_la_LDFLAGS = -version-info 0:9:0
+libesmart_resize_la_LIBADD = @RESIZE_LIBS@
+
Index: src/lib/esmart_resize/esmart_resize.c
===================================================================
RCS file: src/lib/esmart_resize/esmart_resize.c
diff -N src/lib/esmart_resize/esmart_resize.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/esmart_resize/esmart_resize.c 24 Jun 2007 09:38:40 -0000
@@ -0,0 +1,340 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Ecore_X.h>
+#include "Esmart_Resize.h"
+
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+
+static Evas_Smart *_esmart_resize_object_smart_get();
+static Evas_Object *esmart_resize_object_new(Evas * evas);
+static void _esmart_resize_object_add(Evas_Object * o);
+static void _esmart_resize_object_del(Evas_Object * o);
+static void _esmart_resize_object_move(Evas_Object * o, Evas_Coord x,
+ Evas_Coord y);
+static void _esmart_resize_object_resize(Evas_Object * o, Evas_Coord w,
+ Evas_Coord h);
+static void _esmart_resize_object_show(Evas_Object * o);
+static void _esmart_resize_object_hide(Evas_Object * o);
+static void _esmart_resize_object_color_set(Evas_Object * o, int r, int g,
+ int b, int a);
+static void _esmart_resize_object_clip_set(Evas_Object * o,
+ Evas_Object * clip);
+static void _esmart_resize_object_clip_unset(Evas_Object * o);
+
+/*==========================================================================
+ * The actual code that handles the resizing of the window
+ *========================================================================*/
+static void
+_mouse_up_cb(void *data, Evas * evas, Evas_Object * obj, void *ev)
+{
+ Esmart_Resize *drag = NULL;
+ Evas_Event_Mouse_Up *e = NULL;
+
+ if ((drag = (Esmart_Resize *) data)
+ && (e = (Evas_Event_Mouse_Up *) ev)
+ && e->button == drag->button)
+ {
+ drag->clicked = 0;
+ drag->dx = drag->dy = 0;
+ }
+}
+
+static void
+_mouse_down_cb(void *data, Evas * evas, Evas_Object * obj, void *ev)
+{
+ Esmart_Resize *drag = NULL;
+ Evas_Event_Mouse_Down *e = NULL;
+ Ecore_X_Event_Mouse_Button_Down *evx = NULL;
+
+ if ((drag = (Esmart_Resize *) data)
+ && ecore_event_current_type_get() == ECORE_X_EVENT_MOUSE_BUTTON_DOWN
+ && (evx = (Ecore_X_Event_Mouse_Button_Down *)
+ ecore_event_current_event_get())
+ && (e = (Evas_Event_Mouse_Down *) ev)
+ && e->button == drag->button)
+ {
+ ecore_evas_geometry_get(drag->ee, &(drag->x),
+ &(drag->y), &(drag->w),
+ &(drag->h));
+ drag->clicked = 1;
+ drag->dx = evx->root.x;
+ drag->dy = evx->root.y;
+ }
+}
+
+static void
+_mouse_move_cb(void *data, Evas * evas, Evas_Object * obj, void *ev)
+{
+ Esmart_Resize *drag = NULL;
+ Ecore_X_Event_Mouse_Move *evx = NULL;
+
+ if ((drag = (Esmart_Resize *) data)
+ && ecore_event_current_type_get() == ECORE_X_EVENT_MOUSE_MOVE
+ && (evx = (Ecore_X_Event_Mouse_Move *)
+ ecore_event_current_event_get())
+ && drag->clicked)
+ {
+ int h, w, x, y;
+ int minw, minh, maxw, maxh;
+
+ w = drag->w + drag->resize_x * (evx->root.x - drag->dx);
+ h = drag->h + drag->resize_y * (evx->root.y - drag->dy);
+
+ ecore_evas_size_min_get(drag->ee, &minw, &minh);
+ ecore_evas_size_max_get(drag->ee, &maxw, &maxh);
+
+ w = MAX(minw, w);
+ h = MAX(minh, h);
+ w = MIN(maxw, w);
+ h = MIN(maxh, h);
+
+ if (drag->resize_x < 0)
+ x = drag->x - w + drag->w;
+ else
+ x = drag->x;
+ if (drag->resize_y < 0)
+ y = drag->y - h + drag->h;
+ else
+ y = drag->y;
+
+ ecore_evas_move_resize(drag->ee, x, y, w, h);
+ }
+}
+
+/*==========================================================================
+ * The three external functions, new, button set and type set
+ *========================================================================*/
+EAPI Evas_Object *
+esmart_resize_new(Ecore_Evas * ee)
+{
+ Evas_Object *o = NULL;
+ Evas_Object *result = NULL;
+ Esmart_Resize *data = NULL;
+
+ if (!ee)
+ return NULL;
+ if ((result = esmart_resize_object_new(ecore_evas_get(ee)))
+ && (data = (Esmart_Resize *) evas_object_smart_data_get(result)))
+ {
+ data->ee = ee;
+ o = evas_object_rectangle_add(ecore_evas_get(ee));
+ evas_object_color_set(o, 255, 255, 255, 0);
+ evas_object_repeat_events_set(o, 1);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
+ _mouse_down_cb, data);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP,
+ _mouse_up_cb, data);
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE,
+ _mouse_move_cb, data);
+ data->obj = o;
+ }
+ return result;
+}
+
+EAPI void
+esmart_resize_button_set(Evas_Object * o, int button)
+{
+ Esmart_Resize *data = NULL;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ data->button = button;
+ }
+}
+
+EAPI void
+esmart_resize_type_set(Evas_Object * o, Esmart_Resize_Type type)
+{
+ Esmart_Resize *data = NULL;
+
+ if (!(data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ return;
+
+ switch (type)
+ {
+ case ESMART_RESIZE_LEFT:
+ case ESMART_RESIZE_LEFT_BOTTOM:
+ case ESMART_RESIZE_LEFT_TOP:
+ data->resize_x = -1;
+ break;
+ case ESMART_RESIZE_TOP:
+ case ESMART_RESIZE_BOTTOM:
+ data->resize_x = 0;
+ break;
+ default:
+ data->resize_x = 1;
+ }
+ switch (type)
+ {
+ case ESMART_RESIZE_TOP:
+ case ESMART_RESIZE_LEFT_TOP:
+ case ESMART_RESIZE_RIGHT_TOP:
+ data->resize_y = -1;
+ break;
+ case ESMART_RESIZE_LEFT:
+ case ESMART_RESIZE_RIGHT:
+ data->resize_y = 0;
+ break;
+ default:
+ data->resize_y = 1;
+ }
+}
+
+EAPI void
+esmart_resize_event_callback_add(Evas_Object * o, Evas_Callback_Type type,
+ void (*func) (void *data, Evas * e, Evas_Object * obj, void *ev),
+ const void *user_data)
+{
+ Esmart_Resize *data = NULL;
+
+ if ((data = (Esmart_Resize *)evas_object_smart_data_get(o)))
+ {
+ evas_object_event_callback_add(data->obj, type, func, user_data);
+ }
+}
+
+/*==========================================================================
+ * Smart Object Code, Go Away
+ *========================================================================*/
+
+static Evas_Object *
+esmart_resize_object_new(Evas * evas)
+{
+ Evas_Object *esmart_resize_object;
+
+ esmart_resize_object =
+ evas_object_smart_add(evas, _esmart_resize_object_smart_get());
+
+ return esmart_resize_object;
+}
+
+static Evas_Smart *
+_esmart_resize_object_smart_get()
+{
+ static Evas_Smart *smart = NULL;
+
+ if (smart)
+ return smart;
+
+ smart = evas_smart_new("esmart_resize_object",
+ _esmart_resize_object_add,
+ _esmart_resize_object_del,
+ NULL, NULL, NULL, NULL, NULL,
+ _esmart_resize_object_move,
+ _esmart_resize_object_resize,
+ _esmart_resize_object_show,
+ _esmart_resize_object_hide,
+ _esmart_resize_object_color_set,
+ _esmart_resize_object_clip_set,
+ _esmart_resize_object_clip_unset, NULL);
+
+ return smart;
+}
+
+static void
+_esmart_resize_object_add(Evas_Object * o)
+{
+ Esmart_Resize *data = NULL;
+
+ data = (Esmart_Resize *) calloc(1, sizeof(Esmart_Resize));
+ evas_object_smart_data_set(o, data);
+}
+
+static void
+_esmart_resize_object_del(Evas_Object * o)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ data->ee = NULL;
+ if (data->obj)
+ evas_object_del(data->obj);
+ free(data);
+ }
+}
+
+static void
+_esmart_resize_object_move(Evas_Object * o, Evas_Coord x, Evas_Coord y)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_move(data->obj, x, y);
+ }
+}
+
+static void
+_esmart_resize_object_resize(Evas_Object * o, Evas_Coord w, Evas_Coord h)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_resize(data->obj, w, h);
+ }
+}
+
+static void
+_esmart_resize_object_show(Evas_Object * o)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_show(data->obj);
+ }
+}
+
+static void
+_esmart_resize_object_hide(Evas_Object * o)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_hide(data->obj);
+ }
+}
+
+static void
+_esmart_resize_object_color_set(Evas_Object * o, int r, int g, int b, int a)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_color_set(data->obj, r, g, b, a);
+ }
+}
+
+static void
+_esmart_resize_object_clip_set(Evas_Object * o, Evas_Object * clip)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_clip_set(data->obj, clip);
+ }
+}
+
+static void
+_esmart_resize_object_clip_unset(Evas_Object * o)
+{
+ Esmart_Resize *data;
+
+ if ((data = (Esmart_Resize *) evas_object_smart_data_get(o)))
+ {
+ evas_object_clip_unset(data->obj);
+ }
+}
+
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel