Skip to content

Commit

Permalink
Fixed some more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
DWilliames committed Mar 7, 2018
1 parent b25479f commit 328c921
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<link>https://raw.githubusercontent.com/DWilliames/paddy-sketch-plugin/master/.appcast.xml</link>
<description>Automated padding, spacing and alignment for your Sketch layers</description>
<language>en</language>
<item>
<title>Version 1.0.6</title>
<description>Squashed some more bugs</description>
<enclosure url="https://github.com/DWilliames/paddy-sketch-plugin/releases/download/v1.0.6/Paddy.sketchplugin.zip" sparkle:version="1.0.6" />
</item>
<item>
<title>Version 1.0.5</title>
<description>More bug fixes</description>
Expand Down
1 change: 1 addition & 0 deletions Paddy.sketchplugin/Contents/Sketch/async.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Work in progress

function loadFramework(name, className) {
if (NSClassFromString(className) == null) {
Expand Down
17 changes: 14 additions & 3 deletions Paddy.sketchplugin/Contents/Sketch/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getContainerFrameForBGLayer(bg) {
return false
if (layer.isMemberOfClass(MSSliceLayer))
return false
if (layer.name().startsWith('-'))
if (shouldLayerBeIgnored(layer))
return false
return true
})
Expand All @@ -36,13 +36,24 @@ function getContainerFrameForBGLayer(bg) {
}


// If the layer should be ignored when calculating the rect of a layer
function shouldLayerBeIgnored(layer) {
if (!layer) return

if (layer.name().startsWith('-')) {
return true
}

return false
}

// Whether to check for Stack Groups
var takeIntoAccountStackViews = true


// Return the rect for a layer as an MSRect
function rectForLayer(layer, ignoreWithPrefix) {
if (!layer || (ignoreWithPrefix && layer.name().startsWith('-'))) {
if (!layer || (ignoreWithPrefix && shouldLayerBeIgnored(layer))) {
return
}

Expand Down Expand Up @@ -161,7 +172,7 @@ function getBGCandidateFromLayers(layers) {

var candidate
var existingBackground = layers.find(function(layer) {
if (layer.name().startsWith('-'))
if (shouldLayerBeIgnored(layer))
return false

if (canLayerHavePadding(layer)) {
Expand Down
8 changes: 6 additions & 2 deletions Paddy.sketchplugin/Contents/Sketch/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,15 @@ function selectionChanged(context) {
startBenchmark()
document = context.actionContext.document

// print('Selection changed - OLD/NEW')
// print(context.actionContext.oldSelection)
// print(context.actionContext.newSelection)

if (newSelection.length == 1 && newSelection[0].name() == "PADDY-NULL-LAYER") {
// The selection was becuase of the 'Null layer' used to resolve Craft's stupid Duplicator conflict!!!

log('Selected the NULL layer; will reselect', context.actionContext.oldSelection)

context.actionContext.oldSelection.forEach(function(layer) {
layer.select_byExpandingSelection(true, true)
})
Expand Down Expand Up @@ -576,7 +580,7 @@ function updatePaddingAndSpacingForLayer(layer) {

var updateInstances = true

if (total >= 5) {
if (total >= 10) {
// if there are more than 10 to update... ask the user if this is what they want to do

var iconImage = NSImage.alloc().initByReferencingFile(plugin.urlForResourceNamed("icon.png").path())
Expand Down
2 changes: 1 addition & 1 deletion Paddy.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
"name": "Imply padding for selection",
"identifier": "autoApplyPadding",
"shortcut": "command p",
"shortcut": "command shift p",
"script": "main.js",
"handler": "autoApplyPadding",
"description": "Apply implied padding to the currently selected layers",
Expand Down
2 changes: 1 addition & 1 deletion Paddy.sketchplugin/Contents/Sketch/spacing.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function applySpacingToGroup(spacing, groupLayer) {
return false
if (layer.isMemberOfClass(MSSliceLayer))
return false
if (layer.name().startsWith('-'))
if (shouldLayerBeIgnored(layer))
return false
return true
})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Examples:

Run the plugin command **'Enter padding for selection'** or **`Control + Alt + p`** to bring up an input field, to save padding to all your selected layers easier.

If you don't want to be prompted to enter the specified padding, and instead want it to be automatically inferred from what it already is – run the command **'Imply padding for selection'** or **`Command + p`**.
If you don't want to be prompted to enter the specified padding, and instead want it to be automatically inferred from what it already is – run the command **'Imply padding for selection'** or **`Command + shift + p`**.

![Padding example](.images/GIFs/padding.gif)

Expand Down

0 comments on commit 328c921

Please sign in to comment.