Fixed button size when setting image by scaling down image before using it

This commit is contained in:
Michael Starke
2018-11-15 18:07:43 +01:00
parent 3fcb7305d3
commit 4b56167b56
2 changed files with 23 additions and 15 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13529" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13529"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -16,17 +16,17 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="1">
<rect key="frame" x="0.0" y="0.0" width="400" height="400"/>
<rect key="frame" x="0.0" y="0.0" width="465" height="400"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView wantsLayer="YES" focusRingType="none" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="57" customClass="HNHUIScrollView">
<rect key="frame" x="10" y="50" width="380" height="330"/>
<rect key="frame" x="10" y="50" width="445" height="330"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="Gwf-zs-lPT">
<rect key="frame" x="0.0" y="0.0" width="380" height="330"/>
<rect key="frame" x="0.0" y="0.0" width="445" height="330"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView focusRingType="none" selectable="YES" id="58" customClass="MPCollectionView">
<rect key="frame" x="0.0" y="0.0" width="380" height="330"/>
<rect key="frame" x="0.0" y="0.0" width="445" height="330"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="primaryBackgroundColor" name="windowBackgroundColor" catalog="System" colorSpace="catalog"/>
<connections>
@@ -35,17 +35,17 @@
</collectionView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="59">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="59">
<rect key="frame" x="1" y="144" width="233" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="60">
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="60">
<rect key="frame" x="364" y="0.0" width="16" height="268"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="101">
<rect key="frame" x="265" y="18" width="115" height="25"/>
<rect key="frame" x="330" y="19" width="115" height="23"/>
<buttonCell key="cell" type="roundTextured" title="Use Default Icon" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="102">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -55,7 +55,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8kv-BJ-IEk">
<rect key="frame" x="153" y="18" width="104" height="25"/>
<rect key="frame" x="214" y="19" width="108" height="23"/>
<buttonCell key="cell" type="roundTextured" title="Download Icon" bezelStyle="texturedRounded" imagePosition="left" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iaf-XW-XUo">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -65,7 +65,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="His-4A-hcY">
<rect key="frame" x="89" y="18" width="56" height="25"/>
<rect key="frame" x="150" y="19" width="56" height="23"/>
<buttonCell key="cell" type="roundTextured" title="Cancel" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1kM-cI-P1o">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>

View File

@@ -102,13 +102,21 @@ typedef NS_ENUM(NSInteger, MPIconDownloadStatus) {
case MPIconDownloadStatusNone:
self.downloadIconButton.image = nil;
break;
case MPIconDownloadStatusError:
self.downloadIconButton.image = [NSImage imageNamed:NSImageNameCaution];
case MPIconDownloadStatusError: {
NSImage *image = [NSImage imageNamed:NSImageNameCaution];
CGFloat scale = image.size.width / image.size.height;
image.size = NSMakeSize(16 * scale, 16);
self.downloadIconButton.image = image;
break;
case MPIconDownloadStatusProgress:
self.downloadIconButton.image = [NSImage imageNamed:NSImageNameRefreshTemplate];
}
case MPIconDownloadStatusProgress: {
NSImage *image = [NSImage imageNamed:NSImageNameRefreshTemplate];
CGFloat scale = image.size.width / image.size.height;
image.size = NSMakeSize(16 * scale, 16);
self.downloadIconButton.image = image;
break;
}
}
}
- (void)_downloadIconForURL:(NSString *)URLString {