Commit 0e6d581a authored by user's avatar user
Browse files

code cleanup, plus bugfix for updating iemgui border size after dialog changes

parent fa6e3e3d
......@@ -286,16 +286,11 @@
cancel();
}
// function toggler(evt) {
// evt.value = evt.checked ? 1 : 0;
// }
function flag_change(elem) {
var attr, arrays_select, name, value, flag;
arrays_select = document.getElementById('arrays_select');
attr = pd_garray_attrs[arrays_select.value];
name = elem.name;
// pdgui.gui_post("name is " + name);
// get value from radio group, checked from checkboxes
if (name === 'array_style') {
value = document.querySelector('input[name="array_style"]:checked').value;
......@@ -304,7 +299,7 @@
// '+' for casting boolean to number
value = +elem.checked;
}
// pdgui.gui_post("value is " + value);
//pdgui.gui_post("value is " + value);
flag = attr[attr.indexOf('array_flags') + 1];
pdgui.gui_post("flag before is " + flag);
switch (name) {
......@@ -331,11 +326,9 @@
arrays_select = document.getElementById('arrays_select');
attr = pd_garray_attrs[arrays_select.value];
name = elem.name;
// pdgui.gui_post("name is " + name);
// get value from radio group, checked from checkboxes
// '+' for casting boolean to number
value = +elem.checked;
// pdgui.gui_post("value is " + value);
attr[attr.indexOf(name) + 1] = value;
pdgui.gui_post("array is " + attr);
}
......@@ -441,7 +434,6 @@
update_gop_form(no_gop_opts, state === false);
}
function substitute_space(arg) {
var fake_space = String.fromCharCode(11);
return arg.split(' ').join(fake_space);
......@@ -466,14 +458,14 @@
return attrs[attrs.indexOf(name) + 1];
}
function apply() {
var i, attrs, gop, hide_name;
pdgui.gui_post("we're applying shits!");
// If this is a dialog to create a new array, we
// skip the canvas dialog callback
if (pd_garray_attrs.length < 1 || pd_garray_attrs[0][0] !== 'array_gfxstub')
if (pd_garray_attrs.length < 1 ||
pd_garray_attrs[0][0] !== 'array_gfxstub')
{
// Note: the "+" casts Boolean to Number
gop = +document.getElementsByName('gop')[0].checked;
......@@ -517,33 +509,16 @@
].join(' '));
}
/*
pd [concat $id donecanvasdialog \
$::dialog($vid:xscale) \
$::dialog($vid:yscale) \
[expr $::dialog($vid:graphme)+2*$::dialog($vid:hidetext)] \
$::dialog($vid:x1) \
$::dialog($vid:y1) \
$::dialog($vid:x2) \
$::dialog($vid:y2) \
$::dialog($vid:xpix) \
$::dialog($vid:ypix) \
$::dialog($vid:xmargin) \
$::dialog($vid:ymargin) \
\;]
}
*/
}
function cancel() {
var i, attrs, gfxstub;
pdgui.gui_post("closing the window at this point");
// window.close(true);
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
for (i = 0; i < pd_garray_attrs.length; i++) {
attrs = pd_garray_attrs[i];
gfxstub = attrs[attrs.indexOf("array_gfxstub") + 1];
pdgui.gui_post("guistub is " + gfxstub);
pdgui.pdsend(gfxstub + " cancel");
}
}
......@@ -588,8 +563,8 @@ pdgui.gui_post("guistub is " + gfxstub);
pdgui.gui_post(attr_arrays[i] + ": " + attr_arrays[i+1]);
}
add_events(gfxstub);
// not sure that we need this for properties windows
// pdgui.canvas_map(gfxstub);
// not sure that we need this for properties windows...
// pdgui.canvas_map(gfxstub);
translate_form();
if (attr_arrays[0] === 'array_gfxstub') {
canvas_fieldsets = document.getElementsByClassName('canvas');
......@@ -607,7 +582,6 @@ pdgui.gui_post("guistub is " + gfxstub);
// labels and form elements. That makes it more efficient and
// snappier, at least on older machines.
document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
// document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
}
function tr_text(id) {
......@@ -630,23 +604,7 @@ 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');
// 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);
// }
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];
......@@ -654,23 +612,24 @@ function populate_form(attr_array) {
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]);
pdgui.gui_post("Error: couldn't find iemgui prop group for " +
attr_array[i]);
}
if (attr_array[i] === 'display-flags') {
// protip: '!!' forces Boolean, '+' forces Number type
var flag = +attr_array[i+1];
document.getElementsByName('gop')[0].checked = !!flag;
document.getElementsByName('hide-name')[0].checked = !!(flag & 2);
// Set the gop-related parts of the form to be enabled/disabled based on state
// Set the gop-related parts of the form to be
// enabled/disabled based on state
set_gop(!!flag);
}
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);
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') {
......@@ -686,17 +645,14 @@ function populate_form(attr_array) {
}
function add_events(name) {
// let's handle some events for this window...
// closing the Window
nw.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
// pdgui.pdsend(name + " menuclose 0");
// cancel();
//pdgui.pdsend(name + " menuclose 0");
//cancel();
pdgui.remove_dialogwin(pd_object_callback);
this.close(true);
});
}
</script>
......
......@@ -93,25 +93,25 @@
</div>
<script>
'use strict';
var nw = require('nw.gui');
var pdgui = require('./pdgui.js');
'use strict';
var nw = require('nw.gui');
var pdgui = require('./pdgui.js');
// For translations
var l = pdgui.get_local_string;
// For translations
var l = pdgui.get_local_string;
console.log("my working dire is " + pdgui.get_pwd());
console.log("my working dire is " + pdgui.get_pwd());
pdgui.skin.apply(this);
pdgui.skin.apply(this);
var pd_object_callback;
var current_size;
var canvas;
var pd_object_callback;
var current_size;
var canvas;
function ok() {
apply();
cancel();
}
function ok() {
apply();
cancel();
}
function change_size() {
pdgui.gui_post("changing the size");
......@@ -119,16 +119,7 @@ function change_size() {
}
function apply() {
pdgui.gui_post("we're applying shits!");
/*
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.gui_post("we're applying font size changes!");
pdgui.pdsend([canvas, 'font',
+document.querySelector('input[name="font_size"]:checked').value,
current_size,
......@@ -137,31 +128,30 @@ function apply() {
].join(' '));
}
function cancel() {
pdgui.gui_post("closing the window at this point");
// window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
}
function cancel() {
pdgui.gui_post("closing the window at this point");
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
}
// This gets called from the nw_create_window function in index.html
// It provides us with our window id from the C side. Once we have it
// we can create the menu and register event callbacks
function register_canvas_id(gfxstub, attrs) {
pd_object_callback = gfxstub;
console.log('attrs are ' + attrs.toString());
add_events(gfxstub);
// not sure that we need this for properties windows
// pdgui.canvas_map(gfxstub);
translate_form();
populate_form(attrs);
// We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and
// snappier, at least on older machines.
document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
// document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
}
// This gets called from the nw_create_window function in index.html
// It provides us with our window id from the C side. Once we have it
// we can create the menu and register event callbacks
function register_canvas_id(gfxstub, attrs) {
pd_object_callback = gfxstub;
console.log('attrs are ' + attrs.toString());
add_events(gfxstub);
// not sure that we need this for properties windows
//pdgui.canvas_map(gfxstub);
translate_form();
populate_form(attrs);
// We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and
// snappier, at least on older machines.
document.getElementsByClassName('container')[0]
.style.setProperty('display', 'inline');
}
// Stop-gap translator
function translate_form() {
......@@ -192,19 +182,15 @@ function populate_form(attrs) {
}
function add_events(name) {
// let's handle some events for this window...
// closing the Window
nw.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
// pdgui.pdsend(name + " menuclose 0");
// cancel();
//pdgui.pdsend(name + " menuclose 0");
//cancel();
pdgui.remove_dialogwin(pd_object_callback);
this.close(true);
});
}
</script>
</body>
</html>
......@@ -136,32 +136,28 @@
</div>
<script>
'use strict';
var nw = require('nw.gui');
var pdgui = require('./pdgui.js');
'use strict';
var nw = require('nw.gui');
var pdgui = require('./pdgui.js');
// For translations
var l = pdgui.get_local_string;
// For translations
var l = pdgui.get_local_string;
console.log("my working dire is " + pdgui.get_pwd());
console.log("my working dire is " + pdgui.get_pwd());
pdgui.skin.apply(this);
pdgui.skin.apply(this);
var pd_object_callback;
var pd_object_callback;
function ok() {
apply();
cancel();
}
// function toggler(evt) {
// evt.value = evt.checked ? 1 : 0;
// }
function ok() {
apply();
cancel();
}
function substitute_space(arg) {
var fake_space = String.fromCharCode(11);
return arg.split(' ').join(fake_space);
}
function substitute_space(arg) {
var fake_space = String.fromCharCode(11);
return arg.split(' ').join(fake_space);
}
function strip_problem_chars(arg) {
var problem_chars = [';', ',', '{', '}', '\\'];
......@@ -191,16 +187,7 @@ function gatom_escape(str) {
}
function apply() {
pdgui.gui_post("we're applying shits!");
/*
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.gui_post("we're applying gatom changes!");
pdgui.pdsend([pd_object_callback, 'param',
+document.getElementById('width').value,
+document.getElementById('minimum-range').value,
......@@ -212,34 +199,34 @@ function apply() {
].join(' '));
}
function cancel() {
pdgui.gui_post("closing the window at this point");
// window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
}
function cancel() {
pdgui.gui_post("closing the window at this point");
//window.close(true);
pdgui.pdsend(pd_object_callback + " cancel");
}
// This gets called from the nw_create_window function in index.html
// It provides us with our window id from the C side. Once we have it
// we can create the menu and register event callbacks
function register_canvas_id(gfxstub, attr_array) {
pd_object_callback = gfxstub;
// This gets called from the nw_create_window function in index.html
// It provides us with our window id from the C side. Once we have it
// we can create the menu and register event callbacks
function register_canvas_id(gfxstub, attr_array) {
pd_object_callback = gfxstub;
console.log('attr array is ' + attr_array.toString());
for (var i = 0; i < attr_array.length; i+=2) {
console.log(attr_array[i] + ": " + attr_array[i+1]);
}
add_events(gfxstub);
// not sure that we need this for properties windows
// pdgui.canvas_map(gfxstub);
translate_form();
populate_form(attr_array);
// We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and
// snappier, at least on older machines.
document.getElementsByClassName('container')[0].style.setProperty('display', 'inline');
// document.getElementsByClass("fumbles")[0].setAttribute('style', 'display: inline;');
console.log('attr array is ' + attr_array.toString());
for (var i = 0; i < attr_array.length; i+=2) {
console.log(attr_array[i] + ": " + attr_array[i+1]);
}
add_events(gfxstub);
// not sure that we need this for properties windows
//pdgui.canvas_map(gfxstub);
translate_form();
populate_form(attr_array);
// We don't turn on rendering of the "container" div until
// We've finished displaying all the spans and populating the
// labels and form elements. That makes it more efficient and
// snappier, at least on older machines.
document.getElementsByClassName('container')[0]
.style.setProperty('display', 'inline');
}
function tr_text(id) {
var elem = document.getElementById('iem.prop.' + id);
......@@ -290,17 +277,14 @@ function populate_form(attr_array) {
}
function add_events(name) {
// let's handle some events for this window...
// closing the Window
nw.Window.get().on("close", function() {
// this needs to do whatever the "cancel" button does
// pdgui.pdsend(name + " menuclose 0");
// cancel();
//pdgui.pdsend(name + " menuclose 0");
//cancel();
pdgui.remove_dialogwin(pd_object_callback);
this.close(true);
});
}
</script>
......
......@@ -298,223 +298,204 @@
</div>
<script>
'use strict';
var nw = require('nw.gui');
var pdgui = require('./pdgui.js');
'use strict';
var nw = require('nw.gui');
var pdgui = require('./pdgui.js');
// For translations
var l = pdgui.get_local_string;
// For translations
var l = pdgui.get_local_string;
console.log("my working dire is " + pdgui.get_pwd());
console.log("my working dire is " + pdgui.get_pwd());
var pd_object_callback;
var pd_object_callback;
function ok() {
apply();
cancel();
}
function ok() {
apply();
cancel();
}
// function toggler(evt) {
// evt.value = evt.checked ? 1 : 0;
// }
function substitute_space(arg) {
var fake_space = String.fromCharCode(11);
return arg.split(' ').join(fake_space);
}
function substitute_space(arg) {
var fake_space = String.fromCharCode(11);
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 iemgui changes!");
/* 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);
}
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 = 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);
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;
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; }
// 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; }