I have a script in which after processing an image I want the user to set the transparency of the currently selected layer. If I just pop a message to the user the tell the user to set transparency the user seems to make by selecting the wrong layer and setting transparency as well as blending modes of wrong layer.
To solve this problem I want to generate a UI dialogbox in which the user will be provided with a scroll/track bar using which the user an set transparency. Is this possible in any way in XTools?
Thank you,
Yogi Yang
UI question
UI question
While you can use xtools to construct rather complex UIs (see GenericUI and SampleUI), you really don't need it for simply presenting a scrollbar or slider.
The docs should have a simple example that should help you out.
-X
The docs should have a simple example that should help you out.
-X
UI question
Larry Ligon wrote:Here is an example of using scrollbars.
bb/viewtopic.php?t=659
Thanks Larry for the link and Xbytor for the tip.
But my problem is that I want to make the Scrollbar dynamic. meaning the user will drag on the scrollbar and the setting of the scorllbar will get applied to the underlying image in Photoshop in real time.
While the Dialogbox is open the user should not be able to break the script nor should the user be able to access anything in PS until he/she does not dismiss the dialgobox.
Hope I am making my point clear?
Thanks
bb/viewtopic.php?t=659
Thanks Larry for the link and Xbytor for the tip.
But my problem is that I want to make the Scrollbar dynamic. meaning the user will drag on the scrollbar and the setting of the scorllbar will get applied to the underlying image in Photoshop in real time.
While the Dialogbox is open the user should not be able to break the script nor should the user be able to access anything in PS until he/she does not dismiss the dialgobox.
Hope I am making my point clear?
Thanks
UI question
Here is another example that forces redraws.
bb/viewtopic.php?t=35
What do you mean set the transparency?
bb/viewtopic.php?t=35
What do you mean set the transparency?
UI question
If I understand what you are trying to do the code below is a mix of Larry's and Xbytor's examples that allow the user to only change a layer's opacity.
Code: Select allcTID = function(s) { return app.charIDToTypeID(s); };
waitForRedraw = function() {
var desc = new ActionDescriptor();
desc.putEnumerated(cTID("Stte"), cTID("Stte"), cTID("RdCm"));
executeAction(cTID("Wait"), desc, DialogModes.NO)
};
var WindowPositionX = 100;
var WindowPositionY = 100;
var WindowWidth = 400;
var WindowHeight = 400;
var bounds = {x:WindowPositionX ,y:WindowPositionX ,width:WindowWidth ,height:WindowHeight };
var dlg = new Window('dialog', 'Set Opacity' );
//Set the location of the dialog. Put it near the foreground box in the tools dialog
dlg.frameLocation = [100, 300];
var uiButtonRun = "Done";
var uiButtonNewWindow = "New Window";
dlg.btnRun = dlg.add("button", undefined ,uiButtonRun );
dlg.btnRun.onClick = function() { this.parent.close(0); };
dlg.orientation = 'column';
//Add panel
dlg.opctPanel = dlg.add("panel",undefined,"Opacity");
dlg.opctPanel.alignChildren = "right";
dlg.opctPanel.orientation = 'row';
dlg.opctPanel.opctSlider = dlg.opctPanel.add('scrollbar', undefined, activeDocument.activeLayer.opacity, 0, 100);
dlg.opctPanel.opctSlider.preferRedSize = [100,20];
dlg.opctPanel.opctValue = dlg.opctPanel.add('edittext');
dlg.opctPanel.opctValue.preferRedSize = [40,25];
dlg.opctPanel.opctValue.onChange = function (){
waitForRedraw();
if (!isNaN(dlg.opctPanel.opctValue.value)){
alert("Opacity value is not a valid number");}
};
dlg.opctPanel.opctValue.text = Math.round(dlg.opctPanel.opctSlider.value);
dlg.opctPanel.opctSlider.onChanging = function () {
dlg.opctPanel.opctValue.text = Math.round(dlg.opctPanel.opctSlider.value);
activeDocument.activeLayer.opacity = Math.round(dlg.opctPanel.opctValue.text);
waitForRedraw();
};
dlg.show();
Mike
Code: Select allcTID = function(s) { return app.charIDToTypeID(s); };
waitForRedraw = function() {
var desc = new ActionDescriptor();
desc.putEnumerated(cTID("Stte"), cTID("Stte"), cTID("RdCm"));
executeAction(cTID("Wait"), desc, DialogModes.NO)
};
var WindowPositionX = 100;
var WindowPositionY = 100;
var WindowWidth = 400;
var WindowHeight = 400;
var bounds = {x:WindowPositionX ,y:WindowPositionX ,width:WindowWidth ,height:WindowHeight };
var dlg = new Window('dialog', 'Set Opacity' );
//Set the location of the dialog. Put it near the foreground box in the tools dialog
dlg.frameLocation = [100, 300];
var uiButtonRun = "Done";
var uiButtonNewWindow = "New Window";
dlg.btnRun = dlg.add("button", undefined ,uiButtonRun );
dlg.btnRun.onClick = function() { this.parent.close(0); };
dlg.orientation = 'column';
//Add panel
dlg.opctPanel = dlg.add("panel",undefined,"Opacity");
dlg.opctPanel.alignChildren = "right";
dlg.opctPanel.orientation = 'row';
dlg.opctPanel.opctSlider = dlg.opctPanel.add('scrollbar', undefined, activeDocument.activeLayer.opacity, 0, 100);
dlg.opctPanel.opctSlider.preferRedSize = [100,20];
dlg.opctPanel.opctValue = dlg.opctPanel.add('edittext');
dlg.opctPanel.opctValue.preferRedSize = [40,25];
dlg.opctPanel.opctValue.onChange = function (){
waitForRedraw();
if (!isNaN(dlg.opctPanel.opctValue.value)){
alert("Opacity value is not a valid number");}
};
dlg.opctPanel.opctValue.text = Math.round(dlg.opctPanel.opctSlider.value);
dlg.opctPanel.opctSlider.onChanging = function () {
dlg.opctPanel.opctValue.text = Math.round(dlg.opctPanel.opctSlider.value);
activeDocument.activeLayer.opacity = Math.round(dlg.opctPanel.opctValue.text);
waitForRedraw();
};
dlg.show();
Mike
UI question
Larry Ligon wrote:What do you mean set the transparency?
By Transparency I mean setting the Opacity of the Active Layer.
By Transparency I mean setting the Opacity of the Active Layer.
UI question
Mike Hale wrote:If I understand what you are trying to do the code below is a mix of Larry's and Xbytor's examples that allow the user to only change a layer's opacity.
Mike
Thank you for putting (assembling) all necessary things together.
I have not tied this yet though. I am going to try it tonight on my personal PC.
Mike
Thank you for putting (assembling) all necessary things together.
I have not tied this yet though. I am going to try it tonight on my personal PC.