Commit 2315cdbf authored by nerrons's avatar nerrons
Browse files

pdgui.js: Add new exported functions for determining K12 mode; add k12_offset related changes

parent 980e171a
......@@ -327,7 +327,8 @@ var pd_myversion, // Pd version string
colors, //
global_clipboard, //
global_selection, //
k12_mode = 0, // should be set from argv ("0" is just a stopgap)
k12_mode = 0,
k12_offset = 0,
k12_saveas_on_new, //
autotips, // tooltips
magicglass, // cord inspector
......@@ -349,8 +350,22 @@ var pd_myversion, // Pd version string
".help":"Max Help Files"
};
exports.k12_mode = k12_mode;
exports.pd_filetypes = pd_filetypes;
// gets called once by index.js when initializing
exports.set_k12_mode = function (k12) {
k12_mode = k12; // set the global k12 variable
k12_offset = k12_mode ? -200 : 0;
if (k12_mode) {
post("K12 mode is on. K12 offset: " + k12_offset);
} else {
post("K12 mode is off");
}
}
exports.get_k12_mode = function () { return k12_mode; };
exports.get_k12_offset = function () { return k12_offset; };
exports.get_k12_demo_dir = function () {
return path.join(lib_dir, "extra/K12/demos");
}
popup_coords = [0,0];
......@@ -989,7 +1004,7 @@ function menu_new () {
pdsend("pd filename",
"Untitled-" + untitled_number,
enquote(defunkify_windows_path(untitled_directory)));
// I don't think k12_mode works yet. Need to test this.
// If in K12 Mode, add a hidden preset_hub to every new canvas
if (k12_mode == 1) {
k12_saveas_on_new = 1;
pdsend("#N canvas");
......@@ -1017,13 +1032,6 @@ function gui_window_close(cid) {
loading[cid] = null;
}
function menu_k12_open_demos () {
}
exports.menu_k12_open_demos = menu_k12_open_demos;
function menu_open (filenames_string) {
var file_array = filenames_string.split(";"),
length = file_array.length,
......@@ -4668,7 +4676,7 @@ function gui_canvas_popup(cid, xpos, ypos, canprop, canopen, isobject) {
// coordinates. Thus the SVG viewbox will have negative values for the
// top left corner, and those must be subtracted from xpos/ypos to get
// the proper window coordinates.
xpos -= Math.floor(svg_view_box[0] * zfactor);
xpos -= Math.floor(svg_view_box[0] * zfactor + k12_offset);
ypos -= Math.floor(svg_view_box[1] * zfactor);
popup_coords[2] = xpos + nw_win.x;
......@@ -5149,7 +5157,7 @@ function gui_dropdown_activate(cid, obj_tag, tag, current_index, font_size, stat
// set a max-height to force scrollbar if needed
select_elem.style.setProperty("max-height", div_max + "px");
select_elem.style.setProperty("left",
(elem_get_coords(g).x - svg_view.x) + "px");
(elem_get_coords(g).x - svg_view.x - k12_offset) + "px");
// Remove "top" and "bottom" props to keep state clean
select_elem.style.removeProperty("top");
select_elem.style.removeProperty("bottom");
......@@ -5587,7 +5595,7 @@ function gui_textarea(cid, tag, type, x, y, width_spec, height_spec, text,
.viewBox.baseVal;
p.classList.add(type);
p.contentEditable = "true";
p.style.setProperty("left", (x - svg_view.x) + "px");
p.style.setProperty("left", (x - svg_view.x - k12_offset) + "px");
p.style.setProperty("top", (y - svg_view.y) + "px");
p.style.setProperty("font-size",
pd_fontsize_to_gui_fontsize(font_size) + "px");
......@@ -5679,7 +5687,8 @@ function canvas_params(nw_win)
// the scrollbars from appearing. Here, we just subtract 4 from both
// of them. This could lead to some problems with event handlers but I
// haven't had a problem with it yet.
min_width = nw_win.window.innerWidth - 4;
// For K12 Mode: the min_width should be slightly larger than the k12_offset
min_width = nw_win.window.innerWidth - 4 + (Math.floor(k12_offset * 1.15));
min_height = nw_win.window.innerHeight - 4;
// Since we don't do any transformations on the patchsvg,
// let's try just using ints for the height/width/viewBox
......
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