Skip to content

Commit

Permalink
Merge branch 'release/2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
amitailanciano committed Sep 3, 2014
2 parents 64545ff + d14e3cb commit 7ca6422
Show file tree
Hide file tree
Showing 105 changed files with 11,469 additions and 1,390 deletions.
20 changes: 20 additions & 0 deletions MachineMenuItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// MachineMenuItem.h
// Vagrant Manager
//
// Copyright (c) 2014 Lanayo. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "VagrantMachine.h"

@class MachineMenuItem;

@interface MachineMenuItem : NSView

@property (weak) IBOutlet NSImageView *stateImageView;
@property (weak) IBOutlet NSTextField *nameTextField;

@property (strong, nonatomic) VagrantMachine *machine;

@end
17 changes: 17 additions & 0 deletions MachineMenuItem.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MachineMenuItem.m
// Vagrant Manager
//
// Copyright (c) 2014 Lanayo. All rights reserved.
//

#import "MachineMenuItem.h"

@implementation MachineMenuItem

- (void)drawRect:(NSRect)dirtyRect {
[[NSColor colorWithRed:.8 green:.8 blue:.8 alpha:.5] set];
NSRectFillUsingOperation(self.bounds, NSCompositeSourceOver);
}

@end
488 changes: 392 additions & 96 deletions Vagrant Manager.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions Vagrant Manager/AXStatusItemPopup/AXStatusItemPopup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// StatusItemPopup.h
// StatusItemPopup
//
// Created by Alexander Schuch on 06/03/13.
// Copyright (c) 2013 Alexander Schuch. All rights reserved.
//

#import <Cocoa/Cocoa.h>
@class PopupContentViewController;

@interface AXStatusItemPopup : NSView

// properties
@property(assign, nonatomic, getter=isActive) BOOL active;
@property(assign, nonatomic) BOOL animated;
@property(strong, nonatomic) NSImage *image;
@property(strong, nonatomic) NSImage *alternateImage;
@property(strong, nonatomic) NSStatusItem *statusItem;


// init
- (id)initWithViewController:(PopupContentViewController *)controller;
- (id)initWithViewController:(PopupContentViewController *)controller image:(NSImage *)image;
- (id)initWithViewController:(PopupContentViewController *)controller image:(NSImage *)image alternateImage:(NSImage *)alternateImage;

- (void)setTitle:(NSString*)title;

// show / hide popover
- (void)showPopover;
- (void)showPopoverAnimated:(BOOL)animated;
- (void)hidePopover;
- (NSPopover*)getPopover;

// view size
- (void)setContentSize:(CGSize)size;

@end
235 changes: 235 additions & 0 deletions Vagrant Manager/AXStatusItemPopup/AXStatusItemPopup.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
//
// StatusItemPopup.m
// StatusItemPopup
//
// Created by Alexander Schuch on 06/03/13.
// Copyright (c) 2013 Alexander Schuch. All rights reserved.
//

#import "AXStatusItemPopup.h"
#import "AXTextView.h"

#define kMinViewWidth 22

//
// Private variables
//
@interface AXStatusItemPopup () {
PopupContentViewController *_viewController;
BOOL _active;
NSImageView *_imageView;
NSTextView *_titleView;
NSStatusItem *_statusItem;
NSPopover *_popover;
id _popoverTransiencyMonitor;
}
@end

///////////////////////////////////

//
// Implementation
//
@implementation AXStatusItemPopup

- (id)initWithViewController:(PopupContentViewController *)controller
{
return [self initWithViewController:controller image:nil];
}

- (id)initWithViewController:(PopupContentViewController *)controller image:(NSImage *)image
{
return [self initWithViewController:controller image:image alternateImage:nil];
}

- (id)initWithViewController:(PopupContentViewController *)controller image:(NSImage *)image alternateImage:(NSImage *)alternateImage
{
CGFloat height = [NSStatusBar systemStatusBar].thickness;

self = [super initWithFrame:NSMakeRect(0, 0, kMinViewWidth*2, height)];
if (self) {
_viewController = controller;

self.image = image;
self.alternateImage = alternateImage;

_imageView = [[NSImageView alloc] initWithFrame:NSMakeRect(0, 0, kMinViewWidth, height)];
[self addSubview:_imageView];

_titleView = [[AXTextView alloc] initWithFrame:NSMakeRect(kMinViewWidth, 0, 20, height)];
[_titleView setEditable:NO];
[self addSubview:_titleView];
[_titleView setString:@""];
_titleView.font = [NSFont boldSystemFontOfSize:12];
[_titleView.textContainer setLineFragmentPadding:0];
[_titleView setTextContainerInset:NSMakeSize(0, 0)];
[_titleView setBackgroundColor:[NSColor clearColor]];

self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
self.statusItem.view = self;

_active = NO;
_animated = YES;

if (!_popover) {
_popover = [[NSPopover alloc] init];
_popover.contentViewController = _viewController;
}
}
return self;
}

- (NSPopover*)getPopover {
return _popover;
}

