Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Aayush
purr-data
Commits
ec3ace4a
Commit
ec3ace4a
authored
Jul 21, 2015
by
Jonathan Wilkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix regression where autopatching would leave an empty box
parent
00d2036a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
19 deletions
+61
-19
pd/nw/pd_canvas.html
pd/nw/pd_canvas.html
+25
-5
pd/nw/pdgui.js
pd/nw/pdgui.js
+6
-5
pd/src/g_editor.c
pd/src/g_editor.c
+30
-9
No files found.
pd/nw/pd_canvas.html
View file @
ec3ace4a
...
...
@@ -199,9 +199,10 @@ var canvas_events = (function() {
// here. I want those newlines: although that isn't
// standard in Pd-Vanilla, Pd-l2ork uses and preserves
// them inside comments
var
fudi_msg
=
text_to_fudi
(
textbox
().
innerText
);
pdgui
.
pdsend
(
name
+
"
stringforobj
"
+
fudi_msg
);
pdgui
.
gui_post
(
"
formatted content is
"
+
fudi_msg
);
utils
.
create_obj
();
// var fudi_msg = text_to_fudi(textbox().innerText);
// pdgui.pdsend(name + " createobj " + fudi_msg);
// pdgui.gui_post("formatted content is " + fudi_msg);
events
.
mousedown
(
evt
);
canvas_events
.
normal
();
}
...
...
@@ -245,6 +246,18 @@ var canvas_events = (function() {
//evt.preventDefault();
//return false;
}
},
utils
=
{
create_obj
:
function
()
{
var
fudi_msg
=
text_to_fudi
(
textbox
().
innerText
);
pdgui
.
pdsend
(
name
+
"
createobj
"
+
fudi_msg
);
pdgui
.
gui_post
(
"
formatted content is
"
+
fudi_msg
);
},
set_obj
:
function
()
{
var
fudi_msg
=
text_to_fudi
(
textbox
().
innerText
);
pdgui
.
pdsend
(
name
+
"
setobj
"
+
fudi_msg
);
pdgui
.
gui_post
(
"
formatted content is
"
+
fudi_msg
);
}
}
;
...
...
@@ -346,6 +359,9 @@ var canvas_events = (function() {
},
get_state
:
function
()
{
return
state
;
},
set_obj
:
function
()
{
utils
.
set_obj
();
}
}
}());
...
...
@@ -775,8 +791,12 @@ function nw_create_patch_window_menus (name) {
putMenu
.
append
(
new
nw
.
MenuItem
({
label
:
l
(
'
menu.object
'
),
click
:
function
()
{
pdgui
.
pdsend
(
name
+
"
dirty 1
"
);
pdgui
.
pdsend
(
name
+
"
obj 0
"
);
var
state
=
canvas_events
.
get_state
();
if
(
state
===
'
text
'
||
state
===
'
floating_text
'
)
{
canvas_events
.
set_obj
();
}
pdgui
.
pdsend
(
name
+
"
dirty 1
"
);
pdgui
.
pdsend
(
name
+
"
obj 0
"
);
},
key
:
'
1
'
,
modifiers
:
"
ctrl
"
,
...
...
pd/nw/pdgui.js
View file @
ec3ace4a
...
...
@@ -3178,7 +3178,7 @@ console.log("obj_tag is " + obj_tag);
y
:
y
,
id
:
obj_tag
+
i
,
visibility
:
seqno
===
i
?
'
visible
'
:
'
hidden
'
,
//
preserveAspectRatio: "xMinYMin meet"
preserveAspectRatio
:
"
xMinYMin meet
"
});
item
.
setAttributeNS
(
'
http://www.w3.org/1999/xlink
'
,
'
href
'
,
'
data:image/
'
+
drawimage_data
[
obj
][
i
].
type
+
'
;base64,
'
+
...
...
@@ -3201,10 +3201,11 @@ function gui_drawimage_index(cid, obj, data, index) {
last_image
,
image
=
image_container
.
childNodes
[
index
],
last_image
=
image_container
.
querySelectorAll
(
'
[visibility="visible"]
'
);
for
(
i
=
0
;
i
<
last_image
.
length
;
i
++
)
{
configure_item
(
last_image
[
i
],
{
visibility
:
'
hidden
'
});
}
configure_item
(
image
,
{
visibility
:
'
visible
'
});
for
(
i
=
0
;
i
<
last_image
.
length
;
i
++
)
{
configure_item
(
last_image
[
i
],
{
visibility
:
'
hidden
'
});
}
configure_item
(
image
,
{
visibility
:
'
visible
'
});
}
function
add_popup
(
cid
,
popup
)
{
...
...
pd/src/g_editor.c
View file @
ec3ace4a
...
...
@@ -7646,10 +7646,27 @@ static void canvas_tip(t_canvas *x, t_symbol *s, int argc, t_atom *argv)
}
}
static
void
canvas_stringforobj
(
t_
canvas
*
x
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
static
void
canvas_stringforobj
(
t_
rtext
*
rtext
,
int
argc
,
t_atom
*
argv
)
{
int
length
;
char
*
buf
;
t_binbuf
*
b
=
binbuf_new
();
binbuf_restore
(
b
,
argc
,
argv
);
binbuf_gettext
(
b
,
&
buf
,
&
length
);
/* We hand off "buf" to rtext as
its x_buf member, and "length"
as x_bufsize. Pd will handle
deallocation of those members
automatically, so we don't need
to free the "buf" here. */
rtext_settext
(
rtext
,
buf
,
length
);
binbuf_free
(
b
);
}
static
void
canvas_createobj
(
t_canvas
*
x
,
t_symbol
*
s
,
int
argc
,
t_atom
*
argv
)
{
// int length;
// char *buf;
t_gobj
*
y
;
t_rtext
*
rtext
;
if
(
!
x
->
gl_editor
)
return
;
...
...
@@ -7657,14 +7674,16 @@ static void canvas_stringforobj(t_canvas *x, t_symbol *s, int argc, t_atom *argv
{
if
(
glist_isselected
(
x
,
y
)
&&
(
rtext
=
glist_findrtext
(
x
,
(
t_text
*
)
y
)))
{
t_binbuf
*
b
=
binbuf_new
();
binbuf_restore
(
b
,
argc
,
argv
);
binbuf_gettext
(
b
,
&
buf
,
&
length
);
rtext_settext
(
rtext
,
buf
,
length
);
binbuf_free
(
b
);
canvas_stringforobj
(
rtext
,
argc
,
argv
);
// t_binbuf *b = binbuf_new();
// binbuf_restore(b, argc, argv);
// binbuf_gettext(b, &buf, &length);
// rtext_settext(rtext, buf, length);
// binbuf_free(b);
// Set the dirty flag since we've changed the rtext content...
x
->
gl_editor
->
e_textdirty
=
1
;
glist_deselect
(
x
,
y
);
if
(
s
==
gensym
(
"createobj"
))
glist_deselect
(
x
,
y
);
// instantiate
break
;
}
}
...
...
@@ -7691,8 +7710,10 @@ void g_editor_setup(void)
A_GIMME
,
A_NULL
);
class_addmethod
(
canvas_class
,
(
t_method
)
canvas_tip
,
gensym
(
"echo"
),
A_GIMME
,
A_NULL
);
class_addmethod
(
canvas_class
,
(
t_method
)
canvas_stringforobj
,
gensym
(
"stringforobj"
),
A_GIMME
,
A_NULL
);
class_addmethod
(
canvas_class
,
(
t_method
)
canvas_createobj
,
gensym
(
"setobj"
),
A_GIMME
,
A_NULL
);
class_addmethod
(
canvas_class
,
(
t_method
)
canvas_createobj
,
gensym
(
"createobj"
),
A_GIMME
,
A_NULL
);
/* ------------------------ menu actions ---------------------------- */
class_addmethod
(
canvas_class
,
(
t_method
)
canvas_menuclose
,
gensym
(
"menuclose"
),
A_DEFFLOAT
,
0
);
...
...
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