X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=blobdiff_plain;f=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fmandelbrot.js;h=72154191907dd4592a2f881ac53280fcb87f9d85;hp=c0a8c1ca64331968c71a9c74056e34340952e966;hb=84e4253dade312621f4f73ba58eab4d19f0c63d1;hpb=f34775a65f93b36d549b5419734e033805e5b000 diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index c0a8c1c..7215419 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -45,6 +45,7 @@ var gCurrentImageData; function Startup() { updateIterMenu(); + updateAlgoMenu(); updatePaletteMenu(); gMbrotBundle = document.getElementById("mbrotBundle"); document.getElementById("statusLabel").value = gMbrotBundle.getString("statusEmpty"); @@ -83,7 +84,7 @@ function adjustCoordsAndDraw(aC_min, aC_max) { if (aC_max.i > 2) aC_max.i = 2; if ((aC_min.i > 2) || (aC_max.i < -2) || (aC_min.i >= aC_max.i)) { - aC_min.i = -1.5; aC_max.i = 1.5; + aC_min.i = -1.3; aC_max.i = 1.3; } let CWidth = aC_max.r - aC_min.r; @@ -115,8 +116,8 @@ function drawImage() { Cr_max = parseFloat(gPref.getCharPref("mandelbrot.last_image.Cr_max")); } catch (e) { } - if ((Cr_min < -2) || (Cr_min > 2) || - (Cr_max < -2) || (Cr_max > 2) || (Cr_min >= Cr_max)) { + if ((Cr_min < -3) || (Cr_min > 2) || + (Cr_max < -3) || (Cr_max > 2) || (Cr_min >= Cr_max)) { Cr_min = -2.0; Cr_max = 1.0; } gPref.setCharPref("mandelbrot.last_image.Cr_min", Cr_min); @@ -129,8 +130,8 @@ function drawImage() { Ci_max = parseFloat(gPref.getCharPref("mandelbrot.last_image.Ci_max")); } catch (e) { } - if ((Ci_min < -2) || (Ci_min > 2) || - (Ci_max < -2) || (Ci_max > 2) || (Ci_min >= Ci_max)) { + if ((Ci_min < -2.5) || (Ci_min > 2.5) || + (Ci_max < -2.5) || (Ci_max > 2.5) || (Ci_min >= Ci_max)) { Ci_min = -1.5; Ci_max = 1.5; } gPref.setCharPref("mandelbrot.last_image.Ci_min", Ci_min); @@ -401,18 +402,23 @@ function drawPoint(context, img_x, img_y, C, iterMax, algorithm) { /***** pure UI functions *****/ var zoomstart; +var imgBackup; function mouseevent(etype, event) { let canvas = document.getElementById("mbrotImage"); + let context = canvas.getContext("2d"); switch (etype) { case 'down': - if (event.button == 0) + if (event.button == 0) { // left button - start dragzoom zoomstart = {x: event.clientX - canvas.offsetLeft, y: event.clientY - canvas.offsetTop}; + imgBackup = context.getImageData(0, 0, canvas.width, canvas.height); + } break; case 'up': if (event.button == 0 && zoomstart) { + context.putImageData(imgBackup, 0, 0); let zoomend = {x: event.clientX - canvas.offsetLeft, y: event.clientY - canvas.offsetTop}; @@ -447,6 +453,15 @@ function mouseevent(etype, event) { } } zoomstart = undefined; + break; + case 'move': + if (event.button == 0 && zoomstart) { + context.putImageData(imgBackup, 0, 0); + context.strokeStyle = "rgb(255,255,31)"; + context.strokeRect(zoomstart.x, zoomstart.y, + event.clientX - canvas.offsetLeft - zoomstart.x, + event.clientY - canvas.offsetTop - zoomstart.y); + } break; } } @@ -470,6 +485,15 @@ function saveImage() { } } +function exitMandelbrot() { + var appInfo = Components.classes["@mozilla.org/xre/app-info;1"] + .getService(Components.interfaces.nsIXULAppInfo); + if (appInfo.ID == "mandelbrot@kairo.at") + quitApp(false); + else + window.close(); +} + function updateBookmarkMenu(aParent) { document.getElementById("bookmarkSave").disabled = (!document.getElementById("drawButton").hidden || (gStartTime > 0)); @@ -654,14 +678,19 @@ function imgSettings() { } function updateDebugMenu() { - var jitMenuItem = document.getElementById("jitEnabled"); - jitMenuItem.setAttribute("checked", gPref.getBoolPref("javascript.options.jit.chrome")); + let scope = (document.getElementById("mandelbrotWindow").nodeName == "page") ? "content" : "chrome"; + for each (let type in ["tracejit", "methodjit"]) { + let jitMenuItem = document.getElementById(type + "Enabled"); + jitMenuItem.setAttribute("checked", gPref.getBoolPref("javascript.options." + type + "." + scope)); + } } -function toggleJITState(jitMenuItem) { - var jitEnabled = !gPref.getBoolPref("javascript.options.jit.chrome"); - gPref.setBoolPref("javascript.options.jit.chrome", jitEnabled) - jitMenuItem.setAttribute("checked", jitEnabled? "true" : "false"); +function toggleJITState(jitMenuItem, jittype) { + let scope = (document.getElementById("mandelbrotWindow").nodeName == "page") ? "content" : "chrome"; + let jitpref = "javascript.options." + jittype + "jit." + scope; + let jitEnabled = !gPref.getBoolPref(jitpref); + gPref.setBoolPref(jitpref, jitEnabled) + jitMenuItem.setAttribute("checked", jitEnabled ? "true" : "false"); } function updateAlgoMenu() {