From f4c74abe46e17fd181926f2d9b1d8ff369cb703e Mon Sep 17 00:00:00 2001 From: yorch Date: Fri, 10 Apr 2015 17:24:12 -0700 Subject: [PATCH] Converted the CornerPinOffset tool to the new model --- ScriptUI Panels/yToolBox.jsx | 2 +- yScripts/y_CPOffset.jsx | 175 +++++++++++++++++++++++++++++++++++ yScripts/y_CornerPin.jsx | 108 --------------------- 3 files changed, 176 insertions(+), 109 deletions(-) create mode 100644 yScripts/y_CPOffset.jsx delete mode 100755 yScripts/y_CornerPin.jsx diff --git a/ScriptUI Panels/yToolBox.jsx b/ScriptUI Panels/yToolBox.jsx index 38115d1..4ca728f 100644 --- a/ScriptUI Panels/yToolBox.jsx +++ b/ScriptUI Panels/yToolBox.jsx @@ -1 +1 @@ -var scriptUIPanel = this; YTB = { info : { name : "yToolBox", ver : 0.5, status : "alpha", url : "yorchnet.com", description : "My mixed bag of tools" }, resources : { icon : new File('../yScripts/yNet.png'), header : new File('../yScripts/header.png') }, appearence : { buttonHeight : 30, buttonWidth : 126 }, tools : [], createUI : function createUI() { var res ="group\ {\ orientation:'column',\ alignment:['fill','fill'],\ margins:[0,0,0,0]\ header: Group\ {\ orientation:'column',\ alignment:['center','top'],\ margins:[0,0,0,0]\ title: Image\ {\ icon:'" + this.resources.header.path + '/' + this.resources.header.name + "',\ preferredSize: [175, 35]},\ ver: StaticText\ {\ text:'" + this.info.ver + "',\ alignment:['center','center']\ }\ desc: StaticText\ {\ text:'" + this.info.description + "',\ alignment:['center','center']\ },\ },\ main: Group\ {\ orientation:'column',\ alignment:['fill','fill'],\ alignChildren:['center','center'],\ },\ footer: Group\ {\ alignment:['center','bottom'], \ icn_app: Image {icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',preferredSize: [15, 18]},\ txt_info: StaticText { text:'"+ this.info.url + "', alignment:['fill','center'] },\ }, \ }"; this.window.grp = this.window.add( res ); this.window.layout.layout(true); this.customizeUI(); //EventHandlerAssignment this.window.onResize = this.resize; this.window.onClose = this.close; this.window.onDraw = this.autoLayout; }, customizeUI : function customizeUI() { var g = this.window.graphics; var orange = g.newBrush(g.BrushType.SOLID_COLOR, [1, .45, 0, 1]); this.window.grp.main.graphics.backgroundColor = orange; }, addTool : function addTool( aTool ) { /**** TO DO ****/ // Check that the tool object is unique. // Call for a window resize so it refreshes propperly. this.tools.push( aTool ); var btn = this.window.grp.main.add( aTool.btnLauyout ); btn.onClick = aTool.activate; btn.yTool = aTool; // add a reference to the tool so I can access info on it later... //alert(btn.onClick); this.window.layout.layout(true); }, //EVENT HANDLERS resize : function resize() { this.layout.resize(); }, close : function close() { YTB = null; delete this; }, init : function init() { this.window = ( scriptUIPanel instanceof Panel ) ? scriptUIPanel: new Window( "palette" , this.info.name , undefined, { resizeable : true } ); this.createUI(); } }; YTB.init(); #include "../yScripts/y_setStructure.jsx"; #include "../yScripts/y_colorProbe.jsx"; #include "../yScripts/y_BindBetween2.jsx"; #include "../yScripts/y_GenericNewScript.jsx"; \ No newline at end of file +var scriptUIPanel = this; YTB = { info : { name : "yToolBox", ver : 0.5, status : "alpha", url : "yorchnet.com", description : "My mixed bag of tools" }, resources : { icon : new File('../yScripts/yNet.png'), header : new File('../yScripts/header.png') }, appearence : { buttonHeight : 30, buttonWidth : 126 }, tools : [], createUI : function createUI() { var res ="group\ {\ orientation:'column',\ alignment:['fill','fill'],\ margins:[0,0,0,0]\ header: Group\ {\ orientation:'column',\ alignment:['center','top'],\ margins:[0,0,0,0]\ title: Image\ {\ icon:'" + this.resources.header.path + '/' + this.resources.header.name + "',\ preferredSize: [175, 35]},\ ver: StaticText\ {\ text:'" + this.info.ver + "',\ alignment:['center','center']\ }\ desc: StaticText\ {\ text:'" + this.info.description + "',\ alignment:['center','center']\ },\ },\ main: Group\ {\ orientation:'column',\ alignment:['fill','fill'],\ alignChildren:['center','center'],\ },\ footer: Group\ {\ alignment:['center','bottom'], \ icn_app: Image {icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',preferredSize: [15, 18]},\ txt_info: StaticText { text:'"+ this.info.url + "', alignment:['fill','center'] },\ }, \ }"; this.window.grp = this.window.add( res ); this.window.layout.layout(true); this.customizeUI(); //EventHandlerAssignment this.window.onResize = this.resize; this.window.onClose = this.close; this.window.onDraw = this.autoLayout; }, customizeUI : function customizeUI() { var g = this.window.graphics; var orange = g.newBrush(g.BrushType.SOLID_COLOR, [1, .45, 0, 1]); this.window.grp.main.graphics.backgroundColor = orange; }, addTool : function addTool( aTool ) { /**** TO DO ****/ // Check that the tool object is unique. // Call for a window resize so it refreshes propperly. this.tools.push( aTool ); var btn = this.window.grp.main.add( aTool.btnLauyout ); btn.onClick = aTool.activate; btn.yTool = aTool; // add a reference to the tool so I can access info on it later... //alert(btn.onClick); this.window.layout.layout(true); }, //EVENT HANDLERS resize : function resize() { this.layout.resize(); }, close : function close() { YTB = null; delete this; }, init : function init() { this.window = ( scriptUIPanel instanceof Panel ) ? scriptUIPanel: new Window( "palette" , this.info.name , undefined, { resizeable : true } ); this.createUI(); } }; YTB.init(); #include "../yScripts/y_setStructure.jsx"; #include "../yScripts/y_colorProbe.jsx"; #include "../yScripts/y_BindBetween2.jsx"; #include "../yScripts/y_CPOffset.jsx"; #include "../yScripts/y_GenericNewScript.jsx"; \ No newline at end of file diff --git a/yScripts/y_CPOffset.jsx b/yScripts/y_CPOffset.jsx new file mode 100644 index 0000000..86f210c --- /dev/null +++ b/yScripts/y_CPOffset.jsx @@ -0,0 +1,175 @@ +#include "../yScripts/y_JSExtensions.jsx"; +function YCPOffset() +{ + this.info = + { + name : "YCornerPinOffset", + version : 0.12, + stage : "development", + description : "Offsets each corner of a CornerPin Effect.", + url : "yorchnet.com" + }; + this.appearence = + { + buttonHeight : 30, + buttonWidth : 126 + }; + this.resources = + { + icon : new File('yNet.png'), + }; + this.init = function init() + { + + this.btnLauyout = + "button\ + {\ + preferredSize: ['" + this.appearence.buttonWidth + "','" + this.appearence.buttonHeight + "'],\ + text:'" + this.info.name + "',\ + helpTip:'" + this.info.description + "'\ + }"; + + this. res = + "window\ + {\ + type:'palette',\ + text:'" + this.info.name + ' ' + this.info.ver + ' ' + this.info.stage + "',\ + info: Group \ + {\ + alignment:['center','bottom'],\ + icon: Image \ + {\ + icon:'" + this.resources.icon.path + '/' + this.resources.icon.name + "',\ + preferredSize: [15, 18]\ + },\ + website: StaticText\ + {\ + text:'" + this.info.url + "',\ + alignment:['fill','center']\ + },\ + }\ + }"; + } + this.createUI = function createUI() + { + res = + "window {\ + resizeable : true\ + closeButton : true\ + text:'wtf'\ + }" + + this.window = new Window( res ); + this.window.layout.layout(true); + this.window.center(); + this.window.show(); + } + this.yMainFunction = function yMainFunction() + { + alert(this); + + //if called from the button as opposed as from the script. + if ( String(this) == "[object Button]" ) + { + this.yTool.processCornerPins(); + } + else + { + this.processCornerPins(); + } + + } + this.getSelectedCornerPins = function getSelectedCornerPins() + { + /* Function that returns a list of effect objects + that match any of the names + specified in validCornerPinNames. */ + validCornerPinNames = ["ADBE Corner Pin","CC Power Pin"]; + + selectedLayers = app.project.activeItem.selectedLayers; + cornerPins = []; + for (layer=0;layer