Show real dimensions and paths in the clip card footer - #95
Open
alvst wants to merge 1 commit into
Open
Conversation
The footer's "Image" and "1 file" told you nothing you couldn't already see from the card itself. Image clips now read their pixel dimensions - "1920 × 1080" - and file clips say which files they actually point at. What a file clip's footer says depends on what the file is. An image already shows what it is by sitting on the card, so its dimensions are the useful fact - a screenshot's path is a timestamped folder nobody reads. Everything else gets its full location instead, abbreviated with "~", because two documents of the same name differ only by where they live. Multi-file clips list every filename rather than a bare "N files" count, which named none of them. Whether a file is an image is decided from its path extension, never by opening it: the footer is evaluated on every render, so it must not touch disk. A path is worth reading in full, so the meta line wraps to three lines for file clips rather than collapsing to an ellipsis; every other type stays on one line. The footer row aligns on its bottom edge so the quick-paste hint stays put as the path grows. Dimensions come from the image file's metadata via CGImageSource rather than from decoding it, and are cached by path: the footer asks on every render, so a decode per card would be paid over and over for a number that never changes. Clips whose image file is missing or unreadable fall back to the old "Image" label, and an image file whose size can't be read falls back to its filename.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The card footer's "Image" and "1 file" tell you nothing the card itself doesn't already show. Image clips now read their pixel dimensions, and file clips say which files they actually point at.
What changed
1920 × 1080— instead of the word "Image".~-abbreviated, because two documents of the same name differ only by where they live.Screenshots
Before:

After:

Notes for review
CGImageSourceCopyPropertiesAtIndex(never a decode), cached by path.alvie/pr-26-paste-style-cards, but the two use differently-named, differently-typed helpers on purpose (isSingleImageFilereturningBoolhere,singleImageFileURLreturningURL?there), so they can merge in either order with no redeclaration.This feature should be bundled into v2.
Part of #80.