Skip to content

Commit

Permalink
Better display of name connexions in the main window #72
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Lebel committed Nov 3, 2014
1 parent 7a6be86 commit cc5f479
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 15 deletions.
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Just build it, it should work (but let me know if you have an errors or warnings

**Current**

**Beta**
**3.1 Beta**

- Better display of name connexions in the main window [issue #72](https://github.com/jeromelebel/MongoHub-Mac/issues/72)

## History

Expand Down
12 changes: 6 additions & 6 deletions Resources/English.lproj/MHMainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1070" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6245"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -500,18 +500,18 @@ DQ
<rect key="frame" x="0.0" y="0.0" width="179" height="157"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView id="538">
<imageView tag="2" id="538">
<rect key="frame" x="17" y="36" width="142" height="105"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="database" id="539"/>
</imageView>
<textField verticalHuggingPriority="750" tag="1" id="540">
<rect key="frame" x="14" y="17" width="145" height="17"/>
<rect key="frame" x="16" y="17" width="141" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="541">
<font key="font" metaFont="system"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</textFieldCell>
<connections>
<binding destination="531" name="value" keyPath="representedObject.alias" id="549"/>
Expand Down
39 changes: 31 additions & 8 deletions Sources/ConnectionsCollectionView/MHConnectionIconView.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#import "MHConnectionIconView.h"

@interface MHConnectionIconView ()
@property (nonatomic, readonly, strong) NSTextField *connectionLabel;
@property (nonatomic, readonly, weak) NSTextField *connectionLabel;
@property (nonatomic, readonly, weak) NSImageView *connectionIcon;

@end

Expand All @@ -28,7 +29,7 @@ - (void)drawRect:(NSRect)dirtyRect

[[NSColor colorWithCalibratedWhite:0.0 alpha:0.4] set];
bezierPath = NSBezierPath.bezierPath;
radius = self.bounds.size.height / 10.0;
radius = rect.size.height / 10.0;

x[0] = NSMinX(rect);
x[1] = NSMidX(rect);
Expand Down Expand Up @@ -58,22 +59,44 @@ - (NSTextField *)connectionLabel
return [self viewWithTag:1];
}

- (NSImageView *)connectionIcon
{
return [self viewWithTag:2];
}

- (void)setFrameSize:(NSSize)newSize
{
NSFont *font = nil;
NSRect frame;
NSRect selfBounds = self.bounds;
NSTextField *connectionLabel = self.connectionLabel;
NSImageView *connectionIcon = self.connectionIcon;

[super setFrameSize:newSize];
if (newSize.width < 90) {
self.connectionLabel.font = [NSFont systemFontOfSize:8.0];
font = [NSFont systemFontOfSize:8.0];
} else if (newSize.width < 100) {
self.connectionLabel.font = [NSFont systemFontOfSize:9.0];
font = [NSFont systemFontOfSize:9.0];
} else if (newSize.width < 110) {
self.connectionLabel.font = [NSFont systemFontOfSize:10.0];
font = [NSFont systemFontOfSize:10.0];
} else if (newSize.width < 130) {
self.connectionLabel.font = [NSFont systemFontOfSize:11.0];
font = [NSFont systemFontOfSize:11.0];
} else if (newSize.width < 150) {
self.connectionLabel.font = [NSFont systemFontOfSize:12.0];
font = [NSFont systemFontOfSize:12.0];
} else {
self.connectionLabel.font = [NSFont systemFontOfSize:13.0];
font = [NSFont systemFontOfSize:13.0];
}
connectionLabel.font = font;

[connectionLabel sizeToFit];
frame = connectionLabel.frame;
frame.origin.x = selfBounds.size.height / 10.0;
frame.size.width = selfBounds.size.width - frame.origin.x * 2;
frame.origin.y = selfBounds.size.height / 10.0;
connectionLabel.frame = frame;

frame = NSMakeRect(0, frame.origin.y + frame.size.height, selfBounds.size.width, selfBounds.size.height - frame.origin.y - frame.size.height - selfBounds.size.height / 10.0);
connectionIcon.frame = frame;
}

- (void)mouseDown:(NSEvent *)event
Expand Down

0 comments on commit cc5f479

Please sign in to comment.