Skip to content

Commit 8ea0fff

Browse files
committed
Improve windows handler
1 parent 965b35c commit 8ea0fff

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

dist/explode_shape_layer.jsx

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/explode_shape_layer.min.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
function explodeLayer(e){if(consLog("==============\n=============="),e.length>1)alert("Select a single shape layer");else{var o=e[0];if(void 0!=o&&"ADBE Vector Layer"===o.matchName)for(var r=o.containingComp,t=o.property("Contents"),p=1;p<=t.numProperties;p++){var a=t.property(p);if(a.enabled){var c=r.layers.addShape();c.name=a.name,copyLayerTransform(o,c),insertPropertyToContents(a,c.property("Contents"),"")}}else alert("Select a shape layer")}}function insertPropertyToContents(e,o,r){if(!o.canAddProperty(e.matchName))return!1;for(var t=o.addProperty(e.matchName),p=1;p<=e.numProperties;p++){var a=e.property(p);if(a.enabled&&t.canAddProperty(a.matchName)){consLog(r+a.matchName);var c=t.property(a.matchName)?t.property(a.matchName):t.addProperty(a.matchName);switch(a.matchName){case"ADBE Vector Filter - Merge":case"ADBE Vector Materials Group":consLog(r+"-- skipped");break;case"ADBE Vector Graphic - Stroke":copyPropertyStroke(a,c);break;case"ADBE Vector Graphic - Fill":copyPropertyFill(a,c);break;case"ADBE Vector Transform Group":copyPropertyTransform(a,c);break;case"ADBE Root Vectors Group":case"ADBE Vectors Group":case"ADBE Vector Group":insertPropertyToContents(a,t,r+=" ");break;case"ADBE Vector Shape - Group":copyPropertyShape(a,c);break;default:c.setValue(a.value)}}}}function copyProperty(e,o,r){r[e].setValue(o[e].value)}function copyPropertyShape(e,o){o.property("ADBE Vector Shape").setValue(e.property("ADBE Vector Shape").value)}function copyPropertyStroke(e,o){copyProperty("composite",e,o),copyProperty("color",e,o),copyProperty("strokeWidth",e,o),copyProperty("lineCap",e,o),copyProperty("lineJoin",e,o),copyProperty("miterLimit",e,o)}function copyPropertyFill(e,o){copyProperty("composite",e,o),copyProperty("fillRule",e,o),copyProperty("color",e,o)}function copyPropertyTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("skew",e,o),copyProperty("skewAxis",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function copyLayerTransform(e,o){copyProperty("anchorPoint",e,o),copyProperty("position",e,o),copyProperty("scale",e,o),copyProperty("rotation",e,o),copyProperty("opacity",e,o)}function createUI(e){if(e instanceof Panel)var o=e;else(o=new Window("palette",configs.title,void 0,{resizeable:!0})).show();var r=o.add("button",[10,10,100,30],"Explode layer");return o.text=configs.title,o.bounds.width=120,o.bounds.height=40,r.onClick=function(){explodeLayer(app.project.activeItem.selectedLayers)},o}function consLog(e){configs.log&&$.writeln(e)}var configs={title:"Explode layer tool",log:!1},myToolsPanel=createUI(this);

explode_shape_layer.jsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,25 +178,34 @@ function createUI(thisObj) {
178178
if(thisObj instanceof Panel) {
179179

180180
var myPanel = thisObj;
181-
var btn = myPanel.add("button", [10, 10, 100, 30], "Explode layer");
182181

183-
btn.onClick = function() {
184-
explodeLayer( app.project.activeItem.selectedLayers );
185-
}
182+
} else {
186183

187-
return myPanel;
184+
var myPanel = new Window('palette', configs.title, undefined, {
185+
resizeable : true,
186+
});
187+
myPanel.show();
188188

189-
} else {
189+
}
190190

191-
explodeLayer( app.project.activeItem.selectedLayers );
191+
var btn = myPanel.add("button", [10, 10, 100, 30], "Explode layer");
192+
193+
myPanel.text = configs.title;
194+
myPanel.bounds.width = 120;
195+
myPanel.bounds.height = 40;
192196

197+
btn.onClick = function() {
198+
explodeLayer( app.project.activeItem.selectedLayers );
193199
}
194200

201+
return myPanel;
202+
195203
}
196204

197205
function consLog(text) { if (configs.log) $.writeln(text); }
198206

199207
var configs = {
208+
title: 'Explode layer tool',
200209
log : false,
201210
};
202211

0 commit comments

Comments
 (0)