summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html2
-rw-r--r--js/tool.js23
-rw-r--r--js/ui/controls.js33
3 files changed, 40 insertions, 18 deletions
diff --git a/index.html b/index.html
index b3a5284..057c0a1 100644
--- a/index.html
+++ b/index.html
@@ -8,7 +8,7 @@
<div id="canvas_rapper" class="rapper"></div>
</div>
- <div style="clear:both;width: 270px;float: left;">
+ <div style="clear:both;width: 300px;float: left;">
<div class="block">
<div id="palette_rapper"></div>
<span id="experimental_palette_toggle">.</div>
diff --git a/js/tool.js b/js/tool.js
index 719e044..807b645 100644
--- a/js/tool.js
+++ b/js/tool.js
@@ -35,10 +35,27 @@ var Checkbox = Tool.extend({
}
})
-var HiddenCheckbox = Tool.extend({
+var BlurredCheckbox = Checkbox.extend({
+ focus: function(){
+ this.use()
+ if (this.name != 'shader') { cursor_input.focus() }
+ }
+})
+
+var BlurredTool = Tool.extend({
+ focus: function(){
+ this.use()
+ if (this.name != 'shader') { cursor_input.focus() }
+ }
+})
+
+var HiddenCheckbox = BlurredCheckbox.extend({
init: function (span){
- this.__init(span)
- var state = this.name[0] == "o"
+ this.el = span
+ this.lex = new Lex (span)
+ this.name = span.innerHTML
+ this.span = span
+ var state = this.name[0] == "o"
this.update(state)
},
update: function(state){
diff --git a/js/ui/controls.js b/js/ui/controls.js
index e666464..b1b1eb4 100644
--- a/js/ui/controls.js
+++ b/js/ui/controls.js
@@ -72,12 +72,14 @@ var controls = (function(){
document.body.classList.remove("bucket")
}
- controls.clear = new Tool (clear_el)
+ controls.clear = new BlurredTool (clear_el)
controls.clear.use = function(){
- canvas.erase()
+ if (confirm("really delete this colorcode?")) {
+ canvas.erase()
+ }
}
- controls.webcam = new Tool (webcam_el)
+ controls.webcam = new BlurredTool (webcam_el)
controls.webcam.load = function(){
this.loaded = true
webcam_close.addEventListener("click", function(){ controls.webcam.blur() })
@@ -101,7 +103,7 @@ var controls = (function(){
webcam_rapper.style.display = "none"
}
- controls.grid = new Checkbox (grid_el)
+ controls.grid = new BlurredCheckbox (grid_el)
controls.grid.use = function(){
document.body.classList.toggle('grid')
this.update( document.body.classList.contains("grid") )
@@ -135,14 +137,17 @@ var controls = (function(){
//
ShaderTool = Tool.extend({
- use: function(){
- shader_rapper.style.display = "block"
- shader_textarea.focus()
+ active: false,
+ use: function(state){
+ this.active = typeof state == "boolean" ? state : ! this.active
+ if (this.active) {
+ shader_rapper.style.display = "block"
+ shader_textarea.focus()
+ }
+ else {
+ shader_rapper.style.display = "none"
+ }
},
- blur: function(){
- this.__blur()
- shader_rapper.style.display = "none"
- }
})
controls.shader = new ShaderTool (shader_el)
shader_textarea.value = demo_shader.innerHTML
@@ -164,19 +169,19 @@ var controls = (function(){
//
- controls.fg = new Checkbox (fg_checkbox)
+ controls.fg = new BlurredCheckbox (fg_checkbox)
controls.fg.use = function(state){
brush.draw_fg = state || ! brush.draw_fg
this.update(brush.draw_fg)
}
- controls.bg = new Checkbox (bg_checkbox)
+ controls.bg = new BlurredCheckbox (bg_checkbox)
controls.bg.use = function(state){
brush.draw_bg = state || ! brush.draw_bg
this.update(brush.draw_bg)
}
- controls.char = new Checkbox (char_checkbox)
+ controls.char = new BlurredCheckbox (char_checkbox)
controls.char.use = function(state){
brush.draw_char = state || ! brush.draw_char
this.update(brush.draw_char)