Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue 28 #33

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
deef80c
Add podspec for Cocoapods
Feb 12, 2013
c00c9e0
Update podspec
Feb 12, 2013
b6fa7ef
Podspec: add QuartzCore in required frameworks
Feb 12, 2013
dd5a264
Merge pull request #6 from thibaut-jarosz/master
indragiek Feb 13, 2013
e3c313d
Bugfix when using ARC
Feb 22, 2013
ab3ebe2
Merge pull request #8 from thibaut-jarosz/master
indragiek Feb 23, 2013
b16c9d0
Bugfix: crash then using ARC and no animation
Feb 27, 2013
22ce1b9
Merge pull request #9 from thibaut-jarosz/master
indragiek Feb 27, 2013
287a7d3
Fixed border drawing glitch
Mar 6, 2013
e59de64
Merge pull request #10 from thibaut-jarosz/master
indragiek Mar 6, 2013
a563333
Fix error when using ARC
Apr 28, 2013
34032ac
Merge pull request #13 from Serahug/master
indragiek Apr 30, 2013
72d35d7
Fix popover animation on Mavericks
indragiek Jan 5, 2014
545fdef
Update .gitignore
indragiek Jan 5, 2014
29ea387
Cleanup directory structure, update build settings
indragiek Jan 5, 2014
c9f3399
Remove old files
indragiek Jan 5, 2014
f9e89de
Update README
indragiek Jan 5, 2014
0b0f4b2
Add alpha setting support to colour wells in sample app
indragiek Jan 12, 2014
61d1a7b
Update README
indragiek Jan 12, 2014
d34b87e
Modernized Objective-C
indragiek Jan 12, 2014
2155176
Remove all MRC conditionals
indragiek Jan 12, 2014
0d63165
retain -> strong
indragiek Jan 12, 2014
b0b8f88
Move license to LICENSE file, update copyright
indragiek Jan 12, 2014
a0cda2b
Add arrowSize and cornerRadius properties
indragiek Jan 12, 2014
126ec6c
Style
indragiek Jan 12, 2014
80b6676
Reformat code
indragiek Jan 12, 2014
35aa58d
Update README
indragiek Jan 12, 2014
c0d2567
Fix window activation behaviour
indragiek Jan 12, 2014
2a23660
Add animationType property
indragiek Jan 12, 2014
ff9406c
Fix popover inset
indragiek Jan 13, 2014
4b06722
Only draw border if borderWidth > 0
indragiek Jan 13, 2014
aa2d43e
Fixed source files location in podspec.
tomaz Mar 21, 2014
d00abd0
Merge pull request #16 from tomaz/master
indragiek Mar 28, 2014
f530925
Added option to close popover when escape key is pressed.
tomaz Apr 3, 2014
2978287
Merge pull request #17 from tomaz/master
indragiek Apr 13, 2014
b524902
copy/paste fail
Jun 20, 2014
3564f98
Merge pull request #19 from TaikiMMT/patch-1
indragiek Jun 20, 2014
bee38c2
NSRectEdge -> NSUInteger to support OSX 10.11
stephengazzard Jul 3, 2015
e30fef0
Remove references to NS...Edge in enum
stephengazzard Jul 6, 2015
4c7c674
Merge pull request #27 from RobotsAndPencils/master
indragiek Jul 7, 2015
9c1b0fd
fix for issue 28
Oct 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# OS X
.DS_Store
*.swp
*~.nib

# Xcode
build/

*.pbxuser
*.perspective
*.perspectivev3
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
*.xcworkspace
*xcuserdata/
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.ipa

# CocoaPods
Pods

# AppCode
.idea/
30 changes: 0 additions & 30 deletions INPopoverController-Info.plist

This file was deleted.

