From 7651d66c3807eec49509bf03115f0047f9e9173f Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 13 Jan 2023 14:06:29 +0000 Subject: [PATCH] Disable Canvas menubar for now --- Nasal/canvas/ImageTest.nas | 49 ++++++++++++++++++++++++++++++++++++++ Nasal/canvas/gui.nas | 9 +++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 Nasal/canvas/ImageTest.nas diff --git a/Nasal/canvas/ImageTest.nas b/Nasal/canvas/ImageTest.nas new file mode 100644 index 000000000..ba01eefdb --- /dev/null +++ b/Nasal/canvas/ImageTest.nas @@ -0,0 +1,49 @@ +var ImageTest = { + + new : func() + { + var obj = { + parents : [ ImageTest ], + width : 528, + height : 528, + }; + + obj.window = canvas.Window.new([obj.width,obj.height],"dialog").set('title',"CanvasImageTest"); + + # creating the top-level/root group which will contain all other elements/group + obj.myCanvas = obj.window.createCanvas(); + obj.myCanvas.set("name", "Test"); + obj.root = obj.myCanvas.createGroup(); + obj._slice = 17; + + obj._frame = + obj.root.createChild("image", "background") + .set("src", "gui/images/tooltip.png") + .set("slice", obj._slice ~ " fill") + .setSize([obj.width,obj.height]); + + obj._image = obj.root.createChild("image", "TestImage") + .setSize(500, 500); + obj._image.set("src", "gui/images/cat.png"); + + obj.pixelX = 0; + obj.pixelY = 0; + + var t = maketimer(0.05, obj, func { + obj.pixelX += 1; + if (obj.pixelX >= obj.width) { + obj.pixelX = 0; + obj.pixelY += 1; + if (obj.pixelY >= obj.height) { + obj.pixelY = 0; + } + } + + var c = math.mod(obj.pixelX + obj.pixelY, 32) / 32.0; + me._image.setPixel(obj.pixelX, obj.pixelY, [c, (1.0 - c), c, 1.0]); + me._image.dirtyPixels(); + }); + t.start(); + } +}; + diff --git a/Nasal/canvas/gui.nas b/Nasal/canvas/gui.nas index 40742504d..220a499a9 100644 --- a/Nasal/canvas/gui.nas +++ b/Nasal/canvas/gui.nas @@ -14,6 +14,7 @@ var gui = { focused_window: nil, open_popups: [], region_highlight: nil, + menubar: nil, # Window/dialog stacking order STACK_INDEX: { @@ -595,7 +596,8 @@ getDesktop().addEventListener("mousedown", func { } }); -gui.menubar = gui.MenuBar.new(); +# disabled until this is hooked up to the PUICompat code +#gui.menubar = gui.MenuBar.new(); # Provide old 'Dialog' for backwards compatiblity (should be removed for 3.0) var Dialog = { @@ -607,5 +609,8 @@ var Dialog = { }; var unloadGUI = func() { - gui.menubar.del(); + if (gui.menubar) { + gui.menubar.del(); + gui.menubar = nil; + } }