Revision: 4750 http://sourceforge.net/p/vexi/code/4750 Author: mkpg2 Date: 2014-11-23 17:22:58 +0000 (Sun, 23 Nov 2014) Log Message: ----------- org.vexi.tool.DrawArea
Modified Paths: -------------- branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t Added Paths: ----------- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/tool/DrawArea.t Modified: branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t =================================================================== --- branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t 2014-11-18 03:26:40 UTC (rev 4749) +++ branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t 2014-11-23 17:22:58 UTC (rev 4750) @@ -3,68 +3,14 @@ <vexi xmlns:ui="vexi://ui" xmlns:w="vexi.widget" xmlns:image="org.vexi.demo.image" - xmlns:demo="org.vexi.demo"> + xmlns:demo="org.vexi.demo" + xmlns:tool="org.vexi.tool"> <w:surface /> <ui:box frameheight="600" framewidth="500" orient="vertical"> - <w:bevel form="down" shrink="true"> - <ui:Box layout="layer" - width="400" - height="400" > - <ui:Box id="background" fill=":image.block_mask_20x20"/> - <ui:Canvas id="canvas" - tile="false" - dotsPerPixel="1"> - drawColor = "black"; - drawWidth = 2; - - var draw = false; - var x0; - var y0; - thisbox.Press1 ++= function(v){ - cascade = v; - draw = true; - const s = surface; - const frameToThis = s.frame.distanceto(thisbox); - const m = s.frame.mouse; - x0 = m.x-frameToThis.x; - y0 = m.y-frameToThis.y; - drawLine(x0,y0,x0,y0); - } - - thisbox.Release1 ++= function(v){ - cascade = v; - draw = false; - }; - - thisbox.Enter ++= function(v){ - cascade = v; - if(draw){ - const s = surface; - const frameToThis = s.frame.distanceto(thisbox); - const m = s.frame.mouse; - x0 = m.x-frameToThis.x; - y0 = m.y-frameToThis.y; - } - }; - - - thisbox.Move ++= function(v){ - cascade = v; - if(draw){ - const s = surface; - const frameToThis = s.frame.distanceto(thisbox); - const m = s.frame.mouse; - var x1 = m.x-frameToThis.x; - var y1 = m.y-frameToThis.y; - drawLine(x0,y0,x1,y1); - x0 = x1; - y0 = y1; - } - } - </ui:Canvas> - - </ui:Box> - </w:bevel> + <tool:DrawArea id="draw" + width="400" + height="400" + backgroundFill=":image.block_mask_20x20"/> <ui:Box height="50"> <w:button text="Save" id="save"/> <w:button text="Load" id="load"/> @@ -77,7 +23,7 @@ vexi.thread = function(){ var file = vexi.file.save("canvas."+suffix); if(file!=null){ - var png = $canvas.save(suffix); + var png = $draw.canvas.save(suffix); vexi.stream.pipe(png, file); } } @@ -87,16 +33,15 @@ $load.action ++= function(v){ vexi.thread = function(){ var file = vexi.file.load(); - $canvas.load(file); + $draw.canvas.load(file); } }; - $loadbg.action ++= function(v){ vexi.thread = function(){ var file = vexi.file.load(); - $background.fill = file; + $draw.backgroundFill = file; } }; Added: branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/tool/DrawArea.t =================================================================== --- branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/tool/DrawArea.t (rev 0) +++ branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/tool/DrawArea.t 2014-11-23 17:22:58 UTC (rev 4750) @@ -0,0 +1,65 @@ +<!-- public domain --> + +<vexi xmlns:ui="vexi://ui" + xmlns:w="vexi.widget"> + <w:bevel form="down" shrink="true"/> + <ui:Box layout="layer" + width="400" + height="400" > + <ui:Box id="background"/> + <ui:Canvas id="canvas" + tile="false" + dotsPerPixel="1"> + drawColor = "black"; + drawWidth = 2; + + var draw = false; + var x0; + var y0; + thisbox.Press1 ++= function(v){ + cascade = v; + draw = true; + const s = surface; + const frameToThis = s.frame.distanceto(thisbox); + const m = s.frame.mouse; + x0 = m.x-frameToThis.x; + y0 = m.y-frameToThis.y; + drawLine(x0,y0,x0,y0); + } + + thisbox.Release1 ++= function(v){ + cascade = v; + draw = false; + }; + + thisbox.Enter ++= function(v){ + cascade = v; + if(draw){ + const s = surface; + const frameToThis = s.frame.distanceto(thisbox); + const m = s.frame.mouse; + x0 = m.x-frameToThis.x; + y0 = m.y-frameToThis.y; + } + }; + + + thisbox.Move ++= function(v){ + cascade = v; + if(draw){ + const s = surface; + const frameToThis = s.frame.distanceto(thisbox); + const m = s.frame.mouse; + var x1 = m.x-frameToThis.x; + var y1 = m.y-frameToThis.y; + drawLine(x0,y0,x1,y1); + x0 = x1; + y0 = y1; + } + } + </ui:Canvas> + thisbox.backgroundFill ++= function(v){ $background.fill = v; }; + thisbox.backgroundFill ++= function(){ return $background.fill; }; + thisbox.canvas = $canvas; + </ui:Box> +</vexi> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn