Skip to content

Commit

Permalink
v4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
TomByrne committed Dec 5, 2017
1 parent 6d7d604 commit 7732962
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 61 deletions.
12 changes: 9 additions & 3 deletions SmartCore/DocUtils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@



DocUtils.copyDocument = function(docRef, artboard, artboardRect, w, h, doInnerPadding, layerCheck, layerDepths, outlineText, ungroup, layerVis, ignoreWarnings, hasBoundErrorRef, offset, colorSpace) {
DocUtils.copyDocument = function(docRef, artboard, artboardRect, w, h, doInnerPadding, layerCheck, layerDepths, outlineText, ungroup, layerVis, ignoreWarnings, hasBoundErrorRef, offset, colorSpace, rasterResolution) {
if(w<1)w = 1;
if(h<1)h = 1;
var preset = new DocumentPreset();
preset.width = w;
preset.height = h;
preset.units = docRef.rulerUnits;

if(rasterResolution == "screen"){
preset.rasterResolution = DocumentRasterResolution.ScreenResolution;
}else if(rasterResolution == "medium"){
preset.rasterResolution = DocumentRasterResolution.MediumResolution;
}else{
preset.rasterResolution = DocumentRasterResolution.HighResolution;
}

if(colorSpace == "cmyk"){
preset.colorMode = DocumentColorSpace.CMYK;

}else if(colorSpace == "rgb"){
preset.colorMode = DocumentColorSpace.RGB;

}else{
preset.colorMode = docRef.documentColorSpace;
}
Expand Down
5 changes: 3 additions & 2 deletions SmartCore/ExportSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
artboardAll_layers:true,
artboardInd_layers:[],

symbolAll:true,
symbolAll:false,
symbolNames:[],

elementPaths:[], // e.g. ["layerInd : rootElemInd : childElemInd", "layerInd : rootElemInd : childElemInd"]
Expand Down Expand Up @@ -263,8 +263,9 @@
if(this.symbolNames.length){
this.symbolNames = this.symbolNames.split(",");
this.symbolAll = false;

}else if(xml.symbolAll.length()==0){
this.symbolAll = true;
this.symbolAll = false;
}
}

Expand Down
2 changes: 1 addition & 1 deletion SmartCore/Exporter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}
this.updateProgress(++this.num_exported, this.num_to_export);
this.updatedExportItem(item);
$.sleep(40) // Allows UI update;
//$.sleep(40) // Allows UI update;
}

