Commit 5d32723f authored by Aayush's avatar Aayush

added ascii_art parser and UI to take ascii_art input

parent 04670509
Pipeline #1570 canceled with stage
......@@ -73,7 +73,8 @@
"mknob_steps": "# of steps",
"mknob_steps_tt": "number of dial positions for the knob",
"mknob_size": "size",
"mknob_size_tt": "size of the knob"
"mknob_size_tt": "size of the knob",
"submit_tt": "submit ascii_art to parser"
}
},
"gatom": {
......@@ -200,6 +201,8 @@
"comment_tt": "Füge dem Patch einen Kommentar hinzu",
"dropdown": "Dropdown",
"dropdown_tt": "Dropdown menu",
"ascii_art": "Ascii_Art",
"ascii_art_tt": "ASCII_ART menu",
"bang": "Bang",
"bang_tt": "Füge dem Patch einen Taster zum Senden von Bang-Nachrichten hinzu",
"toggle": "Toggle",
......
......@@ -72,7 +72,8 @@
"mknob_steps": "# of steps",
"mknob_steps_tt": "number of dial positions for the knob",
"mknob_size": "size",
"mknob_size_tt": "size of the knob"
"mknob_size_tt": "size of the knob",
"submit_tt": "submit ascii_art to parser"
}
},
"gatom": {
......@@ -199,6 +200,8 @@
"comment_tt": "Write a comment on the canvas",
"dropdown": "Dropdown",
"dropdown_tt": "Dropdown menu",
"ascii_art": "Ascii_art",
"ascii_art_tt": "ASCII_ART menu",
"bang": "Bang",
"bang_tt": "Add a graphical button to the canvas for sending bang messages",
"toggle": "Toggle",
......
......@@ -51,6 +51,18 @@
<span data-i18n="canvas.find.search"></span>
</button>
</div>
<div id="ascii_art" style="display:none;">
<textarea id="ascii_art_text_area"
rows="10" cols="50">
write your ascii art here
</textarea>
<button type="button"
id="canvas_ascii_art_button"
data-i18n="[title]canvas.ascii_art.submit_tt">
submit ascii_art
</button>
<span data-i18n="canvas.ascii_art.submit"></span>
</div>
<div style="display:none;" id="dropdown_list" class="noselect">
<ol></ol>
</div>
......
......@@ -3,6 +3,7 @@
var gui = require("nw.gui");
var pdgui = require("./pdgui.js");
var pd_menus = require("./pd_menus.js");
var pd_ascii_art = require("./pd_ascii_art.js");
// Apply gui preset to this canvas
pdgui.skin.apply(window);
......@@ -426,6 +427,13 @@ var canvas_events = (function() {
events.find_click(evt);
}
},
submit_ascii_art : function(evt) {
var art = document.getElementById("ascii_art_text_area").value;
var parsed_art = pd_ascii_art.parse_ascii_art(art);
// to check the create pd_message
document.getElementById("ascii_art_text_area").innerHTML = parsed_art.pd_message;
canvas_events[canvas_events.get_previous_state()]();
},
scalar_draggable_mousemove: function(evt) {
var new_x = evt.pageX,
new_y = evt.pageY,
......@@ -1020,6 +1028,10 @@ var canvas_events = (function() {
document.querySelector("#canvas_find_button")
.addEventListener("click", events.find_click
);
//submit ascii art to parser
document.querySelector("#canvas_ascii_art_button")
.addEventListener("click", events.submit_ascii_art
);
// We need to separate these into nw_window events and html5 DOM
// events closing the Window this isn't actually closing the window
// yet
......@@ -1358,11 +1370,11 @@ function nw_create_patch_window_menus(gui, w, name) {
minit(m.edit.paste_clipboard, {
enabled: true,
click: function () {
var clipboard = nw.Clipboard.get();
var text = clipboard.get('text');
//pdgui.post("** paste from clipboard: "+text);
canvas_events.paste_from_pd_file(name, text);
}
var clipboard = nw.Clipboard.get();
var text = clipboard.get('text');
//pdgui.post("** paste from clipboard: "+text);
canvas_events.paste_from_pd_file(name, text);
}
});
minit(m.edit.duplicate, {
enabled: true,
......@@ -1566,6 +1578,23 @@ function nw_create_patch_window_menus(gui, w, name) {
pdgui.pdsend(name, "dropdown 0");
}
});
minit(m.put.ascii_art, {
enabled: true,
click: function() {
var ascii_art = w.document.getElementById("ascii_art"),
ascii_art_text_area = w.document.getElementById("ascii_art_text_area"),
state = ascii_art.style.getPropertyValue("display");
// if there's a box being edited, try to instantiate it in Pd
instantiate_live_box();
if (state === "none") {
ascii_art.style.setProperty("display", "block");
ascii_art_text_area.focus();
canvas_events.none();
} else {
ascii_art.style.setProperty("display", "none");
}
}
});
minit(m.put.bang, {
enabled: true,
click: function(e) {
......
......@@ -362,24 +362,24 @@ function create_menu(gui, type) {
tooltip: l("menu.zoomreset_tt")
}));
if (canvas_menu) {
view_menu.append(m.view.optimalzoom = new gui.MenuItem({
view_menu.append(m.view.optimalzoom = new gui.MenuItem({
label: l("menu.zoomoptimal"),
key: shortcuts.menu.zoomoptimal.key,
modifiers: shortcuts.menu.zoomoptimal.modifiers,
tooltip: l("menu.zoomoptimal_tt")
}));
view_menu.append(m.view.horizzoom = new gui.MenuItem({
}));
view_menu.append(m.view.horizzoom = new gui.MenuItem({
label: l("menu.zoomhoriz"),
key: shortcuts.menu.zoomhoriz.key,
modifiers: shortcuts.menu.zoomhoriz.modifiers,
tooltip: l("menu.zoomhoriz_tt")
}));
view_menu.append(m.view.vertzoom = new gui.MenuItem({
}));
view_menu.append(m.view.vertzoom = new gui.MenuItem({
label: l("menu.zoomvert"),
key: shortcuts.menu.zoomvert.key,
modifiers: shortcuts.menu.zoomvert.modifiers,
tooltip: l("menu.zoomvert_tt")
}));
}));
}
view_menu.append(new gui.MenuItem({ type: "separator" }));
view_menu.append(m.view.fullscreen = new gui.MenuItem({
......@@ -431,6 +431,12 @@ function create_menu(gui, type) {
modifiers: shortcuts.menu.dropdown.modifiers,
tooltip: l("menu.dropdown_tt")
}));
put_menu.append(m.put.ascii_art = new gui.MenuItem({
label: l("menu.ascii_art"),
key: shortcuts.menu.ascii_art.key,
modifiers: shortcuts.menu.ascii_art.modifiers,
tooltip: l("menu.ascii_art_tt")
}));
put_menu.append(new gui.MenuItem({ type: "separator" }));
put_menu.append(m.put.bang = new gui.MenuItem({
label: l("menu.bang"),
......
......@@ -47,6 +47,7 @@ exports.menu = {
"symbol": { key: "4", modifiers: cmd_or_ctrl },
"comment": { key: "5", modifiers: cmd_or_ctrl },
"dropdown": { key: "6", modifiers: cmd_or_ctrl },
"ascii_art": { key: "7", modifiers: cmd_or_ctrl },
"bang": { key: "b", modifiers: cmd_or_ctrl + "+shift" },
"toggle": { key: "t", modifiers: cmd_or_ctrl + "+shift" },
"number2": { key: "n", modifiers: cmd_or_ctrl + "+shift" },
......
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