Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[FIX] When autoresizing items, item sizes need to be integral. Otherw…

…ise, CoreGraphics freaks out when trying to create graphics contexts.
  • Loading branch information...
commit 29a770b56d5dd8cc5da14fbe76fc440346abd10b 1 parent a99a762
@mattball authored
View
10 English.lproj/MainMenu.xib
@@ -1114,7 +1114,7 @@
<object class="NSWindowTemplate" id="972006081">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{335, 390}, {480, 360}}</string>
+ <string key="NSWindowRect">{{335, 521}, {623, 229}}</string>
<int key="NSWTFlags">1946157056</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">NSWindow</string>
@@ -1128,12 +1128,12 @@
<object class="NSCustomView" id="260292442">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">286</int>
- <string key="NSFrameSize">{480, 360}</string>
+ <string key="NSFrameSize">{623, 229}</string>
<reference key="NSSuperview" ref="439893737"/>
<string key="NSClassName">MBCoverFlowView</string>
</object>
</object>
- <string key="NSFrameSize">{480, 360}</string>
+ <string key="NSFrameSize">{623, 229}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
@@ -2959,8 +2959,8 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{234, 376}, {480, 360}}</string>
- <string>{{234, 376}, {480, 360}}</string>
+ <string>{{139, 478}, {623, 229}}</string>
+ <string>{{139, 478}, {623, 229}}</string>
<reference ref="9"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
View
7 MBCoverFlowView.h
@@ -50,6 +50,7 @@
MBCoverFlowScroller *_scroller;
BOOL _showsScrollbar;
+ BOOL _autoresizesItems;
}
/**
@@ -66,6 +67,12 @@
*/
/**
+ * @brief Whether or not the receiver should resize items to fit
+ * the available vertical space. Defaults to \c YES.
+ */
+@property (nonatomic, assign) BOOL autoresizesItems;
+
+/**
* @brief The size of the flow items.
*/
@property (nonatomic, assign) NSSize itemSize;
View
20 MBCoverFlowView.m
@@ -68,7 +68,8 @@ - (void)_scrollerChange:(MBCoverFlowScroller *)scroller;
@implementation MBCoverFlowView
@synthesize accessoryController=_accessoryController, selectionIndex=_selectionIndex,
- itemSize=_itemSize, content=_content, showsScrollbar=_showsScrollbar;
+ itemSize=_itemSize, content=_content, showsScrollbar=_showsScrollbar,
+ autoresizesItems=_autoresizesItems;
#pragma mark -
#pragma mark Life Cycle
@@ -76,7 +77,7 @@ @implementation MBCoverFlowView
- (id)initWithFrame:(NSRect)frameRect
{
if (self = [super initWithFrame:frameRect]) {
- //_imageOrigin = MBCoverFlowViewBottomMargin;
+ _autoresizesItems = YES;
[self setAutoresizesSubviews:YES];
@@ -365,8 +366,18 @@ - (void)setContent:(NSArray *)newContents
#pragma mark Setting Display Attributes
+- (void)setAutoresizesItems:(BOOL)flag
+{
+ _autoresizesItems = flag;
+ [self resizeSubviewsWithOldSize:[self frame].size];
+}
+
- (NSSize)itemSize
{
+ if (!self.autoresizesItems) {
+ return _itemSize;
+ }
+
float origin = MBCoverFlowViewBottomMargin;
if (self.showsScrollbar) {
@@ -381,6 +392,11 @@ - (NSSize)itemSize
NSSize size;
size.height = ([self frame].size.height - origin) - [self frame].size.height/3;
size.width = 1.4*size.height;
+
+ // Make sure it's integral
+ size.height = floor(size.height);
+ size.width = floor(size.width);
+
return size;
}
Please sign in to comment.
Something went wrong with that request. Please try again.