14 changes: 14 additions & 0 deletions INPopoverController.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Pod::Spec.new do |s|
s.name = 'INPopoverController'
s.version = '0.0.1'
s.summary = 'A customizable popover controller for Mac OS X'
s.homepage = 'https://github.com/indragiek/INPopoverController'
s.author = { 'Indragie Karunaratne' => 'indragiek@gmail.com' }
s.source = { :git => 'https://github.com/indragiek/INPopoverController.git' }
s.source_files = 'INPopoverController/*.{h,m}'
s.public_header_files = 'INPopoverController/*.h'
s.platform = :osx
s.requires_arc = true
s.license = 'BSD'
s.frameworks = 'QuartzCore'
end
115 changes: 69 additions & 46 deletions INPopoverController.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions INPopoverController/INPopoverController-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.indragie.INPopoverController.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2011 Indragie Karunaratne. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
77 changes: 34 additions & 43 deletions INPopoverController.h → INPopoverController/INPopoverController.h
Original file line number Diff line number Diff line change
@@ -1,61 +1,48 @@
//
// INPopoverController.h
// Copyright 2011 Indragie Karunaratne. All rights reserved.
// Copyright 2011-2014 Indragie Karunaratne. All rights reserved.
//
// Licensed under the BSD License <http://www.opensource.org/licenses/bsd-license>
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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

@class INPopoverWindow;
@protocol INPopoverControllerDelegate;
@interface INPopoverController : NSObject {
#if __has_feature(objc_arc)
__unsafe_unretained id<INPopoverControllerDelegate> _delegate;
#else
id<INPopoverControllerDelegate> _delegate;
#endif
NSSize _contentSize;
BOOL _closesWhenPopoverResignsKey;
BOOL _closesWhenApplicationBecomesInactive;
BOOL _animates;
NSViewController *_contentViewController;

INPopoverWindow *_popoverWindow;
NSView *_positionView;
NSRect _screenRect;
NSRect _viewRect;
}

@interface INPopoverController : NSObject

#pragma mark -
#pragma mark Properties

/** The delegate of the INPopoverController object (should conform to the INPopoverControllerDelegate protocol) **/
#if __has_feature(objc_arc)
@property (nonatomic, unsafe_unretained) id<INPopoverControllerDelegate> delegate;
#else
@property (nonatomic, assign) id<INPopoverControllerDelegate> delegate;
#endif
@property (nonatomic, assign) id <INPopoverControllerDelegate> delegate;

/** The background color of the popover. Default value is [NSColor blackColor] with an alpha value of 0.8. Changes to this value are not animated. **/
@property (nonatomic, retain) NSColor *color;
@property (nonatomic, strong) NSColor *color;

/** Border color to use when drawing a border. Default value: [NSColor blackColor]. Changes to this value are not animated. **/
@property (nonatomic, retain) NSColor *borderColor;
@property (nonatomic, strong) NSColor *borderColor;

/** Color to use for drawing a 1px highlight just below the top. Can be nil. Changes to this value are not animated. **/
@property (nonatomic, retain) NSColor *topHighlightColor;
@property (nonatomic, strong) NSColor *topHighlightColor;

/** The width of the popover border, drawn using borderColor. Default value: 0.0 (no border). Changes to this value are not animated. **/
@property (nonatomic) CGFloat borderWidth;
@property (nonatomic, assign) CGFloat borderWidth;

/** Corner radius of the popover window. Default value: 4. Changes to this value are not animated. **/
@property (nonatomic, assign) CGFloat cornerRadius;

/** The size of the popover arrow. Default value: {23, 12}. Changes to this value are not animated. **/
@property (nonatomic, assign) NSSize arrowSize;

/** The current arrow direction of the popover. If the popover has never been displayed, then this will return INPopoverArrowDirectionUndefined */
@property (readonly) INPopoverArrowDirection arrowDirection;
@property (nonatomic, assign, readonly) INPopoverArrowDirection arrowDirection;

/** The size of the content of the popover. This is automatically set to contentViewController's size when the view controller is set, but can be modified. Changes to this value are animated when animates is set to YES **/
@property (nonatomic, assign) NSSize contentSize;

