Permalink
Browse files

new zooming UI

  • Loading branch information...
1 parent 07f4719 commit ea0ffa2016af251c9e4d19758ea91ec6e5f2b160 @mattrajca mattrajca committed Oct 15, 2012
Oops, something went wrong.
@@ -17,7 +17,6 @@
NSPoint marqueePatternOffset;
BOOL drawsSelectionMarquee;
- float zoomPercentage;
NSPoint centeredPoint;
BOOL shouldDrawMainBackground;
BOOL shouldDrawGrid;
@@ -34,7 +33,7 @@
}
@property (nonatomic, weak) PXCanvas *canvas;
-@property (nonatomic, assign) float zoomPercentage;
+@property (nonatomic, assign) int zoomPercentage;
@property (nonatomic, assign) BOOL usesToolCursors;
@property (nonatomic, assign) BOOL updatesInfoPanel;
@@ -45,10 +44,6 @@
- (PXCrosshair *)crosshair;
- (id) initWithFrame:(NSRect)rect;
-- (float)zoomPercentage;
-
-- (void)setZoomPercentage:(float)percent;
-
- (NSPoint)convertFromCanvasToViewPoint:(NSPoint)point;
- (NSRect)convertFromCanvasToViewRect:(NSRect)rect;
- (NSPoint)convertFromViewToCanvasPoint:(NSPoint)point;
@@ -43,7 +43,7 @@ @implementation PXCanvasView {
NSTrackingArea *_trackingArea;
}
-@synthesize canvas, zoomPercentage, delegate;
+@synthesize canvas, zoomPercentage = _zoomPercentage, delegate;
@synthesize usesToolCursors = _usesToolCursors, updatesInfoPanel = _updatesInfoPanel;
- (BOOL)acceptsFirstMouse:(NSEvent *)event
@@ -72,7 +72,7 @@ -(id) initWithFrame:(NSRect)rect
return nil;
acceptsFirstMouse = YES;
- zoomPercentage = 100;
+ _zoomPercentage = 100;
shouldDrawGrid = YES;
shouldDrawMainBackground = YES;
trackingRect = -1;
@@ -212,14 +212,16 @@ - (void)sizeToCanvas
[self addTrackingArea:_trackingArea];
}
-- (void)setZoomPercentage:(float)percent
+- (void)setZoomPercentage:(int)percent
{
- NSRect rect = [self visibleRect];
- centeredPoint = [self convertFromViewToCanvasPoint:NSMakePoint(NSMinX(rect) + NSWidth(rect)/2, NSMinY(rect) + NSHeight(rect)/2)];
- zoomPercentage = percent;
- cachedMarqueePath = nil;
- [self sizeToCanvas];
- [self updateInfoPanelWithMousePosition:[self convertFromWindowToCanvasPoint:[[self window] mouseLocationOutsideOfEventStream]] dragging:NO];
+ if (_zoomPercentage != percent) {
+ NSRect rect = [self visibleRect];
+ centeredPoint = [self convertFromViewToCanvasPoint:NSMakePoint(NSMinX(rect) + NSWidth(rect)/2, NSMinY(rect) + NSHeight(rect)/2)];
+ _zoomPercentage = percent;
+ cachedMarqueePath = nil;
+ [self sizeToCanvas];
+ [self updateInfoPanelWithMousePosition:[self convertFromWindowToCanvasPoint:[[self window] mouseLocationOutsideOfEventStream]] dragging:NO];
+ }
}
- (BOOL)shouldDrawMainBackground
@@ -565,7 +567,7 @@ - (void)drawRect:(NSRect)rect
// gridRect.size.height += yCenter;
// gridRect.size.width = ceilf(NSWidth(gridRect));
// gridRect.size.height = ceilf(NSHeight(gridRect));
- if ((zoomPercentage / 100.0f) * [[canvas grid] unitSize].width >= 4 && (zoomPercentage / 100.0f) * [[canvas grid] unitSize].height >= 4)
+ if ((_zoomPercentage / 100.0f) * [[canvas grid] unitSize].width >= 4 && (_zoomPercentage / 100.0f) * [[canvas grid] unitSize].height >= 4)
{
[[canvas grid] drawRect:gridRect];
}
@@ -577,7 +579,7 @@ - (void)drawRect:(NSRect)rect
[transform concat];
if ([[self window] isMainWindow]) {
- [crosshair drawRect:gridRect withTool:currentTool tileOffset:NSMakePoint(xCenter, yCenter) scale:zoomPercentage/100.0f];
+ [crosshair drawRect:gridRect withTool:currentTool tileOffset:NSMakePoint(xCenter, yCenter) scale:_zoomPercentage/100.0f];
}
[transform invert];
@@ -595,7 +597,7 @@ - (NSAffineTransform *)setupScaleTransform
{
NSAffineTransform *transformation = [NSAffineTransform transform];
- [transformation scaleBy:zoomPercentage/100.0f];
+ [transformation scaleBy:_zoomPercentage/100.0f];
return transformation;
}
@@ -16,10 +16,6 @@
PXCanvasController *__weak canvasController;
PXCanvas *__weak canvas;
- id __weak zoomPercentageBox;
- id __weak zoomStepper;
- NSView *zoomView;
-
PXGridSettingsController *_gridSettingsController;
PXCanvasResizePrompter *_resizePrompter;
PXScaleController *scaleController;
@@ -29,9 +25,8 @@
NSToolbar *toolbar;
}
-@property (nonatomic, weak) IBOutlet id zoomPercentageBox;
-@property (nonatomic, weak) IBOutlet id zoomStepper;
-@property (nonatomic, strong) IBOutlet NSView *zoomView;
+@property (nonatomic, weak) IBOutlet NSTextField *zoomLabel;
+@property (nonatomic, weak) IBOutlet NSSlider *zoomSlider;
@property (nonatomic, weak) IBOutlet PXCanvasController *canvasController;
@@ -29,7 +29,6 @@
@implementation PXCanvasWindowController
-@synthesize zoomPercentageBox, zoomStepper, zoomView;
@synthesize scaleController, canvasController, resizePrompter = _resizePrompter, canvas;
@synthesize splitView, sidebarSplit, layerSplit, canvasSplit, paletteSplit;
@@ -202,8 +201,6 @@ - (void)windowDidBecomeMain:(NSNotification *)notification
- (void)prepare
{
- [self prepareZoom];
-
[canvasController setDocument:[self document]];
[canvasController setWindow:[self window]];
[canvasController prepare];
@@ -17,6 +17,7 @@
#import "PXCanvas_Modifying.h"
#import "PXCanvas_Selection.h"
#import "PXCanvasController.h"
+#import "PXCanvasView.h"
#import "PXGridSettingsController.h"
#import "PXScaleController.h"
#import "PXPaletteExporter.h"
@@ -204,11 +205,11 @@ - (BOOL)validateMenuItem:(NSMenuItem *)anItem
return [[self canvas] hasSelection] && [[[PXToolPaletteController sharedToolPaletteController] currentTool] supportsPatterns];
else if ([anItem action] == @selector(zoomOut:))
{
- return ([zoomPercentageBox indexOfSelectedItem] < [zoomPercentageBox numberOfItems]-1);
+ return ([[canvasController view] zoomPercentage] > 100);
}
else if ([anItem action] == @selector(zoomIn:))
{
- return ([zoomPercentageBox indexOfSelectedItem] > 0);
+ return ([[canvasController view] zoomPercentage] < 1000);
}
else if ([anItem action] == @selector(increaseOpacity:))
{
@@ -16,7 +16,6 @@ @implementation PXCanvasWindowController(Toolbar)
NSString *PXToolProperties = @"PXToolProperties";
NSString *PXScale = @"PXScale";
NSString *PXResize = @"PXResize";
-NSString *PXZoom = @"PXZoom";
- (void)prepareToolbar
{
@@ -68,14 +67,6 @@ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
[item setAction:@selector(resizeCanvas:)];
[item setImage:[NSImage imageNamed:@"resize"]];
}
- else if ([itemIdentifier isEqualToString:PXZoom])
- {
- [item setLabel:NSLocalizedString(@"ZOOM_LABEL", @"Zoom Label")];
- [item setToolTip:NSLocalizedString(@"ZOOM_TOOLTIP", @"Zoom Tooltip")];
- [item setView:zoomView];
- [item setMinSize:NSMakeSize(124,NSHeight([zoomView frame]))];
- [item setMaxSize:NSMakeSize(124,NSHeight([zoomView frame]))];
- }
[item setPaletteLabel:[item label]];
if(![item target])
{
@@ -87,7 +78,7 @@ - (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
- (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar
{
return [NSArray arrayWithObjects:PXBackgroundConfigurator,
- PXPreview, PXZoom,
+ PXPreview,
PXResize, PXScale,
NSToolbarCustomizeToolbarItemIdentifier,
NSToolbarSpaceItemIdentifier,
@@ -100,7 +91,7 @@ - (NSArray *) toolbarDefaultItemIdentifiers:(NSToolbar *) toolbar
{
return [NSArray arrayWithObjects:PXBackgroundConfigurator,
NSToolbarSeparatorItemIdentifier, PXPreview,
- NSToolbarFlexibleSpaceItemIdentifier, PXZoom, nil];
+ NSToolbarFlexibleSpaceItemIdentifier, nil];
}
@end
@@ -2,27 +2,25 @@
// PXCanvasWindowController_Zooming.h
// Pixen
//
-// Created by Joe Osborn on 2005.08.09.
-// Copyright 2005 Pixen. All rights reserved.
+// Copyright 2005-2012 Pixen Project. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
#import "PXCanvasWindowController.h"
-@interface PXCanvasWindowController(Zooming)
+@interface PXCanvasWindowController (Zooming)
-- (void)prepareZoom;
-- (IBAction)zoomToFit:sender;
-- (void)zoomToIndex:(float)index;
-- (void)zoomToPercentage:(NSNumber *)percentage;
+- (void)zoomToPercent:(int)percent;
- (void)zoomToFit;
+
- (void)canvasController:(PXCanvasController *)controller zoomInOnCanvasPoint:(NSPoint)point;
- (void)canvasController:(PXCanvasController *)controller zoomOutOnCanvasPoint:(NSPoint)point;
- (void)zoomToFitCanvasController:(PXCanvasController *)controller;
-- (IBAction)zoomIn: (id) sender;
-- (IBAction)zoomOut: (id) sender;
-- (IBAction)zoomStandard: (id) sender;
-- (IBAction)zoomPercentageChanged:sender;
-- (IBAction)zoomStepperStepped:(id) sender;
+
+- (IBAction)zoomIn:(id)sender;
+- (IBAction)zoomOut:(id)sender;
+- (IBAction)zoomStandard:(id)sender;
+- (IBAction)zoomToFit:(id)sender;
+
+- (IBAction)zoomSliderChanged:(id)sender;
@end
Oops, something went wrong.

0 comments on commit ea0ffa2

Please sign in to comment.