OmniDialogMaker

I was hoping that someone can tell me where you put the OmniDialogMaker script. I was hoping that place in my way of scripts, then by restarting Photoshop can run the script for those who need this script library would be working, unfortunately, no?

It looks like a file, you can include in a script that you write that will use the function in the included file.  All I see are a few variables and functions not code to do anything.

Use an include statement

@include "ominoDialogMaker.jsx".

var D_MARGIN = 4;

var D_CONTROLHEIGHT = 18;

var D_BUTTONWIDTH = 96;

var D_CONTROLLABELWIDTH = 84;

var D_CONTROLWIDTH = 100;

var D_DIALOG_WIDTH = 1 * D_MARGIN + D_CONTROLLABELWIDTH + D_CONTROLWIDTH;

var S2 = 1.41421356237309504880;

Create a rectangle for a new control, walking down.

function _odControlShared (label, name)

{

OD = this;

var y = od.curYPos;

itemHeight var = D_CONTROLHEIGHT;

var itemBump = itemHeight + D_MARGIN;

If (label! = "")

label += ":";

var labelCtl = od.w.add ("statictext', [D_MARGIN, y, D_MARGIN + D_CONTROLLABELWIDTH, y + itemHeight], label");

labelCtl.justify = 'right ';

var controlBox = new Object();

controlBox.left = D_MARGIN + D_CONTROLLABELWIDTH + D_MARGIN;

controlBox.top = y;

controlBox.right = controlBox.left + D_CONTROLWIDTH;

controlBox.bottom = controlBox.top + itemHeight;

od.curYPos = controlBox.bottom + D_MARGIN;

return controlBox;

}

function _odControlSharedFinish (control, tname, valueFieldName)

{

oD = this;

oD.items [tname] = control;

oD.itemValueFieldNames [tname] = valueFieldName;

oD.itemNames [oD.itemNames.length] = tNom;

}

function _odNumber (label, tname, value)

{

oD = this;

controlBox var = oD._odControlShared (label, tname);

var control = oD.w.add ('edittext', controlBox, value);

Control.value = value;

control.onChange = function() {this.value = (this.text) * 1.0; this.text = this.value ;};}  make accessible all the .value

oD._odControlSharedFinish (control, tname, "text");

Returns the control;

}

function _odText (label, tname, value)

{

oD = this;

controlBox var = oD._odControlShared (label, tname);

var control = oD.w.add ('edittext', controlBox, value);

Control.value = value;

control.onChange = function() {this.value = this.text ;};}  make accessible all the .value

oD._odControlSharedFinish (control, tname, "text");

Returns the control;

}

function _setColorFromButton (victim, button)

{

var g = victim.graphics;

var n = button.value;

var g.newBrush (g.BrushType.SOLID_COLOR, n) = myBrush;

g.backgroundColor = myBrush;

}

/*

the color values are table of three tanks, 0,0... 1.0.

*/

function _odColor (label, tname, color)

{

oD = this;

controlBox var = oD._odControlShared (label, tname);

var swatchBox = [controlBox.left + 40, controlBox.top, controlBox.right, controlBox.bottom];

var buttonBox = [controlBox.left, controlBox.top, + 30 controlBox.left, controlBox.bottom];

Swatch var = oD.w.add ('group', swatchBox);

var button = oD.w.add ('button', buttonBox);

Button.Swatch = swatch;

Button.Value = color;

button.onClick = function() {}

var n = doColorPicker (this.value);

This.Value = n;

_setColorFromButton (Swatch, this);

};

_setColorFromButton (Swatch, Button);

oD._odControlSharedFinish (button, tname, "value");

Back button;

}

/*

Add a button and static text in the dialog box;

the button refers to the text "nameCtl."

and .filePrompt and .fileExtension.

*/

function _odFileCommon(label,tname,path,prompt,extension)

{

controlBox var = oD._odControlShared (label, tname);

buttonWidth var = 10;

var buttonBox = [controlBox.left, controlBox.top, controlBox.left + buttonWidth, controlBox.bottom];

var nameBox = [controlBox.left + buttonWidth + 10, controlBox.top, D_DIALOG_WIDTH, controlBox.bottom];

var f = new File (path);

var nameCtl = oD.w.add ('statictext', nameBox);

var button = oD.w.add ('button', buttonBox, '...');

button.nameCtl = nameCtl;

nameCtl.text = f.name;

Button.Value = f.fsName;

Button.file = f;

prompt = button.filePrompt;

button.fileExtension = extension;

oD._odControlSharedFinish (button, tname, "value");

button.onChange = function()

{

This.file = new queue (this.value);

this.nameCtl.text = this.file.name;

}

Back button;

}

