Commit 55872b8b authored by Jonathan Wilkes's avatar Jonathan Wilkes

improve the external dialog api by adding an additional argument to specify...

improve the external dialog api by adding an additional argument to specify the input type, refactor grid dialog to the new interface
parent 7c98463e
......@@ -350,18 +350,18 @@ static void grid_properties(t_gobj *z, t_glist *owner)
gui_start_vmess("gui_external_dialog", "ss", gfx_tag, "grid");
gui_start_array();
gui_s("receive_symbol"); gui_s(x->x_name->s_name);
gui_s("width"); gui_i(x->x_width);
gui_s("min"); gui_f(x->x_min);
gui_s("max"); gui_f(x->x_max);
gui_s("height"); gui_i(x->x_height);
gui_s("y-min"); gui_f(x->y_min);
gui_s("y-max"); gui_f(x->y_max);
gui_s("grid_toggle"); gui_i(x->x_grid);
gui_s("x-steps"); gui_f(x->x_xstep);
gui_s("y-steps"); gui_f(x->x_ystep);
gui_s("x-lines"); gui_i(x->x_xlines);
gui_s("y-lines"); gui_i(x->x_ylines);
gui_s("symbol"); gui_s("receive_symbol"); gui_s(x->x_name->s_name);
gui_s("int"); gui_s("width"); gui_i(x->x_width);
gui_s("int"); gui_s("min"); gui_f(x->x_min);
gui_s("float"); gui_s("max"); gui_f(x->x_max);
gui_s("int"); gui_s("height"); gui_i(x->x_height);
gui_s("float"); gui_s("y-min"); gui_f(x->y_min);
gui_s("float"); gui_s("y-max"); gui_f(x->y_max);
gui_s("toggle"); gui_s("show_grid"); gui_i(x->x_grid);
gui_s("float"); gui_s("x-steps"); gui_f(x->x_xstep);
gui_s("float"); gui_s("y-steps"); gui_f(x->x_ystep);
gui_s("int"); gui_s("x-lines"); gui_i(x->x_xlines);
gui_s("int"); gui_s("y-lines"); gui_i(x->x_ylines);
gui_end_array();
gui_end_vmess();
......@@ -450,6 +450,11 @@ static void grid_displace(t_gobj *z, t_glist *glist, int dx, int dy)
x->y_current += dy;
if (xold != text_xpix(&x->x_obj, glist) || yold != text_ypix(&x->x_obj, glist))
{
gui_vmess("gui_text_displace", "xxii",
glist,
x,
dx,
dy);
//grid_draw_move(x, x->x_glist);
canvas_fixlinesfor(glist, (t_text *)z);
}
......@@ -882,10 +887,10 @@ void grid_setup(void)
/* Big hack for receiving edit-mode resize anchor clicks from
g_editor.c. */
class_addmethod(grid_class, (t_method)grid_click_for_resizing,
gensym("_click_for_resizing"),
gensym("_click"),
A_FLOAT, A_FLOAT, A_FLOAT, 0);
class_addmethod(grid_class, (t_method)grid_motion_for_resizing,
gensym("_motion_for_resizing"),
gensym("_motion"),
A_FLOAT, A_FLOAT, 0);
grid_widgetbehavior.w_getrectfn = grid_getrect;
grid_widgetbehavior.w_displacefn = grid_displace;
......
......@@ -98,13 +98,11 @@ function parse_attrs(attrs) {
elem.label = attr.replace("_", " ");
} else {
if (elem.type === "enum") {
if (elem.value) {
elem.value.push(attr);
if (elem.options) {
elem.options.push(attr);
} else {
elem.value = [attr];
elem.options = [attr];
}
} else if (elem.type === "enum_index") {
elem.index = attr;
} else {
elem.value = attr;
}
......@@ -137,7 +135,6 @@ function register_window_id(gfxstub, args) {
translate_form();
build_form(external_name, array_of_objects);
fud = array_of_objects;
// 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
......@@ -180,12 +177,15 @@ function build_form(external_name, array_of_objects) {
type = get_input_type(ob.type);
if (type === "select") {
elem = document.createElement("select");
ob.value.forEach(function(e) {
ob.options.forEach(function(e) {
var option = document.createElement("option");
option.textContent = e;
elem.appendChild(option);
});
elem.selectedIndex = ob.index;
elem.selectedIndex = ob.value;
elem.onchange = function() {
ob.value = elem.selectedIndex;
}
} else if (type === "checkbox") {
elem = document.createElement("input");
elem.type = "checkbox";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment