Skip to content

Commit

Permalink
Improve windows handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliepse committed Sep 16, 2017
1 parent 965b35c commit 8ea0fff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion dist/explode_shape_layer.jsx

This file was deleted.

1 change: 1 addition & 0 deletions dist/explode_shape_layer.min.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +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);
23 changes: 16 additions & 7 deletions explode_shape_layer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,34 @@ function createUI(thisObj) {
if(thisObj instanceof Panel) {

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

btn.onClick = function() {
explodeLayer( app.project.activeItem.selectedLayers );
}
} else {

return myPanel;
var myPanel = new Window('palette', configs.title, undefined, {
resizeable : true,
});
myPanel.show();

} else {
}

explodeLayer( app.project.activeItem.selectedLayers );
var btn = myPanel.add("button", [10, 10, 100, 30], "Explode layer");

myPanel.text = configs.title;
myPanel.bounds.width = 120;
myPanel.bounds.height = 40;

btn.onClick = function() {
explodeLayer( app.project.activeItem.selectedLayers );
}

return myPanel;

}

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

var configs = {
title: 'Explode layer tool',
log : false,
};

Expand Down

0 comments on commit 8ea0fff

Please sign in to comment.