1 /* 2 PPSamplerImageView.h 3 4 Copyright 2013-2018 Josh Freeman 5 http://www.twilightedge.com 6 7 This file is part of PikoPixel for Mac OS X and GNUstep. 8 PikoPixel is a graphical application for drawing & editing pixel-art images. 9 10 PikoPixel is free software: you can redistribute it and/or modify it under 11 the terms of the GNU Affero General Public License as published by the 12 Free Software Foundation, either version 3 of the License, or (at your 13 option) any later version approved for PikoPixel by its copyright holder (or 14 an authorized proxy). 15 16 PikoPixel is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more 19 details. 20 21 You should have received a copy of the GNU Affero General Public License 22 along with this program. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 #import <Cocoa/Cocoa.h> 26 #import "PPSamplerImagePanelType.h" 27 #import "PPResizableDirectionsMasks.h" 28 29 30 @class PPDocumentSamplerImage; 31 32 @interface PPSamplerImageView : NSView 33 { 34 PPSamplerImagePanelType _panelType; 35 36 float _minViewDimension; 37 float _maxViewDimension; 38 float _defaultImageDimension; 39 40 id _delegate; 41 42 PPDocumentSamplerImage *_samplerImage; 43 NSRect _imageFrame; 44 NSRect _imageDrawBounds; 45 46 NSRect _imageBoundsTrackingRect; 47 NSTrackingRectTag _imageBoundsTrackingRectTag; 48 49 float _minScaleForCurrentImage; 50 float _maxScaleForCurrentImage; 51 52 NSColor *_lastSampledColor; 53 54 bool _mouseIsSamplingImage; 55 bool _mouseIsInsideImageBoundsTrackingRect; 56 bool _disallowMouseTracking; 57 } 58 59 - (void) setSamplerImagePanelType: (PPSamplerImagePanelType) panelType 60 minViewDimension: (float) minViewDimension 61 maxViewDimension: (float) maxViewDimension 62 defaultImageDimension: (float) defaultImageDimension 63 delegate: (id) delegate; 64 65 - (void) setSamplerImage: (PPDocumentSamplerImage *) samplerImage; 66 67 - (NSSize) viewSizeForResizingToProposedViewSize: (NSSize) proposedViewSize 68 resizableDirectionsMask: (unsigned) resizableDirectionsMask; 69 - (NSSize) viewSizeForScaledCurrentSamplerImage; 70 71 - (void) setupMouseTracking; 72 - (void) disableMouseTracking: (bool) shouldDisableTracking; 73 74 - (bool) mouseIsSamplingImage; 75 - (void) forceStopSamplingImage; 76 77 @end 78 79 @interface NSObject (PPSamplerImageViewDelegateMethods) 80 81 - (void) ppSamplerImageView: (PPSamplerImageView *) samplerImageView 82 didBrowseColor: (NSColor *) color; 83 84 - (void) ppSamplerImageView: (PPSamplerImageView *) samplerImageView 85 didSelectColor: (NSColor *) color; 86 87 - (void) ppSamplerImageViewDidCancelSelection: (PPSamplerImageView *) samplerImageView; 88 89 @end 90