/** Whether the popover closes when user presses escape key. Default value: YES */
@property (nonatomic, assign) BOOL closesWhenEscapeKeyPressed;

/** Whether the popover closes when the popover window resigns its key status. Default value: YES **/
@property (nonatomic, assign) BOOL closesWhenPopoverResignsKey;

Expand All @@ -65,17 +52,21 @@
/** Enable or disable animation when showing/closing the popover and changing the content size. Default value: YES */
@property (nonatomic, assign) BOOL animates;

/* If `animates` is `YES`, this is the animation type to use when showing/closing the popover.
Default value: `INPopoverAnimationTypePop` **/
@property (nonatomic, assign) INPopoverAnimationType animationType;

/** The content view controller from which content is displayed in the popover **/
@property (nonatomic, retain) NSViewController *contentViewController;
@property (nonatomic, strong) NSViewController *contentViewController;

/** The view that the currently displayed popover is positioned relative to. If there is no popover being displayed, this returns nil. **/
@property (readonly) NSView *positionView;
@property (nonatomic, strong, readonly) NSView *positionView;

/** The window of the popover **/
@property (readonly) NSWindow *popoverWindow;
@property (nonatomic, strong, readonly) NSWindow *popoverWindow;

/** Whether the popover is currently visible or not **/
@property (readonly) BOOL popoverIsVisible;
@property (nonatomic, assign, readonly) BOOL popoverIsVisible;

#pragma mark -
#pragma mark Methods
Expand All @@ -85,7 +76,7 @@
@param viewController the content view controller
@returns a new instance of INPopoverController
*/
- (id)initWithContentViewController:(NSViewController*)viewController;
- (id)initWithContentViewController:(NSViewController *)viewController;

/**
Displays the popover.
Expand All @@ -94,7 +85,7 @@
@param direction the prefered direction at which the arrow will point. There is no guarantee that this will be the actual arrow direction, depending on whether the screen is able to accomodate the popover in that position.
@param anchors Whether the popover binds to the frame of the positionView. This means that if the positionView is resized or moved, the popover will be repositioned according to the point at which it was originally placed. This also means that if the positionView goes off screen, the popover will be automatically closed. **/

- (void)presentPopoverFromRect:(NSRect)rect inView:(NSView*)positionView preferredArrowDirection:(INPopoverArrowDirection)direction anchorsToPositionView:(BOOL)anchors;
- (void)presentPopoverFromRect:(NSRect)rect inView:(NSView *)positionView preferredArrowDirection:(INPopoverArrowDirection)direction anchorsToPositionView:(BOOL)anchors;

/**
Recalculates the best arrow direction for the current window position and resets the arrow direction. The change will not be animated. **/
Expand Down Expand Up @@ -128,29 +119,29 @@
@param popover the @class INPopoverController object that is controlling the popover
@returns whether the popover should close or not
*/
- (BOOL)popoverShouldClose:(INPopoverController*)popover;
- (BOOL)popoverShouldClose:(INPopoverController *)popover;

/**
Invoked right before the popover shows on screen
@param popover the @class INPopoverController object that is controlling the popover
*/
- (void)popoverWillShow:(INPopoverController*)popover;
- (void)popoverWillShow:(INPopoverController *)popover;

/**
Invoked right after the popover shows on screen
@param popover the @class INPopoverController object that is controlling the popover
*/
- (void)popoverDidShow:(INPopoverController*)popover;
- (void)popoverDidShow:(INPopoverController *)popover;

/**
Invoked right before the popover closes
@param popover the @class INPopoverController object that is controlling the popover
*/
- (void)popoverWillClose:(INPopoverController*)popover;
- (void)popoverWillClose:(INPopoverController *)popover;

/**
Invoked right before the popover closes
Invoked right after the popover closes
@param popover the @class INPopoverController object that is controlling the popover
*/
- (void)popoverDidClose:(INPopoverController*)popover;
- (void)popoverDidClose:(INPopoverController *)popover;
@end
Loading