mirror of
https://github.com/jorgevasquezp/AFX_yTools.git
synced 2026-08-16 15:30:59 +00:00
Now the button calls to a reference of the tool from this.yTool, to be able to access its methods
This commit is contained in:
+77
-46
@@ -1,43 +1,71 @@
|
||||
yColorProbe_data = new Object();
|
||||
|
||||
yColorProbe_data.scriptName = 'yColorProbe';
|
||||
yColorProbe_data.scriptDesc = 'Creates a Null that will Sample the selected layer within the specified radius.';
|
||||
yColorProbe_data.scriptVer = '0.2a';
|
||||
yColorProbe_data.webLink = 'yorchnet.com';
|
||||
|
||||
//if yToolBox Exists add it to its tool list.
|
||||
if (typeof(YTB)!=='undefined'){
|
||||
YTB.tools.push(yColorProbe_data);
|
||||
|
||||
//it should be called from toolbox.
|
||||
/* yColorProbe_data.buttonWidth=76;
|
||||
yColorProbe_data.buttonHeight=30;
|
||||
*/
|
||||
yColorProbe_data.btnLayout = "btn_"+yColorProbe_data.scriptName+": Button { preferredSize: ['"+ YTB.buttonWidth+"','"+ YTB.buttonHeight+"'], text:'"+yColorProbe_data.scriptName+"', helpTip:'"+yColorProbe_data.scriptDesc+"' }";
|
||||
|
||||
}
|
||||
|
||||
yColorProbe_data.res = "window { \
|
||||
type:'palette' , text:'"+yColorProbe_data.scriptName+' '+yColorProbe_data.scriptVer+"',\
|
||||
\
|
||||
\
|
||||
info: Group { \
|
||||
alignment:['center','bottom'], \
|
||||
icon: Image {preferredSize: [15, 18]},\
|
||||
website: StaticText { text:'"+yColorProbe_data.webLink+"', alignment:['fill','center'] },\
|
||||
}\
|
||||
\
|
||||
}";
|
||||
|
||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
||||
// MAIN SCRIPT GOES HERE.
|
||||
|
||||
#include "../yScripts/y_JSExtensions.jsx";
|
||||
#include "usefulFunctions.jsx";
|
||||
|
||||
function yColorProbe(){
|
||||
//It works with Sampled layers at a 100% scale only.
|
||||
app.beginUndoGroup('Create ColorProbe');
|
||||
function YColorProbe()
|
||||
{
|
||||
this.info =
|
||||
{
|
||||
name : "yColorProbe",
|
||||
version : 0.0,
|
||||
stage : "development",
|
||||
description : "Creates a Null that will Sample the selected layer within the specified radius.",
|
||||
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.getInfo = function getInfo( )
|
||||
{
|
||||
alert("asdasdasd");
|
||||
}
|
||||
this.createUI = function createUI()
|
||||
{
|
||||
this.window = new Window ( this.res );
|
||||
this.window.show() ;
|
||||
}
|
||||
this.yMainFunction = function yMainFunction()
|
||||
{
|
||||
app.beginUndoGroup(this.yTool.info.name); // yTool is a refernece to the Tool object, because THIS in this context returns the ButtonObject....
|
||||
|
||||
//It works with Sampled layers at a 100% scale only.
|
||||
try
|
||||
{
|
||||
sel = app.project.activeItem.selectedLayers[0];
|
||||
@@ -70,20 +98,23 @@ function yColorProbe(){
|
||||
if(sel!==undefined){
|
||||
myNull("Effects")('sampledLayer')(1).setValue(sel.index);
|
||||
}
|
||||
|
||||
app.endUndoGroup();
|
||||
return 'ok'
|
||||
}
|
||||
|
||||
//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------//--------
|
||||
this.activate = this.yMainFunction;
|
||||
|
||||
function build_yColorProbe_data_UI(){
|
||||
yColorProbe_data.window = new Window ( yColorProbe_data.res);
|
||||
yColorProbe_data.window.show();
|
||||
this.init();
|
||||
return this;
|
||||
}
|
||||
yColorProbe_data.activate =yColorProbe ;
|
||||
|
||||
//CHECKS that the toolbox exists, and if it doesn´t it runs the script on its own.
|
||||
if (typeof(YTB)=='undefined'){
|
||||
yColorProbe_data.activate();
|
||||
}else{
|
||||
if (typeof(YTB)=='undefined')
|
||||
{
|
||||
yColorProbe = new YColorProbe();
|
||||
yColorProbe.activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
YTB.addTool(new YColorProbe());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user