Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added resizing functionality

  • Loading branch information...
commit d111a1391fc1bc0ec6019231ef5e429a495422ff 1 parent e7d2587
Steven Degutis authored
View
76 English.lproj/InspectorPaneInspector.xib
@@ -206,21 +206,23 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>allowsFloats</string>
<string>attributedStringForZero</string>
+ <string>decimalSeparator</string>
<string>formatterBehavior</string>
<string>groupingSeparator</string>
- <string>locale</string>
<string>maximum</string>
<string>minimum</string>
<string>negativeFormat</string>
<string>positiveFormat</string>
+ <string>textAttributesForZero</string>
<string>usesGroupingSeparator</string>
+ <string>zeroSymbol</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1" id="9"/>
- <object class="NSAttributedString" id="310148558">
+ <object class="NSAttributedString">
<string key="NSString">0</string>
- <object class="NSDictionary" key="NSAttributes" id="1015838502">
+ <object class="NSDictionary" key="NSAttributes" id="415649043">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -230,37 +232,45 @@
</object>
</object>
</object>
- <integer value="1000" id="517535102"/>
+ <string>.</string>
+ <integer value="1040"/>
<string>,</string>
- <object class="NSLocale" id="1001290163">
- <string key="NS.identifier"/>
- </object>
<real value="1.000000e+04" id="667828742"/>
<real value="0.000000e+00" id="743034181"/>
<string>-0</string>
<string>0</string>
- <reference ref="743034181"/>
+ <reference ref="415649043"/>
+ <boolean value="NO" id="6"/>
+ <string>0</string>
</object>
</object>
<string key="NS.positiveformat">0</string>
<string key="NS.negativeformat">-0</string>
<nil key="NS.positiveattrs"/>
<nil key="NS.negativeattrs"/>
- <reference key="NS.zero" ref="310148558"/>
+ <object class="NSAttributedString" key="NS.zero">
+ <string key="NSString">0</string>
+ <reference key="NSAttributes" ref="415649043"/>
+ </object>
<object class="NSAttributedString" key="NS.nil">
- <string key="NSString"/>
+ <nil key="NSString"/>
</object>
<object class="NSAttributedString" key="NS.nan">
<string key="NSString">NaN</string>
- <reference key="NSAttributes" ref="1015838502"/>
+ <reference key="NSAttributes" ref="415649043"/>
</object>
<reference key="NS.min" ref="743034181"/>
<reference key="NS.max" ref="667828742"/>
- <nil key="NS.rounding"/>
+ <object class="NSDecimalNumberHandler" key="NS.rounding">
+ <int key="NS.roundingmode">3</int>
+ <bool key="NS.raise.overflow">YES</bool>
+ <bool key="NS.raise.underflow">YES</bool>
+ <bool key="NS.raise.dividebyzero">YES</bool>
+ </object>
<string key="NS.decimal">.</string>
<string key="NS.thousand">,</string>
<bool key="NS.hasthousands">NO</bool>
- <bool key="NS.localized">NO</bool>
+ <bool key="NS.localized">YES</bool>
<bool key="NS.allowsfloats">YES</bool>
</object>
<reference key="NSControlView" ref="385174481"/>
@@ -287,51 +297,63 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>allowsFloats</string>
<string>attributedStringForZero</string>
+ <string>decimalSeparator</string>
<string>formatterBehavior</string>
<string>groupingSeparator</string>
- <string>locale</string>
<string>maximum</string>
<string>minimum</string>
<string>negativeFormat</string>
<string>positiveFormat</string>
+ <string>textAttributesForZero</string>
<string>usesGroupingSeparator</string>
+ <string>zeroSymbol</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="9"/>
- <object class="NSAttributedString" id="42906102">
+ <object class="NSAttributedString">
<string key="NSString">0</string>
- <reference key="NSAttributes" ref="1015838502"/>
+ <reference key="NSAttributes" ref="415649043"/>
</object>
- <reference ref="517535102"/>
+ <string>.</string>
+ <integer value="1040"/>
<string>,</string>
- <reference ref="1001290163"/>
<reference ref="667828742"/>
- <reference ref="743034181"/>
+ <real value="0.000000e+00" id="602843440"/>
<string>-0</string>
<string>0</string>
- <reference ref="743034181"/>
+ <reference ref="415649043"/>
+ <reference ref="6"/>
+ <string>0</string>
</object>
</object>
<string key="NS.positiveformat">0</string>
<string key="NS.negativeformat">-0</string>
<nil key="NS.positiveattrs"/>
<nil key="NS.negativeattrs"/>
- <reference key="NS.zero" ref="42906102"/>
+ <object class="NSAttributedString" key="NS.zero">
+ <string key="NSString">0</string>
+ <reference key="NSAttributes" ref="415649043"/>
+ </object>
<object class="NSAttributedString" key="NS.nil">
- <string key="NSString"/>
+ <nil key="NSString"/>
</object>
<object class="NSAttributedString" key="NS.nan">
<string key="NSString">NaN</string>
- <reference key="NSAttributes" ref="1015838502"/>
+ <reference key="NSAttributes" ref="415649043"/>
</object>
- <reference key="NS.min" ref="743034181"/>
+ <reference key="NS.min" ref="602843440"/>
<reference key="NS.max" ref="667828742"/>
- <nil key="NS.rounding"/>
+ <object class="NSDecimalNumberHandler" key="NS.rounding">
+ <int key="NS.roundingmode">3</int>
+ <bool key="NS.raise.overflow">YES</bool>
+ <bool key="NS.raise.underflow">YES</bool>
+ <bool key="NS.raise.dividebyzero">YES</bool>
+ </object>
<string key="NS.decimal">.</string>
<string key="NS.thousand">,</string>
<bool key="NS.hasthousands">NO</bool>
- <bool key="NS.localized">NO</bool>
+ <bool key="NS.localized">YES</bool>
<bool key="NS.allowsfloats">YES</bool>
</object>
<reference key="NSControlView" ref="629393840"/>
@@ -949,7 +971,7 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.LastKnownRelativeProjectPath">../InspectorPane.xcodeproj</string>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../Inspector.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
View
8 InspectorPane.h
@@ -28,6 +28,10 @@
BOOL collapsed;
float uncollapsedHeight;
float distanceFromTop;
+
+ // for resizing
+ BOOL pressed;
+ float heightFromBottom;
}
@property BOOL resizable;
@@ -36,8 +40,4 @@
- (IBAction) toggleCollapsed:(id)sender;
-- (void) toggleCollapsedWithAnimation:(BOOL)animates;
-
-- (InspectorPaneContainer*) container;
-
@end
View
149 InspectorPane.m
@@ -14,6 +14,13 @@
#import <QuartzCore/QuartzCore.h>
+@interface InspectorPane ( Private )
+- (void) toggleCollapsedWithAnimation:(BOOL)animates;
+- (NSRect) resizeHandleRect;
+- (InspectorPaneContainer*) container;
+- (void) addHeightToSize:(float)amount;
+@end
+
@implementation InspectorPane
@synthesize resizable;
@@ -63,6 +70,25 @@ - (void) awakeFromNib {
[[titleTextField cell] setBackgroundStyle:NSBackgroundStyleRaised];
}
+- (void) setResizable:(BOOL)newResizable {
+ resizable = newResizable;
+
+ NSRect fullBodyFrame = [self bounds];
+ NSRect headFrame = [paneHead frame];
+ NSRect bodyFrame = [paneBody frame];
+ NSRect resizingHandleFrame = [self resizeHandleRect];
+
+ NSDivideRect(fullBodyFrame, &headFrame, &bodyFrame, NSHeight(headFrame), NSMaxYEdge);
+
+ if (resizable)
+ NSDivideRect(bodyFrame, &resizingHandleFrame, &bodyFrame, NSHeight(resizingHandleFrame) + 1, NSMinYEdge);
+
+ NSLog(@"%@", NSStringFromRect(bodyFrame));
+
+ [paneBody setFrame:bodyFrame];
+ [self setNeedsDisplay:YES];
+}
+
- (BOOL)mouseDownCanMoveWindow {
return NO;
}
@@ -123,12 +149,131 @@ - (void) toggleCollapsedWithAnimation:(BOOL)animate {
// [[self bodyView] setAutoresizesSubviews:YES];
}
+- (InspectorPaneContainer*) container {
+ return (InspectorPaneContainer*)[self superview];
+}
+
+// MARK: -
+// MARK: Resizable methods
+
- (void) drawRect:(NSRect)rect {
//[[[NSColor purpleColor] colorWithAlphaComponent:0.5] drawSwatchInRect:[self bounds]];
+ if (resizable == NO)
+ return;
+
+ NSColor *topColor = [NSColor colorWithCalibratedWhite:0.70 alpha:1.0];
+ NSColor *fillColor = [NSColor colorWithCalibratedWhite:0.95 alpha:1.0];
+ NSColor *handleColor = [NSColor colorWithCalibratedWhite:0.60 alpha:1.0];
+
+ [fillColor setFill];
+ [NSBezierPath fillRect:[self resizeHandleRect]];
+
+ NSRect singlePixelRect = [self resizeHandleRect];
+ singlePixelRect.origin.y = singlePixelRect.size.height - 0;
+ singlePixelRect.size.height = 1;
+
+ [topColor setFill];
+ [NSBezierPath fillRect:singlePixelRect];
+
+ singlePixelRect.origin.y = 0;
+
+ NSRect middleHandleRect = singlePixelRect;
+ middleHandleRect.origin.y = 2;
+ middleHandleRect.size.width = NSWidth([self resizeHandleRect]) / 12.0;
+ middleHandleRect.origin.x = NSMidX([self resizeHandleRect]) - (middleHandleRect.size.width / 2.0);
+
+ [handleColor setFill];
+ [NSBezierPath fillRect:middleHandleRect];
+
+// [[NSColor colorWithCalibratedWhite:0.0 alpha:0.03] setFill];
+// [NSBezierPath fillRect:[self resizeHandleRect]];
+
+ if (pressed) {
+ [[NSColor colorWithCalibratedWhite:0.0 alpha:0.07] setFill];
+ [NSBezierPath fillRect:[self resizeHandleRect]];
+ }
}
-- (InspectorPaneContainer*) container {
- return (InspectorPaneContainer*)[self superview];
+- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
+ if (resizable) {
+ NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ return NSPointInRect(point, [self resizeHandleRect]);
+ }
+ else
+ return [super acceptsFirstMouse:theEvent];
+}
+
+- (void) mouseDown:(NSEvent*)event {
+ if (resizable == NO || SDIsInIB)
+ return;
+
+ NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
+ pressed = NSPointInRect(point, [self resizeHandleRect]);
+
+ if (pressed)
+ heightFromBottom = point.y;
+
+ [self setNeedsDisplay:YES];
+}
+
+- (void) mouseDragged:(NSEvent*)event {
+ if (resizable == NO || SDIsInIB)
+ return;
+
+ if (pressed == NO)
+ return;
+
+ NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
+
+ float growByAmount = heightFromBottom - point.y;
+ [self addHeightToSize:growByAmount];
+}
+
+- (void) mouseUp:(NSEvent*)event {
+ if (resizable == NO || SDIsInIB)
+ return;
+
+ if (pressed == NO)
+ return;
+
+ uncollapsedHeight = [self frame].size.height;
+ pressed = NO;
+ [self setNeedsDisplay:YES];
+
+ //[[self container] setHeight:uncollapsedHeight forPane:self];
+}
+
+- (void) resetCursorRects {
+ if (resizable)
+ [self addCursorRect:[self resizeHandleRect] cursor:[NSCursor resizeUpDownCursor]];
+}
+
+- (NSRect) resizeHandleRect {
+ if (resizable == NO)
+ return NSZeroRect;
+
+ NSRect rect = [self bounds];
+ rect.size.height = 5;
+ return rect;
+}
+
+- (void) addHeightToSize:(float)amount {
+ if (resizable == NO)
+ return;
+
+ NSRect newFrame = [self frame];
+
+ float margins = 17.0 + NSHeight([self resizeHandleRect]);
+
+ if (newFrame.size.height + amount < margins + minHeight)
+ amount = minHeight + margins - newFrame.size.height;
+ else if ((maxHeight > 0) && newFrame.size.height + amount > margins + maxHeight)
+ amount = maxHeight + margins - newFrame.size.height;
+
+ newFrame.size.height += amount;
+ newFrame.origin.y += amount;
+
+ [self setFrame:newFrame];
}
@end
View
12 InspectorPaneContainer.m
@@ -13,8 +13,12 @@
@interface InspectorPaneContainer ( Private )
- (void) adjustActualWindowToFitContainer;
-- (void) togglePane:(InspectorPane*)pane collapsed:(BOOL)collapsed;
- (void) repositionViewsIgnoringView:(NSView*)viewToIgnore;
+
+// get rid of these 2
+- (void) setHeight:(float)newHeight forPane:(NSView*)view;
+- (void) togglePane:(InspectorPane*)pane collapsed:(BOOL)collapsed;
+
@end
@implementation InspectorPaneContainer
@@ -103,11 +107,15 @@ - (void) adjustActualWindowToFitContainer {
[self setFrame:selfFrame];
}
-// this apparently is only here for persistence.. its thus horribly named :/
+// these 2 methods are apparently only here for persistence.. thus they're horribly named :/
- (void) togglePane:(InspectorPane*)pane collapsed:(BOOL)collapsed {
//int index = [[self subviews] indexOfObject:view];
//[collapsedSubviewIndexes replaceObjectAtIndex:index withObject:[NSNumber numberWithBool:collapsed]];
}
+- (void) setHeight:(float)newHeight forPane:(NSView*)view {
+// int index = [[self subviews] indexOfObject:view];
+// [subviewHeights replaceObjectAtIndex:index withObject:[NSNumber numberWithFloat:newHeight]];
+}
- (void) repositionViewsIgnoringView:(NSView*)viewToIgnore {
float top = 0.0;
Please sign in to comment.
Something went wrong with that request. Please try again.