function _odOpenFile(label,tname,path,prompt,extension)

{

oD = this;

var buttonCtl is _odFileCommon(label,tname,path,prompt,extension);.

buttonCtl.onClick = function() {}

var f = this.file.openDlg (this.filePrompt);

If (f)

{

This.file = f;

This.Value = f.fsName;

this.nameCtl.text = f.name;

}

};

ButtonCtl return;

}

function _odSaveFile(label,tname,path,prompt,extension)

{

oD = this;

var buttonCtl is _odFileCommon(label,tname,path,prompt,extension);.

buttonCtl.onClick = function() {}

var f = this.file.saveDlg (this.filePrompt);

If (f)

{

This.file = f;

This.Value = f.fsName;

this.nameCtl.text = f.name;

}

};

ButtonCtl return;

}

function _odSelectFolder(label,tname,path,prompt,extension)

{

oD = this;

var buttonCtl is _odFileCommon(label,tname,path,prompt,extension);.

buttonCtl.folder = new Folder (path); file, pls, no files

buttonCtl.nameCtl.text += ' / ';.

buttonCtl.onClick = function() {}

var f = this.folder.selectDlg (this.filePrompt);

If (f)

{

This.Folder = f;

This.Value = f.fsName;

f.name = this.nameCtl.text + ' / ';.

}

};

ButtonCtl return;

}

function _odCheckbox(label,tname,value,checkboxText)

{

oD = this;

controlBox var = oD._odControlShared (label, tname);

var control = oD.w.add ('checkbox', controlBox, checkboxText);

Control.value = value;

control.onChange = function() {this.value = this.text ;};}

oD._odControlSharedFinish (control, tname, "value");

Returns the control;

}

function _odRadioButtons(label,tname,value,radioChoices)

{

var oD = this;

controlBox = oD ._odControlShared (label, tname);

itemHeight var = controlBox.bottom - controlBox.top;

result = oD.w.add ('edittext', controlBox, value); field of hidden text for fight against it...

result.onChange = function() {}

var i;

This.Value = this.text;

for (i = 0; i< this.buttons.length;="">

{

var button = this.buttons [i];

Button.Value = (button.theChoice == this.text);

}

}

result. Hide();

result.value = value;

result. Buttons = new Array();

var i;

for (i = 0; i< radiochoices.length;="">

{

choice of var = radioChoices [i];

If (i > 0)

{

var bump = itemHeight + D_MARGIN;

controlBox.top += bump;

controlBox.bottom += bump;

oD.curYPos += bump;

}

each object radiobutton pokes his choice in the control of the ersatz,

It looks like a simple value.

("Bundling" seems to be by adjacent additions only. Nice!)

var rb = oD.w.add ('radiobutton', controlBox, choice);

RB. Value = choice == value;

rb.theChoice = choice;

rb.theGroupErsatzControl = result;

rb.onClick = function() {this.theGroupErsatzControl.value = this.theChoice ;};}

result. Buttons [result. Buttons.Length] = rb;

}

oD._odControlSharedFinish (result, tname, "text");

return the result;

}

function _odMenu(label,tname,value,menuChoices)

{

var oD = this;

controlBox = oD ._odControlShared (label, tname);

itemHeight var = controlBox.bottom - controlBox.top;

var control = oD.w.add ('dropdownlist', controlBox, menuChoices);

I could not discern how to get this from the "items" table, so I hide menuChoice for later. dvb08.

control.menuChoices = menuChoices;

Control.value = value;

Set the index of the initial selection

var index = 0;

for (var i = 0; i)< menuchoices.length;="">

{

if(value == menuChoices[i])

index = i;

}

Control.Selection = index;

control.onChange = function() {}

This.Value = this.selection.text;

} / / make accessible all the .value

oD._odControlSharedFinish (control, tname, "value");

}

function _odSectionLabel (label)

{

var oD = this;

var B2 = new Object();

B2. Left = D_MARGIN;

B2. Top = oD.curYPos;

B2. Right = b2.left + D_DIALOG_WIDTH;

B2. Bottom = b2.top + D_CONTROLHEIGHT;

oD.curYPos += D_CONTROLHEIGHT + D_MARGIN;

oD.w.add ("statictext", b2, label + ':', {multiline: true});

}

function _odBoxedText (lines, text)

{

var oD = this;

var width = D_DIALOG_WIDTH;

var height = lines * 15;

var B2 = new Object();

var b = new Object();

b.Top = oD.curYPos;

b.Bottom = b.top + height + 2 * D_MARGIN;

b.Left = D_MARGIN;

b.Right = b.left + width;

oD.curYPos = b.bottom + D_MARGIN;

var Panel = oD.w.add ('panel', b);

B2. Left = D_MARGIN;

B2. Top = D_MARGIN;

B2. Right = b2.left + width - 2 * D_MARGIN;

B2. Bottom = b2.top + height;

Panel.Add('statictext',B2,text,{Multiline:true});)

}

