Skip to content

Commit

Permalink
Improved handling for long symbol master names, added button to select
Browse files Browse the repository at this point in the history
master (if it resides in current document).
  • Loading branch information
Jason Burns committed Oct 31, 2017
1 parent 9c04e9a commit f672b71
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To find your plugins directory...

# Changelog

* **1.4** - Improved handling for long symbol master names, added button to select master (if it resides in current document).
* **1.3** - Added button to select all matches on current page, updated plugin screenshot.
* **1.2** - Update to make the result window a floating panel, highlight for current selection, and artboard name.
* **1.1** - Code optimizations and dialog frame will now be smaller if a small set of results are returned.
Expand Down
Binary file modified Screenshots/Symbol Instance Locator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"isRoot" : true
},
"identifier" : "com.sonburn.sketchplugins.symbol-instance-locator",
"version" : "1.3",
"version" : "1.4",
"description" : "Locate all instances of a selected symbol or instance.",
"authorEmail" : "[email protected]",
"name" : "Symbol Instance Locator",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var onRun = function(context) {
var instancePanelContent = NSView.alloc().initWithFrame(NSMakeRect(0,0,instancePanelWidth,instancePanelContentHeight));
instancePanelContent.setFlipped(1);

var matchText = createBoldDescription(symbolMaster.name() + " has " + symbolInstances.length + " instance(s).",12,NSMakeRect(8,12,instancePanelWidth-16,16));
var matchText = createBoldDescription(truncateString(String(symbolMaster.name()),30) + " has " + symbolInstances.length + " instance(s).",12,NSMakeRect(8,12,instancePanelWidth-16,16));
instancePanelContent.addSubview(matchText);

var selectText = createDescription("Select an instance below to navigate to it's location...",12,NSMakeRect(8,34,instancePanelWidth-16,16));
Expand All @@ -87,7 +87,7 @@ var onRun = function(context) {
while (pageInstance = pageInstanceLoop.nextObject()) {
pageInstance.select_byExpandingSelection(true,true);

var buttonToSelect = symbolInstances.findIndex(o => o === pageInstance);
var buttonToSelect = symbolInstances.findIndex(o => o == pageInstance);

uiButtons[buttonToSelect].setWantsLayer(1);
uiButtons[buttonToSelect].layer().setBorderWidth(2);
Expand All @@ -101,6 +101,33 @@ var onRun = function(context) {
});
instancePanelContent.addSubview(selectAllButton);

var selectMasterButton = NSButton.alloc().initWithFrame(NSMakeRect(130,450,100,36));
selectMasterButton.setTitle("Go to Master");
selectMasterButton.setBezelStyle(NSRoundedBezelStyle);
selectMasterButton.setEnabled(context.document.pages().containsObject(symbolMaster.parentPage()));
selectMasterButton.setAction("callAction:");
selectMasterButton.setCOSJSTargetFunction(function(sender) {
for (var i = 0; i < uiButtons.length; i++) {
if (uiButtons[i].layer()) uiButtons[i].layer().setBorderWidth(0);
}

context.document.currentPage().changeSelectionBySelectingLayers(nil);

var rect = symbolMaster.absoluteRect().rect();

MSDocument.currentDocument().setCurrentPage(symbolMaster.parentPage());
MSDocument.currentDocument().currentView().zoomToFitRect(rect);

symbolMaster.select_byExpandingSelection(true,false);
});
instancePanelContent.addSubview(selectMasterButton);

// var refreshButton = NSButton.alloc().initWithFrame(NSMakeRect(230,450,120,36));
// refreshButton.setTitle("Refresh Results");
// refreshButton.setBezelStyle(NSRoundedBezelStyle);
// refreshButton.setEnabled(0);
// instancePanelContent.addSubview(refreshButton);

var gutterWidth = 15,
instanceItemHeight = 96,
instanceItemWidth = instancePanelWidth - gutterWidth,
Expand Down Expand Up @@ -278,3 +305,7 @@ function createBoldDescription(text,size,frame,alpha) {

return label;
}

function truncateString(string,length) {
return (string.length <= length) ? string : "…" + string.substr(string.length-length);
};
6 changes: 3 additions & 3 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<description>Locate all instances of a selected symbol or instance.</description>
<language>en</language>
<item>
<title>Version 1.3</title>
<title>Version 1.4</title>
<description>
<![CDATA[
<ul>
<li>Added button to select all matches on current page, updated plugin screenshot.</li>
<li>Improved handling for long symbol master names, added button to select master (if it resides in current document).</li>
</ul>
]]>
</description>
<enclosure url="https://github.com/sonburn/symbol-instance-locator/archive/master.zip" sparkle:version="1.3" />
<enclosure url="https://github.com/sonburn/symbol-instance-locator/archive/master.zip" sparkle:version="1.4" />
</item>
</channel>
</rss>

0 comments on commit f672b71

Please sign in to comment.