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
nerrons
purr-data
Commits
c870d442
Commit
c870d442
authored
Dec 16, 2015
by
Jonathan Wilkes
Browse files
first step in making iemgui labels draggable
parent
da20034f
Changes
3
Hide whitespace changes
Inline
Side-by-side
pd/nw/pdgui.js
View file @
c870d442
...
...
@@ -2253,6 +2253,34 @@ function gui_iemgui_label_font(cid, tag, fontname, fontweight, fontsize) {
});
}
// Show or hide little handle for dragging around iemgui labels
function
gui_iemgui_label_show_drag_handle
(
cid
,
tag
,
state
,
x
,
y
)
{
var
gobj
=
get_gobj
(
cid
,
tag
),
rect
;
if
(
state
!==
0
)
{
post
(
"
did thisbranch with cid as
"
+
cid
);
rect
=
create_item
(
cid
,
"
rect
"
,
{
x
:
x
,
y
:
y
,
width
:
10
,
height
:
10
,
id
:
"
iemgui_label_handle
"
});
gobj
.
appendChild
(
rect
);
}
else
{
post
(
"
did delete branch with cid as
"
+
cid
);
rect
=
get_item
(
cid
,
"
iemgui_label_handle
"
);
rect
.
parentNode
.
removeChild
(
rect
);
}
}
// A workaround for making iemgui labels draggable. Obnoxiously long name
// to remind me how much of a pain it is to be handling stuff like this
// going between the GUI and Pd (as opposed to doing it completely in the GUI).
function
gui_add_iemgui_label_resize_listener
(
cid
,
tag
)
{
post
(
"
received a message to add a binding for an iemgui handle...
"
);
}
function
gui_create_mycanvas
(
cid
,
tag
,
color
,
x1
,
y1
,
x2_vis
,
y2_vis
,
x2
,
y2
)
{
var
rect_vis
,
rect
,
g
;
rect_vis
=
create_item
(
cid
,
"
rect
"
,
{
...
...
pd/src/g_all_guis.c
View file @
c870d442
...
...
@@ -700,18 +700,21 @@ float maxf(float a, float b) {return a>b?a:b;}
// [bng], [tgl], [hradio], [vradio], [hsl], [vsl], [cnv], [nbx], [vu]
// for both scale & label, plus canvas' scale & move.
void
scalehandle_bind
(
t_scalehandle
*
h
)
{
sys_vgui
(
"bind %s <Button> {pd [concat %s _click 1 %%x %%y
\\
;]}
\n
"
,
h
->
h_pathname
,
h
->
h_bindsym
->
s_name
);
sys_vgui
(
"bind %s <ButtonRelease> {pd [concat %s _click 0 0 0
\\
;]}
\n
"
,
h
->
h_pathname
,
h
->
h_bindsym
->
s_name
);
sys_vgui
(
"bind %s <Motion> {pd [concat %s _motion %%x %%y
\\
;]}
\n
"
,
h
->
h_pathname
,
h
->
h_bindsym
->
s_name
);
//sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n",
// h->h_pathname, h->h_bindsym->s_name);
//sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n",
// h->h_pathname, h->h_bindsym->s_name);
//sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n",
// h->h_pathname, h->h_bindsym->s_name);
gui_vmess
(
"gui_add_iemgui_label_resize_listener"
,
"xs"
,
h
->
h_glist
,
h
->
h_pathname
);
}
// in 18 cases only, because canvas does not fit the pattern below.
// canvas has no label handle and has a motion handle
// but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally)
void
scalehandle_draw_select
(
t_scalehandle
*
h
,
int
px
,
int
py
)
{
char
tagbuf
[
MAXPDSTRING
];
char
tags
[
128
];
// BNG may need up to 100 chars in 64-bit mode, for example
t_object
*
x
=
h
->
h_master
;
t_canvas
*
canvas
=
glist_getcanvas
(
h
->
h_glist
);
...
...
@@ -758,6 +761,10 @@ void scalehandle_draw_select(t_scalehandle *h, int px, int py) {
"-window %s -tags {%s}
\n
"
,
canvas
,
xpos
+
px
-
sx
,
ypos
+
py
-
sy
,
sx
,
sy
,
h
->
h_pathname
,
tags
);
sprintf
(
tagbuf
,
"x%lx"
,
(
long
unsigned
int
)
x
);
gui_vmess
(
"gui_iemgui_label_show_drag_handle"
,
"xsiii"
,
canvas
,
tagbuf
,
1
,
px
-
sx
,
py
-
sy
);
scalehandle_bind
(
h
);
h
->
h_vis
=
1
;
/* not yet (this is not supported by the current implementation) */
...
...
@@ -786,7 +793,9 @@ void scalehandle_draw_select2(t_iemgui *x) {
//iemgui_getrect_draw(x, &x1, &y1, &x2, &y2);
sx
=
x2
-
x1
;
sy
=
y2
-
y1
;
}
scalehandle_draw_select
(
x
->
x_handle
,
sx
-
1
,
sy
-
1
);
/* we're not drawing the scalehandle for the actual iemgui-- just
the one for the label. */
// scalehandle_draw_select(x->x_handle,sx-1,sy-1);
if
(
x
->
x_lab
!=
s_empty
)
scalehandle_draw_select
(
x
->
x_lhandle
,
x
->
x_ldx
,
x
->
x_ldy
);
}
...
...
@@ -797,6 +806,8 @@ void scalehandle_draw_erase(t_scalehandle *h) {
sys_vgui
(
"destroy %s
\n
"
,
h
->
h_pathname
);
sys_vgui
(
".x%lx.c delete %lx%s
\n
"
,
canvas
,
h
->
h_master
,
h
->
h_scale
?
"SCALE"
:
pd_class
((
t_pd
*
)
h
->
h_master
)
==
canvas_class
?
"MOVE"
:
"LABELH"
);
gui_vmess
(
"gui_iemgui_label_show_drag_handle"
,
"xsiii"
,
h
->
h_glist
,
"dummy_tag"
,
0
,
0
,
0
);
h
->
h_vis
=
0
;
}
...
...
@@ -809,7 +820,7 @@ void scalehandle_draw_erase2(t_iemgui *x) {
void
scalehandle_draw
(
t_iemgui
*
x
)
{
if
(
x
->
x_glist
==
glist_getcanvas
(
x
->
x_glist
))
{
if
(
x
->
x_selected
==
x
->
x_glist
)
scalehandle_draw_select2
(
x
);
if
(
x
->
x_selected
==
x
->
x_glist
)
scalehandle_draw_select2
(
x
);
else
scalehandle_draw_erase2
(
x
);
}
}
...
...
pd/src/g_all_guis.h
View file @
c870d442
...
...
@@ -184,7 +184,7 @@ typedef struct _my_numbox
double
x_k
;
int
x_lin0_log1
;
// bool
char
x_buf
[
IEMGUI_MAX_NUM_LEN
];
int
x_numwidth
;
// unsigned
int
x_numwidth
;
// unsigned
(width in pixels)
int
x_scalewidth
;
/* temporary value for scalehandle */
int
x_scaleheight
;
/* temporary value for scalehandle */
int
x_tmpfontsize
;
/* temporary value for scalehandle */
...
...
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