function _odSeparator()

{

var oD = this;

var height = oD.groupGap;

var barWidth = oD.ominoDialogWidth;

If (barWidth)

{

var b = new Object();

b.Top = oD.curYPos + height / 2;

b.top = b.Bottom;

b.Left = D_MARGIN;

b.Right = b.left + barWidth;

var Layer10value = 2;

b.Top = Layer10value / 2;

b.Bottom = b.top + Layer10value;

oD.w.add ('panel', b);

}

oD.curYPos += height;

}

function _odAppendGap()

{

oD = this;

oD.curYPos += oD.groupGap;

}

function appendOKCancel (oD)

{

var y = oD.curYPos;

var cancelRect = new Object();

var okRect = new Object();

cancelRect.left = D_MARGIN

cancelRect.top = y;

cancelRect.right = cancelRect.left + D_BUTTONWIDTH;

cancelRect.bottom = cancelRect.top + D_CONTROLHEIGHT;

okRect.left = cancelRect.right + D_MARGIN + D_MARGIN;

okRect.top = y;

okRect.right = okRect.left + D_BUTTONWIDTH;

okRect.bottom = okRect.top + D_CONTROLHEIGHT;

Implement the button apply or OK/Cancel-button

If (OD.isPalette)

{

var applyBtn = oD.w.add ('button', cancelRect, 'Apply');

applyBtn.oD = oD;

applyBtn.onClick = function() {}

oD var = this.oD;

var result = oD.get ();

oD.paletteCallback (result, oD.paletteCallbackArg2);

};

}

on the other

{

var cancelBtn = oD.w.add('button',cancelRect,'Cancel',{name:'cancel'});)

var okBtn = oD.w.add('button',okRect,'OK',{name:'ok'});)

cancelBtn.oD = oD;

cancelBtn.onClick = function() {this.oD.w.close (0) ;};}  0 on cancel

okBtn.theDialog = oD;

okBtn.onClick = function() {this.theDialog.w.close (1) ;};} 1 OK

}

oD.curYPos = okRect.bottom + D_MARGIN;

}

function trimDialogBounds (oD)

{

var xMax = 20;

var yMax = 20;

var n = oD.w.children.length;

var i;

for (i = 0; i< n;="">

{

aenfant var = od.w.children [i];

var aChildBounds = aChild.bounds;

if(aChildBounds.Right > Xmax)

xMax = aChildBounds.right;

if(aChildBounds.Bottom > ymax)

yMax = aChildBounds.bottom;

}

OD.w.Bounds.Right = od.w.bounds.left + xMax + D_MARGIN;

OD.w.Bounds.Bottom = od.w.bounds.top + yMax + D_MARGIN;

actually allow background discontinuities.

OD.w.Bounds.Bottom = od.curYPos + od.w.bounds.top;

}

/**

* The optional arguments of the 2nd, 3rd and 4th make a range instead of a modal dialog box. The reminder

* is called whenever you click Apply (you get a button apply instead of OK/Cancel)

*/

function newOminoDialog (tname, existingPanel, paletteCallback, paletteCallbackArg2)

{

If you switch to something other than a sign, none can use.

If (!) () existingPanel instanceof Panel))

existingPanel = null;

var isPalette = (existingPanel | paletteCallback)? 1: 0;

var type = isPalette? "palette": "dialogue."

var oD = new Object();

oD.w = existingPanel? existingPanel: New Window (kind, tname, [100,100,500,500]);

oD.isPalette = isPalette;

oD.paletteCallback = paletteCallback;

oD.paletteCallbackArg2 = paletteCallbackArg2;

oD.curYPos = D_MARGIN;

oD.groupGap = 12;

oD.itemNames = new Array();

oD.item

oD.items = new Array();

oD.itemValueFieldNames = new Object(); to search a value in the dialog field appropriate to each control, such as 'text' or 'value '.

oD.ominoDialogWidth = D_DIALOG_WIDTH;

oD.gap = _odAppendGap;

oD.number = _odNumber;

oD.string = _odText;

oD.radioButtons = _odRadioButtons;

oD.checkbox = _odCheckbox;

oD.sectionLabel = _odSectionLabel;

oD.separator = _odSeparator;

oD.boxedText = _odBoxedText;

oD.color = _odColor;

oD.openFile = _odOpenFile;

oD.selectFolder = _odSelectFolder;

oD.saveFile = _odSaveFile;

oD.menu = _odMenu;

oD.set = _odSet;

oD.run = _odRun;

oD.get = _odGet;

oD._odControlShared = _odControlShared;

oD._odControlSharedFinish = _odControlSharedFinish;

return the oD;

}

function _odGet()

{

var values = new Object();

tNom var;

for (tNom in this.items)

{

var value = this.items [tname] .value;

values [tname] = value;

}

return values;

}

function _odSet (values)

{

var oD = this;

if(!values)

return;

for var p in values

{

var value = [p] values;

var point = oD.items [p];

If (!) Item)

continue;

var itemValueFieldName = oD.itemValueFieldNames [p];

If (itemValueFieldName)

{

agenda [itemValueFieldName] = value;

If (Item.OnChange)

item.onChange ();

Item.Notify ('onChange'); to get the update

}

}

}

/**

* Can be run as a modal dialog, OR as a current palette box.

* As a dialog box, nothing happens until OK or Cancel is selected. OK,.

* the parameters are returned.

* To be a palette, pass a function and an arg. The function will be

* being called (resultParams, yourArg).

*/

function _odRun()

{

var oD = this;

If (!) OD.finishingTouches)

{

oD.separator (oD);

oD.gap ();

appendOKCancel (oD);

oD.gap ();

trimDialogBounds (oD);

oD.finishingTouches = true;

}

If (OD.w instanceof Window)

{

resultCode var = oD.w.show ();

If (resultCode! = 1) / / cancel

Returns a null value.

var result = oD.get ();

return the result;

}

on the other

Returns a null value.

}

function objectToString (o)

{

if(!o)

Return ' ';

var s = "";

var i;

for (tNom in o)

s += tNom '=' + o [tname] + "\n";

return s;

}

var gExampleSettings = null;

function example (thisObj)

{

var host = app;

the 2 last arguments are making modeless and give you a button APPLY instead of OK and CANCEL.

This works in AE and Illustrator, but on Photoshop. I have not tried the rest...

var d = newOminoDialog ("Omino sample dialogue:" + $host.name, thisObj, function (a, b) {alert ("result\n" + objectToString (a)) ;});})

Comment on the above and use it for photoshop, to be modal:

var d = newOminoDialog ("Omino sample dialogue:" + $host.name);

d.boxedText (9, "It's an example of a dialogue built with ominoDialogMaker.jsx\n"

+ "host:" + $host.name + ""+ host.version + "\n";

+ "\n"

+ "© 2007-2012 [email protected]«,»»

D_DIALOG_WIDTH);

d.Separator ();

d.sectionLabel ("types of controls");

d.Number ("number:", 'h', 11.23);

d.CheckBox ("Checkbox X", "x", true, "to check");

d.String ("Text", "T", "Enter here");

d.openFile ("A file", "f","","open", "" jpg");

d.radioButtons (One","r","red", ["red","maroon","scarlet "," crimson"]) to choose";

var result;

d.Set (gExampleSettings);

var result = d.run ();

If (result! = null)

{

gExampleSettings = result;

var s = "Result Values\n";

s += objectToString (result);

alert (s);

}

}

/*

Easy to use ExtendScript progress bar.

Written by [email protected], 2007

Enjoy, but this credit must stay intact.

use:

var pb = progressBar ("main title", "subtitle");

pb.setValue (valueFrom0to1);

pb.setTitle2 ("new display of subtitles!")

If (PB.isCanceled ())

PB. Close(); they clicked on cancel

*/

progressBar (title1, title2) function

{

var result = new Object();

result. Running = true;

result.p = new Window ("range");

result.p.orientation = "column";

result.p.alignChildren = 'left ';

result. T1 = result.p.add ("statictext", undefined, title1);

result. T2 = result.p.add ("statictext", undefined, title2);

result.b = result.p.add ("progressbar");

result.c = result.p.add ("button", undefined, "Cancel");

result.c.onClick = function() {}

result. Running = false;

}

result.isRunning = function() {return this.running ;}

result.isCanceled = function() {return! this.isRunning () ;}}

result.setValue = Function {this.b.value = x * 100; this.p.update () ;}

result.setTitle1 = function (t1) {this.t1.text = t1 ;}

result.setTitle2 = function (t2) {this.t2.text = t2 ;}

result. Close = function() {this.p.close (;})

result.p.Show ();

return the result;

}

/*

a routine kind of stupid to show the inside of an object in alert al.

You know, for debugging.

*/

function alertObj (o, title)

{

if(!title)

title = "";

var s = title + "\n";

var k;

if(!o)

s += "(objet null)"; "

on the other

s += objectToString (o);

alert (s);

}

Tags: Photoshop

Similar Questions

Maybe you are looking for