- (void)setTitle:(NSString*)title {
NSAttributedString *string = [[NSAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName: _titleView.font}];
CGRect rect = [string boundingRectWithSize:(CGSize){CGFLOAT_MAX, self.frame.size.height} options:NSStringDrawingUsesLineFragmentOrigin];


CGRect frame = _titleView.frame;
frame.size.width = rect.size.width;
frame.size.height = rect.size.height;
frame.origin.y = (self.frame.size.height - frame.size.height) / 2;
_titleView.frame = frame;
_titleView.string = title;
[self updateViewFrame];
}


////////////////////////////////////
#pragma mark - Drawing
////////////////////////////////////

- (void)drawRect:(NSRect)dirtyRect
{
// set view background color
if (_active) {
[[NSColor selectedMenuItemColor] setFill];
} else {
[[NSColor clearColor] setFill];
}
NSRectFill(dirtyRect);

// set image
NSImage *image = (_active ? _alternateImage : _image);
_imageView.image = image;

if(_active) {
_titleView.textColor = [NSColor whiteColor];
} else {
_titleView.textColor = [NSColor blackColor];
}
}

////////////////////////////////////
#pragma mark - Position / Size
////////////////////////////////////

- (void)setContentSize:(CGSize)size
{
_popover.contentSize = size;
}

////////////////////////////////////
#pragma mark - Mouse Actions
////////////////////////////////////

- (void)mouseDown:(NSEvent *)theEvent
{
if (_popover.isShown) {
[self hidePopover];
} else {
[self showPopover];
}
}

////////////////////////////////////
#pragma mark - Setter
////////////////////////////////////

- (void)setActive:(BOOL)active
{
_active = active;
[self setNeedsDisplay:YES];
}

- (void)setImage:(NSImage *)image
{
_image = image;
[self updateViewFrame];
}

- (void)setAlternateImage:(NSImage *)image
{
_alternateImage = image;
if (!image && _image) {
_alternateImage = _image;
}
[self updateViewFrame];
}

////////////////////////////////////
#pragma mark - Helper
////////////////////////////////////

- (void)updateViewFrame
{
CGFloat width = MAX(MAX(kMinViewWidth, self.alternateImage.size.width), self.image.size.width);

if([_titleView string].length > 0) {
width += _titleView.frame.size.width;
}

CGFloat height = [NSStatusBar systemStatusBar].thickness;

NSRect frame = NSMakeRect(0, 0, width, height);
self.frame = frame;

[self setNeedsDisplay:YES];
}


////////////////////////////////////
#pragma mark - Show / Hide Popover
////////////////////////////////////

- (void)showPopover
{
[self showPopoverAnimated:_animated];
[_viewController resizeTableView];
}

- (void)showPopoverAnimated:(BOOL)animated
{
self.active = YES;

if (!_popover.isShown) {
_popover.animates = animated;
[_popover showRelativeToRect:self.frame ofView:self preferredEdge:NSMinYEdge];
_popoverTransiencyMonitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask handler:^(NSEvent* event) {
[self hidePopover];
}];
[_viewController resizeTableView];
}
}

- (void)hidePopover
{
self.active = NO;

if (_popover && _popover.isShown) {
[_popover close];

[_viewController collapseAllChildMenuItems];

if (_popoverTransiencyMonitor) {
[NSEvent removeMonitor:_popoverTransiencyMonitor];
_popoverTransiencyMonitor = nil;
}
}
}

@end

12 changes: 12 additions & 0 deletions Vagrant Manager/AXStatusItemPopup/AXTextView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// AXTextView.h
// Vagrant Manager
//
// Copyright (c) 2014 Lanayo. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface AXTextView : NSTextView

@end
32 changes: 32 additions & 0 deletions Vagrant Manager/AXStatusItemPopup/AXTextView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// AXTextView.m
// Vagrant Manager
//
// Copyright (c) 2014 Lanayo. All rights reserved.
//

#import "AXTextView.h"

@implementation AXTextView

- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];

// Drawing code here.
}

- (NSView *)hitTest:(NSPoint)aPoint {
return nil;
}

@end
13 changes: 7 additions & 6 deletions Vagrant Manager/AboutWindow.xib
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
<plugIn identifier="com.apple.WebKitIBPlugin" version="5056"/>
</dependencies>
Expand All @@ -15,14 +16,14 @@
<customObject id="-3" userLabel="Application"/>
<window title="About Vagrant Manager" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="1">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="196" y="240" width="480" height="239"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
<rect key="contentRect" x="196" y="240" width="480" height="240"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1058"/>
<view key="contentView" id="2">
<rect key="frame" x="0.0" y="0.0" width="480" height="239"/>
<rect key="frame" x="0.0" y="0.0" width="480" height="240"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<webView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tYe-WP-fMN">
<rect key="frame" x="20" y="19" width="440" height="200"/>
<webView id="tYe-WP-fMN">
<rect key="frame" x="20" y="20" width="440" height="200"/>
<autoresizingMask key="autoresizingMask"/>
<webPreferences key="preferences" defaultFontSize="12" defaultFixedFontSize="12">
<nil key="identifier"/>
Expand Down
Loading

0 comments on commit 7ca6422

Please sign in to comment.