if(copyDoc/* && copyDoc!="skipped" && copyDoc!="failed"*/){
Expand Down
70 changes: 60 additions & 10 deletions SmartCore/FormatPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
this.formatChooser = new pack.Dropdown(column, formatNames);
this.formatChooser.setSelection(0);
this.formatChooser.onChange = function(){
if(scopedThis.ignoreChanges) return;
if(scopedThis.formatChooser.selection > 0){
scopedThis.addFormatItem(formats[scopedThis.formatChooser.selection - 1]);
scopedThis.formatChooser.selection = 0;
scopedThis.formatChooser.setSelection(0);
scopedThis.formatList.selection = scopedThis.formatList.items.length-1;
if(scopedThis.onFormatsChanged)scopedThis.onFormatsChanged();
}
Expand All @@ -50,6 +51,7 @@
{numberOfColumns: 1, showHeaders: false, multiselect:false,
columnTitles: ['Format'] });
this.formatList.onChange = function(){
if(scopedThis.ignoreChanges) return;
if(scopedThis.formatList.selection===null){
scopedThis.formatList.selection = scopedThis.currentIndex;
}else{
Expand All @@ -72,26 +74,23 @@
this.activeCheckBox.value = false;
this.activeCheckBox.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP];
this.activeCheckBox.enabled = false;
//this.activeCheckBox.size = [ 180,20 ];
this.activeCheckBox.size = [ 290,20 ];
this.activeCheckBox.onClick = function(){
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.active = scopedThis.activeCheckBox.value;
scopedThis.onFormatsChanged();
scopedThis.checkSettingsActive(scopedThis.currentFormatSettings);
}

// scaling row
var scalingRow = this.formatColumn.add('group', undefined, '')
scalingRow.orientation = 'row';
scalingRow.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP];

this.scalingLabel = scalingRow.add('statictext', undefined, 'Scaling:');
this.scalingLabel.size = [100, 22];
this.scalingLabel = activeRow.add('statictext', undefined, 'Scaling:');
//this.scalingLabel.size = [100, 22];
this.scalingLabel.enabled = false;

this.scalingInput = scalingRow.add('edittext', undefined, "");
this.scalingInput = activeRow.add('edittext', undefined, "");
this.scalingInput.size = [ 50,20 ];
this.scalingInput.enabled = false;
this.scalingInput.onChange = function(){
if(scopedThis.ignoreChanges) return;
var scaling = parseFloat( scopedThis.scalingInput.text.replace( /\% /, '' ));

if(scaling){
Expand Down Expand Up @@ -140,10 +139,38 @@
}
this.colorSpaceList.setItems(colorList);
this.colorSpaceList.onChange = function() {
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.colorSpace = scopedThis.colorSpaceOptions[scopedThis.colorSpaceList.selection].key;
if(scopedThis.onFormatsChanged) scopedThis.onFormatsChanged();
};

// raster resolution row
var rasterResRow = this.formatColumn.add('group', undefined, '')
rasterResRow.orientation = 'row';
rasterResRow.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP];

this.rasterResLabel = rasterResRow.add('statictext', undefined, 'Raster Resolution:');
this.rasterResLabel.size = [100, 22];
this.rasterResLabel.enabled = false;
this.rasterResLabel.alignment = [ScriptUI.Alignment.RIGHT, ScriptUI.Alignment.CENTER];

this.rasterResOptions = [/*{name:"Same as Document", key:null},*/ {name:"High", key:"high"}, {name:"Medium", key:"medium"}, {name:"Screen (Low)", key:"screen"}];

this.rasterResList = new pack.Dropdown(rasterResRow);
this.rasterResList.setEnabled(false);
this.rasterResList.setSize(290,20);
var rasterResList = [];
for(var i=0; i<this.rasterResOptions.length; i++){
var item = this.rasterResOptions[i];
rasterResList.push(item.name);
}
this.rasterResList.setItems(rasterResList);
this.rasterResList.onChange = function() {
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.rasterResolution = scopedThis.rasterResOptions[scopedThis.rasterResList.selection].key;
if(scopedThis.onFormatsChanged) scopedThis.onFormatsChanged();
};


// font row
var fontRow = this.formatColumn.add('group', undefined, '')
Expand All @@ -159,6 +186,7 @@
this.fontHandlingList.setEnabled(false);
this.fontHandlingList.setSize(290,20);
this.fontHandlingList.onChange = function() {
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.fontHandling = scopedThis.fontHandlingOptions[scopedThis.fontHandlingList.selection].key;
scopedThis.onFormatsChanged();
};
Expand All @@ -180,6 +208,7 @@
//this.presetsList.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.CENTER];
this.presetsList.setSize(290,20);
this.presetsList.onChange = function() {
if(scopedThis.ignoreChanges) return;
if(scopedThis.currentFormat.presets == null) return;
if(scopedThis.presetsList.selection <= 0){
scopedThis.currentFormatSettings.preset = null;
Expand All @@ -201,6 +230,7 @@
this.embedImageCheckBox.enabled = false;
//this.embedImageCheckBox.size = [ 180,20 ];
this.embedImageCheckBox.onClick = function(){
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.embedImage = scopedThis.embedImageCheckBox.value;
scopedThis.onFormatsChanged();
}
Expand All @@ -210,6 +240,7 @@
this.ungroupCheckBox.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP];
this.ungroupCheckBox.enabled = false;
this.ungroupCheckBox.onClick = function(){
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.ungroup = scopedThis.ungroupCheckBox.value;
scopedThis.onFormatsChanged();
}
Expand All @@ -220,6 +251,7 @@
this.trimEdgesCheckBox.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP];
this.trimEdgesCheckBox.enabled = false;
this.trimEdgesCheckBox.onClick = function(){
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.trimEdges = scopedThis.trimEdgesCheckBox.value;
scopedThis.onFormatsChanged();
}
Expand All @@ -231,6 +263,7 @@
this.innerPaddingCheckBox.alignment = [ScriptUI.Alignment.LEFT, ScriptUI.Alignment.TOP];
this.innerPaddingCheckBox.enabled = false;
this.innerPaddingCheckBox.onClick = function(){
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.innerPadding = scopedThis.innerPaddingCheckBox.value;
scopedThis.onFormatsChanged();
}
Expand All @@ -247,6 +280,7 @@
this.dirInput.size = [ 150,20 ];
this.dirInput.enabled = false;
this.dirInput.onChange = function(){
if(scopedThis.ignoreChanges) return;
scopedThis.currentFormatSettings.directory = scopedThis.dirInput.text;
scopedThis.onFormatsChanged();
}
Expand Down Expand Up @@ -381,6 +415,8 @@
this.presetsList.setEnabled(enabled);
this.colorSpaceList.setEnabled(enabled);
this.colorSpaceLabel.enabled = enabled;
this.rasterResList.setEnabled(enabled);
this.rasterResLabel.enabled = enabled;
this.moreButton.enabled = enabled;
this.removeButton.enabled = enabled;
this.activeCheckBox.enabled = enabled;
Expand Down Expand Up @@ -424,6 +460,10 @@
}
}

