update clipper

This commit is contained in:
lxsang 2020-07-14 23:27:28 +02:00
parent 0e6ba3c41d
commit a2b38c7136
9 changed files with 9 additions and 7 deletions

View File

@ -6,7 +6,8 @@ Clipper use `html2canvas` to capture AntOS desktop or a specific window.
It is able to crop the captured image before saving to a file It is able to crop the captured image before saving to a file
## Change logs ## Change logs
* v0.1.1-a use ALT-S as global shortcut for screen capture * v0.1.2-a use ALT-S as global shortcut for screen capture
* v0.1.1-a use CTRL-S as global shortcut for screen capture
* v0.1.0-a initial version * v0.1.0-a initial version

View File

@ -6,7 +6,8 @@ Clipper use `html2canvas` to capture AntOS desktop or a specific window.
It is able to crop the captured image before saving to a file It is able to crop the captured image before saving to a file
## Change logs ## Change logs
* v0.1.1-a use ALT-S as global shortcut for screen capture * v0.1.2-a use ALT-S as global shortcut for screen capture
* v0.1.1-a use CTRL-S as global shortcut for screen capture
* v0.1.0-a initial version * v0.1.0-a initial version

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -2,7 +2,7 @@
* html2canvas 1.0.0-rc.5 <https://html2canvas.hertzen.com> * html2canvas 1.0.0-rc.5 <https://html2canvas.hertzen.com>
* Copyright (c) 2020 Niklas von Hertzen <https://hertzen.com> * Copyright (c) 2020 Niklas von Hertzen <https://hertzen.com>
* Released under MIT License * Released under MIT License
*/var A,e;(function(){var A;(A=class extends this.OS.application.BaseApplication{constructor(A){super("Clipper",A)}main(){var A;if(this.scene=this.find("scene"),this.wrapper=this.find("wrapper"),this.cropwin=this.find("cropwin"),this.dirty=!1,this.currfile="Untitled".asFileHandle(),$(this.cropwin).css("position","absolute").hide(),this.find("btnCptScreen").onbtclick=()=>this.capture(document.body,!0),this.find("btnCptWindow").onbtclick=()=>{var A,e,t,r,n,B,s;for(e in s=[],n=OS.PM.processes)for(A=0,t=(B=n[e]).length;A<t;A++)r=B[A],0===OS.application[r.name].type&&s.push({text:r.scheme.apptitle,el:r.scheme,icon:r.meta().icon,iconclass:r.meta().iconclass});return this.openDialog("SelectionDialog",{title:"Select a window",data:s}).then(A=>{if(A)return this.capture(A.el)})},A=this.find("btnCrop"),this.cropselect=A=>{var e,t,r;return t=$(this.cropwin).offset(),r=A.clientX-t.left,e=A.clientY-t.top,$(this.cropwin).css("width",r+"px").css("height",e+"px")},this.cropup=e=>($(window).off("mousemove",this.cropselect),$(window).off("mouseup",this.cropup),this.ask({text:__("Crop the selected zone ?")}).then(e=>{var t,r,n,B,s,o,i,a;if(A.enable=!0,A.selected=!1,t=$(this.cropwin).offset(),s=$(this.scene).offset(),i=t.left-s.left,a=t.top-s.top,o=$(this.cropwin).width(),B=$(this.cropwin).height(),$(this.cropwin).hide(),$(this.cropwin).css("width","0px").css("height","0px"),e)return n=(r=this.scene.getContext("2d")).getImageData(i,a,o,B),this.scene.width=o,this.scene.height=B,r.putImageData(n,0,0),this.dirty=!0})),this.cropdown=e=>{var t;return A.enable=!1,t=$(this.scheme).offset(),$(this.cropwin).css("left",e.clientX-t.left+"px").css("top",e.clientY-t.top+"px").show(),$(window).off("mousedown",this.cropdown),$(window).mousemove(this.cropselect),$(window).mouseup(this.cropup)},A.onbtclick=()=>A.selected?$(window).mousedown(this.cropdown):$(window).off("mousedown",this.cropdown),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.notify(__("User ALT-S global shortcut to capture the entire VDE")),this._gui.bindKey("CTRL-S",()=>{if(html2canvas)return html2canvas(document.body).then(A=>this._gui.launch("Clipper",[A]))}),this.args&&1===this.args.length)return this.copycanvas(this.args[0])}copycanvas(A){return this.scene.height=A.height,this.scene.width=A.width,this.scene.getContext("2d").drawImage(A,0,0),this.dirty=!0}capture(A,e){return e&&this.hide(),this.load(new Promise((t,r)=>html2canvas(A).then(A=>(this.copycanvas(A),e&&this.show(),t())).catch((function(A){return r(__e(A))})))).then(()=>this.notify(__("Screen captured"))).catch(A=>this.error(A.toString(),A))}menu(){return[{text:"__(File)",nodes:[{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:A=>this.actionFile(A.data.item.data.dataid)}]}save(){return this.currfile.cache=this.scene.toDataURL("image/png"),this.currfile.write("base64").then(A=>(this.notify(__("File saved")),this.dirty=!1)).catch(A=>this.error(__("Cannot save to file: {0}",A.toString()),A))}actionFile(A){var e;switch(e=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(A=>{var e;return e=A.file.path.asFileHandle(),"file"===A.file.type&&(e=e.parent()),this.currfile.setPath(`${e.path}/${A.name}`),this.save(this.currfile)}),A){case this.name+"-Save":return this.currfile.basename?this.save():e();case this.name+"-Saveas":return e()}}cleanup(A){if(this.dirty)return A.preventDefault(),this.ask({title:__("Quit"),text:__("Quit without saving ?")}).then(A=>{if(A)return this.dirty=!1,this.quit()})}}).singleton=!0,this.OS.register("Clipper",A)}).call(this),A=this,e=function(){"use strict"; */var A,e;(function(){var A;(A=class extends this.OS.application.BaseApplication{constructor(A){super("Clipper",A)}main(){var A;if(this.scene=this.find("scene"),this.wrapper=this.find("wrapper"),this.cropwin=this.find("cropwin"),this.dirty=!1,this.currfile="Untitled".asFileHandle(),$(this.cropwin).css("position","absolute").hide(),this.find("btnCptScreen").onbtclick=()=>this.capture(document.body,!0),this.find("btnCptWindow").onbtclick=()=>{var A,e,t,r,n,B,s;for(e in s=[],n=OS.PM.processes)for(A=0,t=(B=n[e]).length;A<t;A++)r=B[A],0===OS.application[r.name].type&&s.push({text:r.scheme.apptitle,el:r.scheme,icon:r.meta().icon,iconclass:r.meta().iconclass});return this.openDialog("SelectionDialog",{title:"Select a window",data:s}).then(A=>{if(A)return this.capture(A.el)})},A=this.find("btnCrop"),this.cropselect=A=>{var e,t,r;return t=$(this.cropwin).offset(),r=A.clientX-t.left,e=A.clientY-t.top,$(this.cropwin).css("width",r+"px").css("height",e+"px")},this.cropup=e=>($(window).off("mousemove",this.cropselect),$(window).off("mouseup",this.cropup),this.ask({text:__("Crop the selected zone ?")}).then(e=>{var t,r,n,B,s,o,i,a;if(A.enable=!0,A.selected=!1,t=$(this.cropwin).offset(),s=$(this.scene).offset(),i=t.left-s.left,a=t.top-s.top,o=$(this.cropwin).width(),B=$(this.cropwin).height(),$(this.cropwin).hide(),$(this.cropwin).css("width","0px").css("height","0px"),e)return n=(r=this.scene.getContext("2d")).getImageData(i,a,o,B),this.scene.width=o,this.scene.height=B,r.putImageData(n,0,0),this.dirty=!0})),this.cropdown=e=>{var t;return A.enable=!1,t=$(this.scheme).offset(),$(this.cropwin).css("left",e.clientX-t.left+"px").css("top",e.clientY-t.top+"px").show(),$(window).off("mousedown",this.cropdown),$(window).mousemove(this.cropselect),$(window).mouseup(this.cropup)},A.onbtclick=()=>A.selected?$(window).mousedown(this.cropdown):$(window).off("mousedown",this.cropdown),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.notify(__("User ALT-S global shortcut to capture the entire VDE")),this._gui.bindKey("ALT-S",()=>{if(html2canvas)return html2canvas(document.body).then(A=>this._gui.launch("Clipper",[A]))}),this.args&&1===this.args.length)return this.copycanvas(this.args[0])}copycanvas(A){return this.scene.height=A.height,this.scene.width=A.width,this.scene.getContext("2d").drawImage(A,0,0),this.dirty=!0}capture(A,e){return e&&this.hide(),this.load(new Promise((t,r)=>html2canvas(A).then(A=>(this.copycanvas(A),e&&this.show(),t())).catch((function(A){return r(__e(A))})))).then(()=>this.notify(__("Screen captured"))).catch(A=>this.error(A.toString(),A))}menu(){return[{text:"__(File)",nodes:[{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:A=>this.actionFile(A.data.item.data.dataid)}]}save(){return this.currfile.cache=this.scene.toDataURL("image/png"),this.currfile.write("base64").then(A=>(this.notify(__("File saved")),this.dirty=!1)).catch(A=>this.error(__("Cannot save to file: {0}",A.toString()),A))}actionFile(A){var e;switch(e=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(A=>{var e;return e=A.file.path.asFileHandle(),"file"===A.file.type&&(e=e.parent()),this.currfile.setPath(`${e.path}/${A.name}`),this.save(this.currfile)}),A){case this.name+"-Save":return this.currfile.basename?this.save():e();case this.name+"-Saveas":return e()}}cleanup(A){if(this.dirty)return A.preventDefault(),this.ask({title:__("Quit"),text:__("Quit without saving ?")}).then(A=>{if(A)return this.dirty=!1,this.quit()})}}).singleton=!0,this.OS.register("Clipper",A)}).call(this),A=this,e=function(){"use strict";
/*! ***************************************************************************** /*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved. Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use Licensed under the Apache License, Version 2.0 (the "License"); you may not use

View File

@ -6,7 +6,7 @@
"author": "", "author": "",
"email": "" "email": ""
}, },
"version":"0.1.1-a", "version":"0.1.2-a",
"category":"Other", "category":"Other",
"iconclass":"fa fa-scissors", "iconclass":"fa fa-scissors",
"mimes":["none"], "mimes":["none"],

Binary file not shown.

View File

@ -90,7 +90,7 @@ class Clipper extends this.OS.application.BaseApplication
@bindKey "CTRL-S", () => @actionFile "#{@name}-Save" @bindKey "CTRL-S", () => @actionFile "#{@name}-Save"
@bindKey "ALT-W", () => @actionFile "#{@name}-Saveas" @bindKey "ALT-W", () => @actionFile "#{@name}-Saveas"
@notify __("User ALT-S global shortcut to capture the entire VDE") @notify __("User ALT-S global shortcut to capture the entire VDE")
@_gui.bindKey "CTRL-S", ()=> @_gui.bindKey "ALT-S", ()=>
return unless html2canvas return unless html2canvas
html2canvas(document.body).then (canvas) => html2canvas(document.body).then (canvas) =>
@_gui.launch "Clipper", [canvas] @_gui.launch "Clipper", [canvas]

View File

@ -6,7 +6,7 @@
"author": "", "author": "",
"email": "" "email": ""
}, },
"version":"0.1.1-a", "version":"0.1.2-a",
"category":"Other", "category":"Other",
"iconclass":"fa fa-scissors", "iconclass":"fa fa-scissors",
"mimes":["none"], "mimes":["none"],

View File

@ -50,7 +50,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Clipper/README.md", "description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Clipper/README.md",
"category": "Other", "category": "Other",
"author": "", "author": "",
"version": "0.1.1-a", "version": "0.1.2-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Clipper/build/release/Clipper.zip" "download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Clipper/build/release/Clipper.zip"
}, },
{ {