Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wynn
purr-data
Commits
71b4349e
Commit
71b4349e
authored
May 02, 2015
by
user
Browse files
got a functional gatom properties dialog
parent
9192134c
Changes
1
Hide whitespace changes
Inline
Side-by-side
pd/nw/dialog_gatom.html
View file @
71b4349e
...
...
@@ -10,28 +10,28 @@
<legend
data-i18n=
"gatom.prop.gatom"
></legend>
<table
class=
"pairs"
>
<tr
class=
"width prop
hidden
"
>
<tr
class=
"width prop"
>
<td>
<label
data-i18n=
"[title]iem.prop.width_tt"
>
<span
data-i18n=
"iem.prop.width"
></span>
</label>
</td>
<td
data-i18n=
"[title]iem.prop.width_tt"
>
<input
type=
"text"
name=
"width"
>
<input
type=
"text"
id=
"width"
name=
"width"
>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr
class=
"draglo prop pair
hidden
"
>
<tr
class=
"draglo prop pair"
>
<td>
<label
data-i18n=
"[title]iem.prop.minimum_tt"
>
<span
data-i18n=
"iem.prop.minimum"
></span>
</label>
</td>
<td
data-i18n=
"[title]iem.prop.minimum_tt"
>
<input
type=
"text"
name=
"minimum-range"
>
<input
type=
"text"
id=
"minimum-range"
name=
"minimum-range"
>
</td>
<td>
<label
data-i18n=
"[title]iem.prop.maximum_tt"
>
...
...
@@ -39,7 +39,7 @@
</label>
</td>
<td
data-i18n=
"[title]iem.prop.maximum_tt"
>
<input
type=
"text"
name=
"maximum-range"
>
<input
type=
"text"
id=
"maximum-range"
name=
"maximum-range"
>
</td>
</tr>
<tr>
...
...
@@ -49,7 +49,7 @@
</label>
</td>
<td
colspan=
"3"
>
<input
type=
"text"
name=
"send-symbol"
>
<input
type=
"text"
id=
"send-symbol"
name=
"send-symbol"
>
</td>
</tr>
<tr>
...
...
@@ -59,7 +59,7 @@
</label>
</td>
<td
colspan=
"3"
>
<input
type=
"text"
name=
"receive-symbol"
>
<input
type=
"text"
id=
"receive-symbol"
name=
"receive-symbol"
>
</td>
</tr>
<tr>
...
...
@@ -69,7 +69,7 @@
</label>
</td>
<td
colspan=
"3"
>
<input
type=
"text"
name=
"label"
>
<input
type=
"text"
id=
"label"
name=
"label"
>
</td>
</tr>
<tr>
...
...
@@ -86,8 +86,7 @@
type=
"radio"
id=
"labelpos_left"
value=
"2"
name=
"labelpos"
onchange=
"labelpos_change(this);"
>
name=
"labelpos"
>
<span
data-i18n=
"gatom.prop.label_top"
></span>
<br/>
...
...
@@ -96,16 +95,14 @@
type=
"radio"
id=
"labelpos_left"
value=
"0"
name=
"labelpos"
onchange=
"labelpos_change(this);"
>
name=
"labelpos"
>
<span
data-i18n=
"gatom.prop.label_left"
></span>
<input
class=
"array-style"
type=
"radio"
id=
"labelpos_right"
value=
"1"
name=
"labelpos"
onchange=
"labelpos_change(this);"
>
name=
"labelpos"
>
<span
data-i18n=
"gatom.prop.label_right"
></span>
<br/>
...
...
@@ -114,8 +111,7 @@
type=
"radio"
id=
"labelpos_bottom"
value=
"3"
name=
"labelpos"
onchange=
"labelpos_change(this);"
>
name=
"labelpos"
>
<span
data-i18n=
"gatom.prop.label_bottom"
></span>
</label>
...
...
@@ -167,169 +163,54 @@
return
arg
.
split
(
'
'
).
join
(
fake_space
);
}
function
strip_problem_chars
(
arg
)
{
var
problem_chars
=
[
'
;
'
,
'
,
'
,
'
{
'
,
'
}
'
,
'
\\
'
];
var
ret
=
arg
;
for
(
var
i
=
0
;
i
<
problem_chars
.
length
;
i
++
)
{
ret
=
ret
.
split
(
'
;
'
).
join
(
''
);
}
return
ret
;
function
strip_problem_chars
(
arg
)
{
var
problem_chars
=
[
'
;
'
,
'
,
'
,
'
{
'
,
'
}
'
,
'
\\
'
];
var
ret
=
arg
;
for
(
var
i
=
0
;
i
<
problem_chars
.
length
;
i
++
)
{
ret
=
ret
.
split
(
'
;
'
).
join
(
''
);
}
return
ret
;
}
function
apply
()
{
pdgui
.
gui_post
(
"
we're applying shits!
"
);
/* Not sure what these are...
iemgui_clip_dim $id
iemgui_clip_num $id
iemgui_sched_rng $id
iemgui_verify_rng $id
iemgui_sched_rng $id
iemgui_clip_fontsize $id
*/
var
send_symbol
=
document
.
getElementsByName
(
'
send-symbol
'
)[
0
].
value
;
var
receive_symbol
=
document
.
getElementsByName
(
'
receive-symbol
'
)[
0
].
value
;
var
label
=
document
.
getElementsByName
(
'
label
'
)[
0
].
value
;
if
(
send_symbol
===
null
||
send_symbol
===
''
)
{
send_symbol
=
'
empty
'
;
}
if
(
receive_symbol
===
null
||
receive_symbol
===
''
)
{
receive_symbol
=
'
empty
'
;
}
if
(
label
===
null
||
label
===
''
)
{
label
=
'
empty
'
;
}
console
.
log
(
"
send_symbol is
"
+
send_symbol
);
if
(
send_symbol
.
charAt
(
0
)
===
'
$
'
)
{
send_symbol
=
'
#
'
+
send_symbol
.
slice
(
1
);
}
if
(
receive_symbol
.
charAt
(
0
)
===
'
$
'
)
{
receive_symbol
=
'
#
'
+
receive_symbol
.
slice
(
1
);
}
if
(
label
.
charAt
(
0
)
===
'
$
'
)
{
label
=
'
#
'
+
label
.
slice
(
1
);
}
send_symbol
=
substitute_space
(
send_symbol
);
receive_symbol
=
substitute_space
(
receive_symbol
);
label
=
substitute_space
(
label
);
send_symbol
=
strip_problem_chars
(
send_symbol
);
receive_symbol
=
strip_problem_chars
(
receive_symbol
);
label
=
strip_problem_chars
(
label
);
var
label_x_offset
=
document
.
getElementsByName
(
'
x-offset
'
)[
0
].
value
;
var
label_y_offset
=
document
.
getElementsByName
(
'
y-offset
'
)[
0
].
value
;
// make sure the offset boxes have a value
if
(
label_x_offset
===
null
)
{
label_x_offset
=
0
;
}
if
(
label_y_offset
===
null
)
{
label_y_offset
=
0
;
}
var
height
,
width
;
var
size
=
document
.
getElementsByName
(
'
size
'
)[
0
].
value
;
if
(
size
===
''
)
{
var
size
=
document
.
getElementsByName
(
'
selection-size
'
)[
0
].
value
;
}
if
(
size
!==
''
)
{
width
=
size
;
height
=
size
;
}
else
{
width
=
document
.
getElementsByName
(
'
width
'
)[
0
].
value
;
height
=
document
.
getElementsByName
(
'
height
'
)[
0
].
value
;
}
var
slot3
=
document
.
getElementsByName
(
'
minimum-range
'
)[
0
].
value
;
var
slot4
=
document
.
getElementsByName
(
'
maximum-range
'
)[
0
].
value
;
if
(
slot3
===
''
)
{
slot3
=
document
.
getElementsByName
(
'
flash-interrupt
'
)[
0
].
value
;
slot4
=
document
.
getElementsByName
(
'
flash-hold
'
)[
0
].
value
;
}
if
(
slot3
===
''
)
{
slot3
=
document
.
getElementsByName
(
'
visible-width
'
)[
0
].
value
;
slot4
=
document
.
getElementsByName
(
'
visible-height
'
)[
0
].
value
;
}
if
(
slot3
===
''
)
{
// toggle
slot3
=
document
.
getElementsByName
(
'
nonzero-value
'
)[
0
].
value
;
if
(
slot3
===
''
)
{
slot3
=
0
;
function
gatom_escape
(
str
)
{
var
arr
,
i
,
ret
;
if
(
str
.
length
===
0
)
{
ret
=
'
-
'
;
}
else
if
(
str
.
slice
(
0
,
1
)
===
'
-
'
)
{
ret
=
'
-
'
+
str
;
}
else
{
arr
=
str
.
split
(
''
);
for
(
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
arr
[
i
]
===
'
$
'
)
{
arr
[
i
]
=
'
#
'
;
}
slot4
=
0
;
}
var
slot5
=
+
document
.
getElementsByName
(
'
log-scaling
'
)[
0
].
checked
;
// Hack to accomodate the vu-scale property, which exists in the same
// slot as this one
var
log_scaling_spanner
=
document
.
getElementsByClassName
(
'
log-scaling
'
)[
0
];
var
log_display
=
log_scaling_spanner
.
style
.
getPropertyValue
(
'
display
'
);
if
(
log_display
===
null
)
{
slot5
=
+
document
.
getElementsByName
(
'
vu-scale
'
)[
0
].
checked
;
pdgui
.
gui_post
(
'
slot five is
'
+
slot5
);
}
pdgui
.
gui_post
(
'
slot five is
'
+
slot5
);
var
init
=
+
document
.
getElementsByName
(
'
init
'
)[
0
].
checked
;
if
(
init
===
''
)
{
init
=
0
;
}
ret
=
arr
.
join
(
''
);
}
return
strip_problem_chars
(
ret
)
;
}
var
slot7
=
document
.
getElementsByName
(
'
log-height
'
)[
0
].
value
;
if
(
slot7
===
''
)
{
slot7
=
document
.
getElementsByName
(
'
number
'
)[
0
].
value
;
}
if
(
slot7
===
''
)
{
slot7
=
0
;
}
function
apply
()
{
pdgui
.
gui_post
(
"
we're applying shits!
"
);
var
font_style
=
document
.
getElementsByName
(
'
font-style
'
)[
0
].
value
;
if
(
font_style
!==
null
)
{
font_style
=
0
;
}
var
font_size
=
document
.
getElementsByName
(
'
font-size
'
)[
0
].
value
;
if
(
font_size
===
''
)
{
font_size
=
0
;
}
var
foreground_color
=
parseInt
(
document
.
getElementsByName
(
'
foreground-color
'
)[
0
].
value
.
slice
(
1
),
16
);
var
background_color
=
parseInt
(
document
.
getElementsByName
(
'
background-color
'
)[
0
].
value
.
slice
(
1
),
16
);
var
label_color
=
parseInt
(
document
.
getElementsByName
(
'
label-color
'
)[
0
].
value
.
slice
(
1
),
16
);
var
slot18
=
+
document
.
getElementsByName
(
'
steady-on-click
'
)[
0
].
checked
;
pdgui
.
pdsend
([
pd_object_callback
,
'
dialog
'
,
width
,
height
,
slot3
,
// bng: flash-interrupt
// slider: min-range
// toggle: nonzero-value
// my_canvas: visible_width
slot4
,
// bng: flash-hold
// slider: max-range
// my_canvas: visible_height
slot5
,
// slider: lin/log thingy
// nbx: lin/log
// vu: vu-scale
init
,
slot7
,
// log-height or vradio/hradio number
send_symbol
,
receive_symbol
,
label
,
label_x_offset
,
label_y_offset
,
font_style
,
font_size
,
background_color
,
foreground_color
,
label_color
,
slot18
,
// steady on click
0
].
join
(
'
'
));
/*
pd [concat $id dialog \
$::dialog($vid:wdt) $::dialog($vid:hgt) \
$::dialog($vid:min_rng) $::dialog($vid:max_rng) \
$::dialog($vid:lin0_log1) $::dialog($vid:loadbang) \
$::dialog($vid:num) \
$hhhsnd $hhhrcv $hhhgui_nam \
$::dialog($vid:gn_dx) $::dialog($vid:gn_dy) \
$::dialog($vid:gn_f) $::dialog($vid:gn_fs) \
$::dialog($vid:bcol) $::dialog($vid:fcol) \
$::dialog($vid:lcol) \
$::dialog($vid:steady) $::dialog($vid:hide) \;]
set cmd [concat $id param \
$::dialog($vid:width) $::dialog($vid:lo) $::dialog($vid:hi) \
[gatom_escape $::dialog($vid:label)] $::dialog($vid:wherelabel) \
[gatom_escape $::dialog($vid:symfrom)] \
[gatom_escape $::dialog($vid:symto)] \;]
*/
}
pdgui
.
pdsend
([
pd_object_callback
,
'
param
'
,
+
document
.
getElementById
(
'
width
'
).
value
,
+
document
.
getElementById
(
'
minimum-range
'
).
value
,
+
document
.
getElementById
(
'
maximum-range
'
).
value
,
gatom_escape
(
document
.
getElementById
(
'
label
'
).
value
),
document
.
querySelector
(
'
input[name="labelpos"]:checked
'
).
value
,
gatom_escape
(
document
.
getElementById
(
'
receive-symbol
'
).
value
),
gatom_escape
(
document
.
getElementById
(
'
send-symbol
'
).
value
)
].
join
(
'
'
));
}
function
cancel
()
{
pdgui
.
gui_post
(
"
closing the window at this point
"
);
...
...
@@ -379,52 +260,31 @@ function translate_form() {
}
}
function
populate_form
(
attr_array
)
{
// First, let's put the translated text for the form labels:
// tr_text('heading.size');
// tr_text('heading.messages');
// tr_text('heading.label');
// tr_text('heading.colors');
// tr_prop('width');
// tr_tooltip('width');
function
get_attr
(
name
,
attrs
)
{
return
attrs
[
attrs
.
indexOf
(
name
)
+
1
];
}
// var headings = ["size", "messages", "label", "colors"];
// for (var i = 0; i
<
headings
.
length
;
i
++
)
{
// var str = "iem.prop.heading." + headings[i];
// var heading = document.getElementById(str);
// heading.textContent = l(str);
// }
function
get_elem
(
name
)
{
return
document
.
getElementById
(
name
);
}
for
(
var
i
=
0
;
i
<
attr_array
.
length
;
i
+=
2
)
{
// Unhide the span with the class with the same name as the id
var
prop_group
=
document
.
getElementsByClassName
(
attr_array
[
i
])[
0
];
if
(
prop_group
!==
undefined
)
{
console
.
log
(
"
the thing here is
"
+
attr_array
[
i
]);
prop_group
.
classList
.
remove
(
'
hidden
'
);
}
else
{
pdgui
.
gui_post
(
"
Error: couldn't find iemgui prop group for
"
+
attr_array
[
i
]);
}
// iemguis use the string 'empty' for null because of
// the limitations of Pd's state-saving API. So we have
// to filter that one out
if
(
attr_array
[
i
+
1
]
!==
'
empty
'
)
{
var
elem
=
document
.
getElementsByName
(
attr_array
[
i
]);
if
(
elem
.
length
>
0
)
{
if
(
attr_array
[
i
].
slice
(
-
5
)
===
'
color
'
)
{
var
hex_string
=
Number
(
attr_array
[
i
+
1
]).
toString
(
16
);
var
color_string
=
"
#
"
+
(
hex_string
===
'
0
'
?
'
000000
'
:
hex_string
);
pdgui
.
gui_post
(
"
color is
"
+
color_string
);
elem
[
0
].
value
=
color_string
;
}
else
if
(
elem
[
0
].
type
===
'
checkbox
'
)
{
// The attr here is a string, so we need to
// force it to number, hence the "+" below
elem
[
0
].
checked
=
+
attr_array
[
i
+
1
];
}
else
{
elem
[
0
].
value
=
attr_array
[
i
+
1
];
}
}
function
populate_form
(
attr_array
)
{
var
label
,
snd
,
rcv
,
labelpos
,
i
,
radios
;
get_elem
(
'
width
'
).
value
=
get_attr
(
'
width
'
,
attr_array
);
get_elem
(
'
minimum-range
'
).
value
=
get_attr
(
'
draglo
'
,
attr_array
);
get_elem
(
'
maximum-range
'
).
value
=
get_attr
(
'
draghi
'
,
attr_array
);
label
=
get_attr
(
'
label
'
,
attr_array
);
get_elem
(
'
label
'
).
value
=
label
===
'
-
'
?
''
:
label
;
snd
=
get_attr
(
'
send-symbol
'
,
attr_array
);
get_elem
(
'
send-symbol
'
).
value
=
snd
===
'
-
'
?
''
:
snd
;
rcv
=
get_attr
(
'
receive-symbol
'
,
attr_array
);
get_elem
(
'
receive-symbol
'
).
value
=
rcv
===
'
-
'
?
''
:
rcv
;
labelpos
=
get_attr
(
'
labelpos
'
,
attr_array
);
radios
=
document
.
getElementsByName
(
'
labelpos
'
);
for
(
i
=
0
;
i
<
radios
.
length
;
i
++
)
{
if
(
+
radios
[
i
].
value
===
labelpos
)
{
radios
[
i
].
checked
=
true
;
}
}
}
...
...
Write
Preview
Supports
Markdown
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