var rasterResEnabled = this.currentFormatSettings.hasProp("rasterResolution");
this.rasterResList.setEnabled(rasterResEnabled);
this.rasterResLabel.enabled = rasterResEnabled;

this.embedImageCheckBox.enabled = this.currentFormatSettings.hasProp("embedImage");
if(this.embedImageCheckBox.enabled){
this.embedImageCheckBox.value = this.currentFormatSettings.embedImage;
Expand All @@ -448,6 +488,16 @@
}
this.colorSpaceList.setSelection(selection);


var selection = 0;
for(var i=0; i<this.rasterResOptions.length; i++){
var item = this.rasterResOptions[i];
if(item.key==this.currentFormatSettings.rasterResolution){
selection = i;
}
}
this.rasterResList.setSelection(selection);

if(this.currentFormatSettings.hasProp("fontEmbed")){
this.fontHandlingOptions = [{name:"No Embed", key:"none"}, {name:"Embed", key:"embed"}];
if(this.currentFormatSettings.hasProp("fontOutline")){
Expand Down
33 changes: 18 additions & 15 deletions SmartCore/FormatSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ungroup:false,
fontHandling:"none",
colorSpace:null,
rasterResolution:"high",
trimEdges:true,
innerPadding:false,
scaling:null,
Expand All @@ -42,11 +43,12 @@
if(this.hasProp("embedImage"))ret.appendChild( new XML('<embedImage>'+this.embedImage+'</embedImage>') );
if(this.hasProp("trimEdges"))ret.appendChild( new XML('<trimEdges>'+this.trimEdges+'</trimEdges>') );
if(this.hasProp("innerPadding"))ret.appendChild( new XML('<innerPadding>'+this.innerPadding+'</innerPadding>') );
if(this.directory)ret.appendChild( new XML('<directory>'+this.directory+'</directory>') );
if(this.fontHandling && this.fontHandling!="none")ret.appendChild( new XML('<fontHandling>'+this.fontHandling+'</fontHandling>') );
if(this.colorSpace && this.colorSpace!="none")ret.appendChild( new XML('<colorSpace>'+this.colorSpace+'</colorSpace>') );
if(this.preset)ret.appendChild( new XML('<preset>'+this.preset+'</preset>') );
if(this.active != null)ret.appendChild( new XML('<active>'+this.active+'</active>') );
if(this.directory) ret.appendChild( new XML('<directory>'+this.directory+'</directory>') );
if(this.fontHandling && this.fontHandling!="none") ret.appendChild( new XML('<fontHandling>'+this.fontHandling+'</fontHandling>') );
if(this.colorSpace && this.colorSpace!="none") ret.appendChild( new XML('<colorSpace>'+this.colorSpace+'</colorSpace>') );
if(this.rasterResolution && this.rasterResolution!="none") ret.appendChild( new XML('<rasterResolution>'+this.rasterResolution+'</rasterResolution>') );
if(this.preset) ret.appendChild( new XML('<preset>'+this.preset+'</preset>') );
if(this.active != null) ret.appendChild( new XML('<active>'+this.active+'</active>') );

if(includePatterns){
var patterns = new XML('<patterns/>');
Expand Down Expand Up @@ -94,16 +96,17 @@
},

populateWithXML:function(xml){
this.format = xml.format.toString();
this.ungroup = xml.ungroup == "true";
this.embedImage = xml.embedImage == "true";
this.fontHandling = xml.fontHandling.toString() || "none";
this.trimEdges = xml.trimEdges == "true";
this.innerPadding = xml.innerPadding == "true";
this.scaling = parseFloat( xml.scaling.toString().replace( /\% /, '' )) || 100;
this.directory = xml.directory.toString();
this.colorSpace = xml.colorSpace.toString();
this.preset = xml.preset.toString();
this.format = xml.format.toString();
this.ungroup = xml.ungroup == "true";
this.embedImage = xml.embedImage == "true";
this.fontHandling = xml.fontHandling.toString() || "none";
this.trimEdges = xml.trimEdges == "true";
this.innerPadding = xml.innerPadding == "true";
this.scaling = parseFloat( xml.scaling.toString().replace( /\% /, '' )) || 100;
this.directory = xml.directory.toString();
this.colorSpace = xml.colorSpace.toString();
this.rasterResolution = xml.rasterResolution.toString();
this.preset = xml.preset.toString();

if(xml.active.length()) this.active = xml.active == "true";

Expand Down
12 changes: 6 additions & 6 deletions SmartCore/Formats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,23 +461,23 @@
{name:"GIF", ext:'gif', defaultDir:'gif', copyBehaviour:false, getOptions:getGifOptions, saveFile:saveGif, props:["scaling","trimEdges","innerPadding"],
more:[ {options:[transparency, antiAliasing, colorCount, colorDither, colorReduction, ditherPercent, infoLossPercent, interlaced, matteColor, webSnap]}]},

{name:"EPS", ext:'eps', defaultDir:'eps', copyBehaviour:true, getOptions:getEpsOptions, saveFile:saveEps, props:["embedImage","fontEmbed","fontOutline","trimEdges","ungroup"],
{name:"EPS", ext:'eps', defaultDir:'eps', copyBehaviour:true, getOptions:getEpsOptions, saveFile:saveEps, props:["embedImage","fontEmbed","fontOutline","rasterResolution","trimEdges","ungroup"],
more:[ {options:[cmykPostScript, compatibility, flattenOuput, includeDocumentThumbnails, overprint, epsVersion, epsPreview]} ]},

{name:"SVG", ext:'svg', defaultDir:'svg', copyBehaviour:true, getOptions:getSvgOptions, saveFile:saveSvg, props:["embedImage","fontOutline","trimEdges","ungroup"],
{name:"SVG", ext:'svg', defaultDir:'svg', copyBehaviour:true, getOptions:getSvgOptions, saveFile:saveSvg, props:["embedImage","fontOutline","rasterResolution","trimEdges","ungroup"],
more:[ {options:[coordinatePrecision, cssProperties, documentEncoding, DTD, fontSubsetting, fontType, includeFileInfo, includeUnusedStyles, preserveEditability, slices, sVGAutoKerning, sVGTextOnPath]} ]},

{name:"SVGZ", ext:'svgz', defaultDir:'svgz', copyBehaviour:true, getOptions:getSvgOptions, saveFile:saveSvg, props:["embedImage","fontOutline","trimEdges","ungroup"],
{name:"SVGZ", ext:'svgz', defaultDir:'svgz', copyBehaviour:true, getOptions:getSvgOptions, saveFile:saveSvg, props:["embedImage","fontOutline","rasterResolution","trimEdges","ungroup"],
more:[ {options:[coordinatePrecision, cssProperties, documentEncoding, DTD, fontSubsetting, fontType, includeFileInfo, includeUnusedStyles, preserveEditability, slices, sVGAutoKerning, sVGTextOnPath]} ],
extra:{ compressed:true }},

{name:"AI", ext:'ai', defaultDir:'ai', copyBehaviour:true, getOptions:getAiOptions, saveFile:saveAi, props:["embedImage","fontOutline","trimEdges","ungroup"],
{name:"AI", ext:'ai', defaultDir:'ai', copyBehaviour:true, getOptions:getAiOptions, saveFile:saveAi, props:["embedImage","fontOutline","rasterResolution","trimEdges","ungroup"],
more:[ {options:[compatibility, compressed, embedICCProfile, fontSubsetThreshold, pdfCompatible]} ]},

{name:"TIFF", ext:'tif', defaultDir:'tiff', copyBehaviour:false, getOptions:getTiffOptions, saveFile:saveTiff, props:["scaling","trimEdges","innerPadding"],
more:[ {options:[tiffByteOrder, tiffImageColorSpace, tiffIZWCompression, tiffResolution]} ]},

{name:"PDF", ext:'pdf', defaultDir:'pdf', copyBehaviour:true, getOptions:getPdfOptions, saveFile:savePdf, props:["trimEdges","fontOutline","ungroup"], presets:pdfPresets,
{name:"PDF", ext:'pdf', defaultDir:'pdf', copyBehaviour:true, getOptions:getPdfOptions, saveFile:savePdf, props:["trimEdges","fontOutline","rasterResolution","ungroup"], presets:pdfPresets,
more:[
{options:[pDFXStandard, pdfCompatibility]},

Expand Down Expand Up @@ -509,7 +509,7 @@
var preserveEditingCapabilities = bool("preserveEditingCapabilities", "Preserve Editing Capabilities", true);
var textPolicy = list("textPolicy", "Text Policy", 0, [opt(TextPreservePolicy.AUTOMATICALLYCONVERTTEXT, "Automatically Convert Text"), opt(TextPreservePolicy.OUTLINETEXT, "Outline Text"), opt(TextPreservePolicy.KEEPTEXTEDITABLE, "Keep Text Editable"), opt(TextPreservePolicy.RASTERIZETEXT, "Rasterize Text")]);
var fxgVersion = list("version", "Version", 1, [opt(FXGVersion.VERSION1PT0, "1.0"), opt(FXGVersion.VERSION2PT0, "2.0")]);
pack.formats.push( {name:"FXG", ext:'fxg', defaultDir:'fxg', copyBehaviour:true, getOptions:getFxgOptions, saveFile:saveFxg, props:["trimEdges","fontOutline","ungroup"],
pack.formats.push( {name:"FXG", ext:'fxg', defaultDir:'fxg', copyBehaviour:true, getOptions:getFxgOptions, saveFile:saveFxg, props:["trimEdges","fontOutline","rasterResolution","ungroup"],
more:[ blendsPolicy, downsampleLinkedImages, filtersPolicy, gradientsPolicy, includeUnusedSymbols, preserveEditingCapabilities, textPolicy, fxgVersion ]});
}

Expand Down

0 comments on commit 7732962

Please sign in to comment.