add scale field in image settings, add extra button for drawing image right away#
authorRobert Kaiser <kairo@kairo.at>
Wed, 29 Oct 2008 17:52:25 +0000 (18:52 +0100)
committerRobert Kaiser <kairo@kairo.at>
Wed, 29 Oct 2008 17:52:25 +0000 (18:52 +0100)
xulapp/chrome/mandelbrot/content/image-settings.js
xulapp/chrome/mandelbrot/content/image-settings.xul
xulapp/chrome/mandelbrot/content/mandelbrot.js
xulapp/chrome/mandelbrot/locales/en-US/image-settings.dtd

index d9af9935a85f0c138dac817bce1d080206a462c4..a907f5a20bf677a820a4350f3c40b43f88d18a2d 100644 (file)
@@ -38,6 +38,8 @@
 var gColorPalette = [];
 
 function initSettings() {
+  recalcCoord('Cr', 'scale');
+  recalcCoord('Ci', 'scale');
 }
 
 function drawPreview() {
@@ -78,3 +80,16 @@ function drawPreview() {
   drawLine(0, [Cr_min, Cr_max, Ci_min, Ci_max],
               canvas, context, iterMax, algorithm);
 }
+
+function recalcCoord(coord, target) {
+  if (target == 'scale') {
+    document.getElementById(coord + '_scale').value =
+      parseFloat(document.getElementById(coord + '_max').value) -
+      parseFloat(document.getElementById(coord + '_min').value);
+  }
+  else if (target == 'max') {
+    document.getElementById('mandelbrot.last_image.' + coord + '_max').value =
+      parseFloat(document.getElementById(coord + '_min').value) +
+      parseFloat(document.getElementById(coord + '_scale').value);
+  }
+}
\ No newline at end of file
index 04da6562b5a34335cbfe03aa27214bebda5440af..c4c609222702b36f5d63dc173deac99286ab6026 100644 (file)
@@ -46,9 +46,9 @@
             xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
             xmlns:html="http://www.w3.org/1999/xhtml"
             title="&imageSettings.title;"
-            dlgbuttons="accept,cancel"
-            ondialogaccept="callDrawImage();"
-            buttonlabelaccept="&DrawImageButton.label;">
+            buttons="accept,cancel,extra1"
+            ondialogextra1="callDrawImage();"
+            buttonlabelextra1="&DrawImageButton.label;">
 
   <prefpane id="imgSettingsPane" onpaneload="initSettings();">
     <script type="application/x-javascript"
       <hbox flex="1">
         <label value="&coord.min.label;" control="Cr_min"/>
         <textbox id="Cr_min" size="10"
-                 preference="mandelbrot.last_image.Cr_min"/>
+                 preference="mandelbrot.last_image.Cr_min"
+                 onchange="recalcCoord('Cr', 'scale');"/>
         <label value="&coord.max.label;" control="Cr_max"/>
         <textbox id="Cr_max" size="10"
-                 preference="mandelbrot.last_image.Cr_max"/>
+                 preference="mandelbrot.last_image.Cr_max"
+                 onchange="recalcCoord('Cr', 'scale');"/>
+        <label value="&coord.scale.label;" control="Cr_scale"/>
+        <textbox id="Cr_scale" size="10"
+                 onchange="recalcCoord('Cr', 'max');"/>
       </hbox>
       <description value="&coord.imag.label;"/>
       <hbox flex="1">
         <label value="&coord.min.label;" control="Ci_min"/>
         <textbox id="Ci_min" size="10"
-                 preference="mandelbrot.last_image.Ci_min"/>
+                 preference="mandelbrot.last_image.Ci_min"
+                 onchange="recalcCoord('Ci', 'scale');"/>
         <label value="&coord.max.label;" control="Ci_max"/>
         <textbox id="Ci_max" size="10"
-                 preference="mandelbrot.last_image.Ci_max"/>
+                 preference="mandelbrot.last_image.Ci_max"
+                 onchange="recalcCoord('Ci', 'scale');"/>
+        <label value="&coord.scale.label;" control="Ci_scale"/>
+        <textbox id="Ci_scale" size="10"
+                 onchange="recalcCoord('Ci', 'max');"/>
       </hbox>
     </groupbox>
 
                    preference="mandelbrot.image.height"/>
         </hbox>
       </groupbox>
-    
+
       <groupbox>
         <caption label="&preview.title;"/>
         <hbox flex="1" pack="center" align="center">
index 02654971e238b88020bf35a64a7046f7c1132de7..cf4927af4a961069b679135d1e86436104db96ad 100644 (file)
@@ -137,7 +137,7 @@ function drawLine(line, dimensions, canvas, context, iterMax, algorithm) {
 
     if (img_y < canvas.height)
       setTimeout(drawLine, 0, img_y, dimensions, canvas, context, iterMax, algorithm);
-    else
+    else if (gStartTime)
       EndCalc();
 }
 
index ea6c02bae0d0f968cf51f8c3e6e33ab7cacc09fb..1351acc4bff6a9707616a850df3ea328d4547f91 100644 (file)
@@ -43,6 +43,7 @@
 <!ENTITY coord.imag.label      "Imaginary">
 <!ENTITY coord.min.label       "From">
 <!ENTITY coord.max.label       "To">
+<!ENTITY coord.scale.label     "Scale">
 
 <!ENTITY img.size.title        "Image Size">
 <!ENTITY img.width.label       "Width">