aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/guitest
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-01-01 04:36:59 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-01-01 04:36:59 +0000
commit59e66762250fe61d570c5baf6c9ce6896a09e027 (patch)
tree422e3386845e00ef0994348a7c46f01aea38abbe /externals/grill/guitest
parent0e1fe750cfd8467a80530cbc70326c81f41a8fe5 (diff)
""
svn path=/trunk/; revision=315
Diffstat (limited to 'externals/grill/guitest')
-rw-r--r--externals/grill/guitest/flgui.cpp46
-rw-r--r--externals/grill/guitest/flgui.h17
-rw-r--r--externals/grill/guitest/main.cpp12
3 files changed, 62 insertions, 13 deletions
diff --git a/externals/grill/guitest/flgui.cpp b/externals/grill/guitest/flgui.cpp
index 1bad0851..2753d303 100644
--- a/externals/grill/guitest/flgui.cpp
+++ b/externals/grill/guitest/flgui.cpp
@@ -107,7 +107,8 @@ void flext_gui::setup(t_class *c)
#if FLEXT_SYS == FLEXT_SYS_PD
-int flext_gui::evmask = evMotion|evMouseDown|evKeyDown|evKeyUp;
+// this event mask declares supported events
+int flext_gui::evmask = evMotion|evMouseDown|evMouseDrag|evKeyDown|evKeyUp|evKeyRepeat;
int flext_gui::curmod = 0;
flext_gui::pxkey_object *flext_gui::pxkey = NULL;
flext_gui::guicanv *flext_gui::gcanv = NULL;
@@ -228,8 +229,25 @@ void flext_gui::pxkey_method(pxkey_object *obj,const t_symbol *s,int argc,t_atom
// post("Key down=%i c=%c mod=%i",down?1:0,code,curmod);
if(code || mod) {
+ // remember past keycodes for repetition detection
+ static int lastcode = 0,lastasc = 0,lastmod = 0;
+
// button is pressed
- p.kind = down?evKeyDown:evKeyUp;
+ if(down) {
+ if(lastcode == code && lastmod == curmod)
+ p.kind = evKeyRepeat;
+ else {
+ p.kind = evKeyDown;
+ lastcode = code;
+ lastasc = asc;
+ lastmod = curmod;
+ }
+ }
+ else {
+ p.kind = evKeyUp;
+ lastcode = lastasc = 0;
+ }
+
p.ext = true;
p.pKey.k = code; //lastkey;
p.pKey.a = asc;
@@ -438,7 +456,7 @@ void flext_gui::sg_vis(t_gobj *c, t_glist *, int vis)
}
}
-int flext_gui::sg_click(t_gobj *c, t_glist *,int xpix, int ypix, int shift, int alt, int dbl, int doit)
+int flext_gui::sg_click(t_gobj *c, t_glist *gl,int xpix, int ypix, int shift, int alt, int dbl, int doit)
{
flext_gui *g = thisObject(c);
CBParams p;
@@ -451,10 +469,13 @@ int flext_gui::sg_click(t_gobj *c, t_glist *,int xpix, int ypix, int shift, int
if(doit) {
// button is pressed
p.kind = evMouseDown;
- p.pMouseKey.x = x;
- p.pMouseKey.y = y;
+ p.pMouseKey.x = g->xdrag = x;
+ p.pMouseKey.y = g->ydrag = y;
+ g->dxdrag = g->dydrag = 0;
p.pMouseKey.b = 1;
p.pMouseKey.mod = curmod; //mod;
+
+ glist_grab(gl,c,(t_glistmotionfn)sg_drag,0,xpix,ypix);
}
else {
// only mouse position change
@@ -467,6 +488,20 @@ int flext_gui::sg_click(t_gobj *c, t_glist *,int xpix, int ypix, int shift, int
return 1;
}
+void flext_gui::sg_drag(t_gobj *c,t_floatarg dx,t_floatarg dy)
+{
+ flext_gui *g = thisObject(c);
+ CBParams p;
+ p.kind = evMouseDrag;
+ p.pMouseDrag.dx = (g->dxdrag += (int)dx);
+ p.pMouseDrag.dy = (g->dydrag += (int)dy);
+ p.pMouseDrag.x = g->xdrag+g->dxdrag;
+ p.pMouseDrag.y = g->ydrag+g->dydrag;;
+ p.pMouseDrag.b = 1;
+ p.pMouseDrag.mod = curmod; //mod;
+ g->m_Method(p);
+}
+
void flext_gui::sg_delete(t_gobj *c, t_glist *)
{
thisObject(c)->g_Delete();
@@ -505,6 +540,7 @@ bool flext_gui::sg_KeyUp(flext_base *c,int &keynum)
#else // MAXMSP
+// this declared supported events
int flext_gui::evmask = evMotion|evMouseDown|evKeyDown;
static void dragfun()
diff --git a/externals/grill/guitest/flgui.h b/externals/grill/guitest/flgui.h
index 211a4935..3ca2b399 100644
--- a/externals/grill/guitest/flgui.h
+++ b/externals/grill/guitest/flgui.h
@@ -1,7 +1,7 @@
#ifndef __FLEXT_GUI
#define __FLEXT_GUI
-#define FLEXT_VIRT
+//#define FLEXT_VIRT
#include <flext.h>
#if FLEXT_SYS == FLEXT_SYS_PD
@@ -15,9 +15,9 @@ class GuiGroup;
class GuiSingle;
class flext_gui:
- virtual public flext_base
+ public flext_base
{
- FLEXT_HEADER_S(flext_gui,flext_base,setup)
+ FLEXT_HEADER_S(flext_gui,flext_dsp,setup)
public:
flext_gui(int xs,int ys);
@@ -29,8 +29,10 @@ public:
evMouseDown = 0x02,
evMouseUp = 0x04,
evMouseWheel = 0x08,
- evKeyDown = 0x10,
- evKeyUp = 0x20
+ evMouseDrag = 0x10,
+ evKeyDown = 0x20,
+ evKeyUp = 0x40,
+ evKeyRepeat = 0x80
};
class CBParams {
@@ -42,6 +44,7 @@ public:
struct { int x,y,mod; } pMotion;
struct { int x,y,b,mod; } pMouseKey;
struct { int x,y,mod,delta; } pMouseWheel;
+ struct { int x,y,dx,dy,b,mod; } pMouseDrag;
struct { int k,a,mod; } pKey;
};
bool ext;
@@ -146,6 +149,7 @@ private:
#if FLEXT_SYS == FLEXT_SYS_PD
bool selected;
int xsize,ysize;
+ int xdrag,ydrag,dxdrag,dydrag;
static void sg_getrect(t_gobj *c, t_glist *,int *xp1, int *yp1, int *xp2, int *yp2);
static void sg_displace(t_gobj *c, t_glist *, int dx, int dy);
@@ -154,6 +158,7 @@ private:
static void sg_delete(t_gobj *c, t_glist *);
static void sg_vis(t_gobj *c, t_glist *, int vis);
static int sg_click(t_gobj *c, t_glist *,int xpix, int ypix, int shift, int alt, int dbl, int doit);
+ static void sg_drag(t_gobj *x, t_floatarg dx, t_floatarg dy);
static void sg_properties(t_gobj *c, t_glist *);
static void sg_save(t_gobj *c, t_binbuf *b);
// static void sg_motion(void *c, float dx,float dy) { thisObject((t_gobj *)c)->g_Motion(dx,dy); }
@@ -210,7 +215,7 @@ public:
static t_class *px_class,*pxkey_class;
static void sg_tk(t_canvas *c,const t_symbol *s,int argc,t_atom *argv);
-#else
+#else // MAXMSP
int curx,cury,curmod;
bool created;
static t_clock clock;
diff --git a/externals/grill/guitest/main.cpp b/externals/grill/guitest/main.cpp
index cfedfa86..661c3ad2 100644
--- a/externals/grill/guitest/main.cpp
+++ b/externals/grill/guitest/main.cpp
@@ -21,7 +21,7 @@
#define UL unsigned long
class guitest:
-public flext_gui,virtual public flext_base
+public flext_gui //,virtual public flext_base
{
FLEXT_HEADER(guitest,flext_gui)
@@ -29,7 +29,7 @@ public:
guitest(I argc,t_atom *argv);
~guitest();
- virtual void m_bang()
+ void m_bang()
{
post("%s - bang!",thisName());
}
@@ -69,9 +69,11 @@ void guitest::g_Create()
delete[] p;
if(!BindEvent(*frame,g_Motion,evMotion)) post("Motion not supported");
+ if(!BindEvent(*frame,g_Motion,evMouseDrag)) post("MouseDrag not supported");
if(!BindEvent(*wave,g_MouseKey,evMouseDown)) post("MouseDown not supported");
if(!BindEvent(*wave,g_MouseKey,evKeyDown)) post("KeyDown not supported");
if(!BindEvent(*wave,g_MouseKey,evKeyUp)) post("KeyUp not supported");
+ if(!BindEvent(*wave,g_MouseKey,evKeyRepeat)) post("KeyRepeat not supported");
}
void guitest::g_Properties()
@@ -107,6 +109,9 @@ bool guitest::g_Motion(flext_gui &g,GuiSingle &obj,const CBParams &p)
if(p.kind == evMotion) {
post("Motion %s x:%i y:%i mod:%i",GetString(obj.Id()),p.pMotion.x,p.pMotion.y,p.pMotion.mod);
}
+ else if(p.kind == evMouseDrag) {
+ post("Drag %s x:%i y:%i dx:%i dy:%i b:%i mod:%i",GetString(obj.Id()),p.pMouseDrag.x,p.pMouseDrag.y,p.pMouseDrag.dx,p.pMouseDrag.dy,p.pMouseDrag.b,p.pMouseDrag.mod);
+ }
else
post("Motion");
return true;
@@ -123,6 +128,9 @@ bool guitest::g_MouseKey(flext_gui &g,GuiSingle &obj,const CBParams &p)
else if(p.kind == evKeyUp) {
post("KeyUp %s asc:%i key:%i mod:%i",GetString(obj.Id()),p.pKey.a,p.pKey.k,p.pKey.mod);
}
+ else if(p.kind == evKeyRepeat) {
+ post("KeyRepeat %s asc:%i key:%i mod:%i",GetString(obj.Id()),p.pKey.a,p.pKey.k,p.pKey.mod);
+ }
return true;
}