Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David MacDonald
purr-data
Commits
699889af
Commit
699889af
authored
May 31, 2016
by
Jonathan Wilkes
Browse files
first try at porting envgen -- still needs select and click widgetbehavior
parent
a244f428
Changes
2
Hide whitespace changes
Inline
Side-by-side
externals/ggee/gui/w_envgen.h
View file @
699889af
...
...
@@ -13,45 +13,80 @@
static
void
draw_inlets
(
t_envgen
*
x
,
t_glist
*
glist
,
int
firsttime
,
int
nin
,
int
nout
)
{
int
n
=
nout
;
int
nplus
,
i
;
int
xpos
=
text_xpix
(
&
x
->
x_obj
,
glist
);
int
ypos
=
text_ypix
(
&
x
->
x_obj
,
glist
);
nplus
=
(
n
==
1
?
1
:
n
-
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
onset
=
xpos
+
(
x
->
w
.
width
-
2
*
BORDER
)
*
i
/
nplus
;
if
(
firsttime
)
sys_vgui
(
".x%x.c create rectangle %d %d %d %d -tags %xo%d
\n
"
,
glist_getcanvas
(
glist
),
onset
,
ypos
+
x
->
w
.
height
-
1
+
2
*
BORDER
,
onset
+
IOWIDTH
,
ypos
+
x
->
w
.
height
+
2
*
BORDER
,
x
,
i
);
else
sys_vgui
(
".x%x.c coords %xo%d %d %d %d %d
\n
"
,
glist_getcanvas
(
glist
),
x
,
i
,
onset
,
ypos
+
x
->
w
.
height
-
1
+
2
*
BORDER
,
onset
+
IOWIDTH
,
ypos
+
x
->
w
.
height
+
2
*
BORDER
);
}
n
=
nin
;
nplus
=
(
n
==
1
?
1
:
n
-
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
onset
=
xpos
+
(
x
->
w
.
width
-
IOWIDTH
)
*
i
/
nplus
-
BORDER
;
if
(
firsttime
)
sys_vgui
(
".x%x.c create rectangle %d %d %d %d -tags %xi%d
\n
"
,
glist_getcanvas
(
glist
),
onset
,
ypos
-
BORDER
,
onset
+
IOWIDTH
,
ypos
+
1
-
BORDER
,
x
,
i
);
else
sys_vgui
(
".x%x.c coords %xi%d %d %d %d %d
\n
"
,
glist_getcanvas
(
glist
),
x
,
i
,
onset
,
ypos
-
BORDER
,
onset
+
IOWIDTH
,
ypos
+
1
-
BORDER
);
}
int
n
=
nout
;
int
nplus
,
i
;
int
xpos
=
text_xpix
(
&
x
->
x_obj
,
glist
);
int
ypos
=
text_ypix
(
&
x
->
x_obj
,
glist
);
nplus
=
(
n
==
1
?
1
:
n
-
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
onset
=
xpos
+
(
x
->
w
.
width
-
2
*
BORDER
)
*
i
/
nplus
;
if
(
firsttime
)
{
//sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
// glist_getcanvas(glist),
// onset, ypos + x->w.height - 1 + 2*BORDER,
// onset + IOWIDTH, ypos + x->w.height + 2*BORDER,
// x, i);
gui_vmess
(
"gui_gobj_draw_io"
,
"xxxiiiiiisiii"
,
glist_getcanvas
(
glist
),
x
,
x
,
onset
,
ypos
+
x
->
w
.
height
-
1
+
2
*
BORDER
,
onset
+
IOWIDTH
,
ypos
+
x
->
w
.
height
+
2
*
BORDER
,
xpos
,
ypos
,
"o"
,
i
,
0
,
0
);
}
else
{
//sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
// glist_getcanvas(glist), x, i,
// onset, ypos + x->w.height - 1 + 2*BORDER,
// onset + IOWIDTH, ypos + x->w.height + 2*BORDER);
}
}
n
=
nin
;
nplus
=
(
n
==
1
?
1
:
n
-
1
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
int
onset
=
xpos
+
(
x
->
w
.
width
-
IOWIDTH
)
*
i
/
nplus
;
if
(
firsttime
)
{
//sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
// glist_getcanvas(glist),
// onset, ypos - BORDER,
// onset + IOWIDTH, ypos + 1 - BORDER,
// x, i);
gui_vmess
(
"gui_gobj_draw_io"
,
"xxxiiiiiisiii"
,
glist_getcanvas
(
glist
),
x
,
x
,
onset
,
ypos
,
onset
+
IOWIDTH
,
ypos
+
1
,
xpos
,
ypos
,
"i"
,
i
,
0
,
0
);
}
else
{
//sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
// glist_getcanvas(glist), x, i,
// onset, ypos - BORDER,
// onset + IOWIDTH, ypos + 1 - BORDER);
}
}
}
...
...
@@ -202,51 +237,71 @@ static void envgen_shownum(t_envgen *x,t_glist* glist)
static
void
envgen_create
(
t_envgen
*
x
,
t_glist
*
glist
)
{
int
i
;
static
char
buf
[
1024
];
float
xscale
,
yscale
;
int
xpos
,
ypos
;
char
num
[
40
];
xpos
=
text_xpix
(
&
x
->
x_obj
,
glist
);
ypos
=
(
int
)
text_ypix
(
&
x
->
x_obj
,
glist
);
x
->
w
.
numclock
=
clock_new
(
x
,
(
t_method
)
envgen_delnum
);
sys_vgui
(
".x%x.c create rectangle \
%d %d %d %d -tags %xS -fill "
BACKGROUNDCOLOR
"
\n
"
,
glist_getcanvas
(
glist
),
xpos
-
BORDER
,
ypos
-
BORDER
,
xpos
+
x
->
w
.
width
+
2
*
BORDER
,
ypos
+
x
->
w
.
height
+
2
*
BORDER
,
x
);
xscale
=
x
->
w
.
width
/
x
->
duration
[
x
->
last_state
];
yscale
=
x
->
w
.
height
;
sprintf
(
buf
,
".x%x.c create line"
,(
unsigned
int
)
glist_getcanvas
(
glist
));
for
(
i
=
0
;
i
<=
x
->
last_state
;
i
++
)
{
sprintf
(
num
,
" %d %d "
,(
int
)(
xpos
+
x
->
duration
[
i
]
*
xscale
),
(
int
)(
ypos
+
x
->
w
.
height
-
x
->
finalvalues
[
i
]
*
yscale
));
strcat
(
buf
,
num
);
}
sprintf
(
num
,
"-tags %pP
\n
"
,
x
);
strcat
(
buf
,
num
);
sys_vgui
(
"%s"
,
buf
);
envgen_create_doodles
(
x
,
glist
);
int
i
;
static
char
buf
[
1024
];
float
xscale
,
yscale
;
int
xpos
,
ypos
;
char
num
[
40
];
xpos
=
text_xpix
(
&
x
->
x_obj
,
glist
);
ypos
=
(
int
)
text_ypix
(
&
x
->
x_obj
,
glist
);
x
->
w
.
numclock
=
clock_new
(
x
,
(
t_method
)
envgen_delnum
);
gui_vmess
(
"gui_gobj_new"
,
"xxsiii"
,
glist_getcanvas
(
glist
),
x
,
"obj"
,
xpos
,
ypos
);
//sys_vgui(".x%x.c create rectangle "
// "%d %d %d %d -tags %xS -fill "BACKGROUNDCOLOR"\n",
// glist_getcanvas(glist),
// xpos-BORDER, ypos-BORDER,
// xpos + x->w.width+2*BORDER, ypos + x->w.height+2*BORDER,
// x);
gui_start_vmess
(
"gui_envgen_draw_bg"
,
"xxsii"
,
glist_getcanvas
(
glist
),
x
,
BACKGROUNDCOLOR
,
x
->
w
.
width
+
2
*
BORDER
,
x
->
w
.
height
+
2
*
BORDER
);
xscale
=
x
->
w
.
width
/
x
->
duration
[
x
->
last_state
];
yscale
=
x
->
w
.
height
;
//sprintf(buf,".x%x.c create line",(unsigned int)glist_getcanvas(glist));
gui_start_array
();
for
(
i
=
0
;
i
<=
x
->
last_state
;
i
++
)
{
//sprintf(num," %d %d ",
// (int)(xpos + x->duration[i] * xscale),
// (int)(ypos + x->w.height - x->finalvalues[i] * yscale));
//strcat(buf,num);
gui_i
(
x
->
duration
[
i
]
*
xscale
);
gui_i
(
x
->
w
.
height
-
x
->
finalvalues
[
i
]
*
yscale
);
}
gui_end_array
();
gui_end_vmess
();
//sprintf(num,"-tags %pP\n",x);
//strcat(buf,num);
//sys_vgui("%s",buf);
envgen_create_doodles
(
x
,
glist
);
}
static
void
envgen_update
(
t_envgen
*
x
,
t_glist
*
glist
)
{
int
i
;
static
char
buf
[
1024
];
float
xscale
,
yscale
;
char
num
[
40
];
int
xpos
=
text_xpix
(
&
x
->
x_obj
,
glist
);
int
ypos
=
text_ypix
(
&
x
->
x_obj
,
glist
);
sys_vgui
(
".x%x.c coords %xS \
int
i
;
static
char
buf
[
1024
];
float
xscale
,
yscale
;
char
num
[
40
];
int
xpos
=
text_xpix
(
&
x
->
x_obj
,
glist
);
int
ypos
=
text_ypix
(
&
x
->
x_obj
,
glist
);
sys_vgui
(
".x%x.c coords %xS \
%d %d %d %d
\n
"
,
glist_getcanvas
(
glist
),
x
,
glist_getcanvas
(
glist
),
x
,
xpos
-
BORDER
,
ypos
-
BORDER
,
xpos
+
x
->
w
.
width
+
2
*
BORDER
,
ypos
+
x
->
w
.
height
+
2
*
BORDER
);
...
...
@@ -310,8 +365,10 @@ static void envgen_getrect(t_gobj *z, t_glist *owner,
width
=
s
->
w
.
width
+
2
*
BORDER
;
height
=
s
->
w
.
height
+
2
*
BORDER
;
*
xp1
=
text_xpix
(
&
s
->
x_obj
,
owner
)
-
BORDER
;
*
yp1
=
text_ypix
(
&
s
->
x_obj
,
owner
)
-
BORDER
;
//*xp1 = text_xpix(&s->x_obj,owner)-BORDER;
//*yp1 = text_ypix(&s->x_obj,owner)-BORDER;
*
xp1
=
text_xpix
(
&
s
->
x_obj
,
owner
);
*
yp1
=
text_ypix
(
&
s
->
x_obj
,
owner
);
*
xp2
=
text_xpix
(
&
s
->
x_obj
,
owner
)
+
width
+
4
;
*
yp2
=
text_ypix
(
&
s
->
x_obj
,
owner
)
+
height
+
4
;
}
...
...
pd/nw/pdgui.js
View file @
699889af
...
...
@@ -2502,7 +2502,7 @@ function gui_mycanvas_coords(cid, tag, vis_width, vis_height, select_width, sele
function
gui_scalar_new
(
cid
,
tag
,
isselected
,
t1
,
t2
,
t3
,
t4
,
t5
,
t6
,
is_toplevel
)
{
// we should probably use
create
_gobj here, but we"re doing some initial
// we should probably use
gui
_gobj
_new
here, but we"re doing some initial
// scaling that normal gobjs don't need...
var
svg
=
get_item
(
cid
,
"
patchsvg
"
),
// id for the svg in the DOM
matrix
,
...
...
@@ -3148,6 +3148,28 @@ function add_popup(cid, popup) {
popup_menu
[
cid
]
=
popup
;
}
// envgen
function
gui_envgen_draw_bg
(
cid
,
tag
,
bg_color
,
w
,
h
,
points_array
)
{
var
g
=
get_gobj
(
cid
,
tag
),
bg
,
pline
;
bg
=
create_item
(
cid
,
"
rect
"
,
{
width
:
w
,
height
:
h
,
fill
:
bg_color
,
stroke
:
"
black
"
,
"
stroke-width
"
:
"
2
"
,
transform
:
"
translate(0.5, 0.5)
"
});
pline
=
create_item
(
cid
,
"
polyline
"
,
{
stroke
:
"
black
"
,
fill
:
"
none
"
,
transform
:
"
translate(1, 1)
"
,
points
:
points_array
.
join
(
"
"
)
});
g
.
appendChild
(
bg
);
g
.
appendChild
(
pline
);
}
exports
.
add_popup
=
add_popup
;
// Kludge to get popup coords to fit the browser's zoom level
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment