From 1d7e6fcca4ab74d61e0ec9ac21c9f3a49a10c035 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 18 Jul 2009 19:36:42 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added:=20AMIndeterminateProgressIndicatorCe?= =?UTF-8?q?ll=20for=20global=20spinning=20wheel=20=E2=80=A2=20added:=20spi?= =?UTF-8?q?nning=20wheel=20background=20image=20=E2=80=A2=20removed=20warn?= =?UTF-8?q?ing=20in=20TableContent=20(unused=20'j')?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Images/borderlessbackground.png | Bin 0 -> 3745 bytes Source/AMIndeterminateProgressIndicatorCell.h | 58 ++++++++ Source/AMIndeterminateProgressIndicatorCell.m | 189 ++++++++++++++++++++++++++ Source/TableContent.m | 2 +- sequel-pro.xcodeproj/project.pbxproj | 10 ++ 5 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 Resources/Images/borderlessbackground.png create mode 100644 Source/AMIndeterminateProgressIndicatorCell.h create mode 100644 Source/AMIndeterminateProgressIndicatorCell.m diff --git a/Resources/Images/borderlessbackground.png b/Resources/Images/borderlessbackground.png new file mode 100644 index 00000000..12464c71 Binary files /dev/null and b/Resources/Images/borderlessbackground.png differ diff --git a/Source/AMIndeterminateProgressIndicatorCell.h b/Source/AMIndeterminateProgressIndicatorCell.h new file mode 100644 index 00000000..40193373 --- /dev/null +++ b/Source/AMIndeterminateProgressIndicatorCell.h @@ -0,0 +1,58 @@ +// +// $Id: SPFieldEditorController.h 802 2009-07-18 20:46:57Z bibiko $ +// +// AMIndeterminateProgressIndicatorCell.h +// sequel-pro +// +// Created by Andreas Mayer on January 23, 2007 +// Copyright 2007 Andreas Mayer (andreas@harmless.de). All rights reserved. +// +// License: http://www.opensource.org/licenses/bsd-license.php +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import + + +@interface AMIndeterminateProgressIndicatorCell : NSCell { + double doubleValue; + NSTimeInterval animationDelay; + BOOL displayedWhenStopped; + BOOL spinning; + NSColor *color; + float redComponent; + float greenComponent; + float blueComponent; +} + +- (NSColor *)color; +- (void)setColor:(NSColor *)value; + +- (double)doubleValue; +- (void)setDoubleValue:(double)value; + +- (NSTimeInterval)animationDelay; +- (void)setAnimationDelay:(NSTimeInterval)value; + +- (BOOL)isDisplayedWhenStopped; +- (void)setDisplayedWhenStopped:(BOOL)value; + +- (BOOL)isSpinning; +- (void)setSpinning:(BOOL)value; + + +@end diff --git a/Source/AMIndeterminateProgressIndicatorCell.m b/Source/AMIndeterminateProgressIndicatorCell.m new file mode 100644 index 00000000..16293202 --- /dev/null +++ b/Source/AMIndeterminateProgressIndicatorCell.m @@ -0,0 +1,189 @@ +// +// $Id: SPFieldEditorController.h 802 2009-07-18 20:46:57Z bibiko $ +// +// AMIndeterminateProgressIndicatorCell.m +// sequel-pro +// +// Created by Andreas Mayer on January 23, 2007 +// Copyright 2007 Andreas Mayer (andreas@harmless.de). All rights reserved. +// +// License: http://www.opensource.org/licenses/bsd-license.php +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at + +#import "AMIndeterminateProgressIndicatorCell.h" + +#define ConvertAngle(a) (fmod((90.0-(a)), 360.0)) + +#define DEG2RAD 0.017453292519943295 + +@implementation AMIndeterminateProgressIndicatorCell + +- (id)init +{ + if (self = [super initImageCell:nil]) { + [self setAnimationDelay:5.0/60.0]; + [self setDisplayedWhenStopped:YES]; + [self setDoubleValue:0.0]; + [self setColor:[NSColor blackColor]]; + } + return self; +} + +- (void)dealloc +{ + [NSColor release]; + [super dealloc]; +} + +- (NSColor *)color +{ + return [[color retain] autorelease]; +} + +- (void)setColor:(NSColor *)value +{ + float alphaComponent; + if (color != value) { + [color release]; + color = [value retain]; + [[color colorUsingColorSpaceName:@"NSCalibratedRGBColorSpace"] getRed:&redComponent green:&greenComponent blue:&blueComponent alpha:&alphaComponent]; + NSAssert((alphaComponent > 0.999), @"color must be opaque"); + } +} + +- (double)doubleValue +{ + return doubleValue; +} + +- (void)setDoubleValue:(double)value +{ + if (doubleValue != value) { + doubleValue = value; + if (doubleValue > 1.0) { + doubleValue = 1.0; + } else if (doubleValue < 0.0) { + doubleValue = 0.0; + } + } +} + +- (NSTimeInterval)animationDelay +{ + return animationDelay; +} + +- (void)setAnimationDelay:(NSTimeInterval)value +{ + if (animationDelay != value) { + animationDelay = value; + } +} + +- (BOOL)isDisplayedWhenStopped +{ + return displayedWhenStopped; +} + +- (void)setDisplayedWhenStopped:(BOOL)value +{ + if (displayedWhenStopped != value) { + displayedWhenStopped = value; + } +} + +- (BOOL)isSpinning +{ + return spinning; +} + +- (void)setSpinning:(BOOL)value +{ + if (spinning != value) { + spinning = value; + } +} + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView +{ + // cell has no border + [self drawInteriorWithFrame:cellFrame inView:controlView]; +} + +- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView +{ + //NSLog(@"cellFrame: %f %f %f %f", cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height); + if ([self isSpinning] || [self isDisplayedWhenStopped]) { + float flipFactor = ([controlView isFlipped] ? 1.0 : -1.0); + int step = round([self doubleValue]/(5.0/60.0)); + float cellSize = MIN(cellFrame.size.width, cellFrame.size.height); + NSPoint center = cellFrame.origin; + center.x += cellSize/2.0; + center.y += cellFrame.size.height/2.0; + float outerRadius; + float innerRadius; + float strokeWidth = cellSize*0.08; + if (cellSize >= 32.0) { + outerRadius = cellSize*0.38; + innerRadius = cellSize*0.23; + } else { + outerRadius = cellSize*0.48; + innerRadius = cellSize*0.27; + } + float a; // angle + NSPoint inner; + NSPoint outer; + // remember defaults + NSLineCapStyle previousLineCapStyle = [NSBezierPath defaultLineCapStyle]; + float previousLineWidth = [NSBezierPath defaultLineWidth]; + // new defaults for our loop + [NSBezierPath setDefaultLineCapStyle:NSRoundLineCapStyle]; + [NSBezierPath setDefaultLineWidth:strokeWidth]; + if ([self isSpinning]) { + a = (270+(step* 30))*DEG2RAD; + } else { + a = 270*DEG2RAD; + } + a = flipFactor*a; + int i; + for (i = 0; i < 12; i++) { +// [[NSColor colorWithCalibratedWhite:MIN(sqrt(i)*0.25, 0.8) alpha:1.0] set]; +// [[NSColor colorWithCalibratedWhite:0.0 alpha:1.0-sqrt(i)*0.25] set]; + [[NSColor colorWithCalibratedRed:redComponent green:greenComponent blue:blueComponent alpha:1.0-sqrt(i)*0.25] set]; + outer = NSMakePoint(center.x+cos(a)*outerRadius, center.y+sin(a)*outerRadius); + inner = NSMakePoint(center.x+cos(a)*innerRadius, center.y+sin(a)*innerRadius); + [NSBezierPath strokeLineFromPoint:inner toPoint:outer]; + a -= flipFactor*30*DEG2RAD; + } + // restore previous defaults + [NSBezierPath setDefaultLineCapStyle:previousLineCapStyle]; + [NSBezierPath setDefaultLineWidth:previousLineWidth]; + } +} + +- (void)setObjectValue:(id)value +{ + if ([value respondsToSelector:@selector(boolValue)]) { + [self setSpinning:[value boolValue]]; + } else { + [self setSpinning:NO]; + } +} + + +@end diff --git a/Source/TableContent.m b/Source/TableContent.m index c84ee3c7..8bcf4942 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1400,7 +1400,7 @@ NSMutableString *argument = [NSMutableString string]; // NSString *columnType; NSArray *columnNames; - int i,j; + int i; if ( row == -1 ) return @""; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index b160cb33..60683331 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -158,10 +158,12 @@ B5E92F400F75B32100012500 /* toolbar-export-xml.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B5E92F3A0F75B32100012500 /* toolbar-export-xml.tiff */; }; B5EAC0FD0EC87FF900CC579C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5EAC0FC0EC87FF900CC579C /* Security.framework */; }; B5F4F7810F7BCF990059AE84 /* toolbar-switch-to-procedures.tiff in Resources */ = {isa = PBXBuildFile; fileRef = B5F4F7800F7BCF990059AE84 /* toolbar-switch-to-procedures.tiff */; }; + BC05F1C5101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BC05F1C4101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.m */; }; BC1847EA0FE6EC8400094BFB /* SPEditSheetTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC1847E90FE6EC8400094BFB /* SPEditSheetTextView.m */; }; BC1E55C4100DC92200AAE9F0 /* table-view-small-square.tiff in Resources */ = {isa = PBXBuildFile; fileRef = BC1E55C3100DC92200AAE9F0 /* table-view-small-square.tiff */; }; BC2C16D40FEBEDF10003993B /* SPDataAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = BC2C16D30FEBEDF10003993B /* SPDataAdditions.m */; }; BC2C8E220FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html in Resources */ = {isa = PBXBuildFile; fileRef = BC2C8E210FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html */; }; + BC688D811012462600D35128 /* borderlessbackground.png in Resources */ = {isa = PBXBuildFile; fileRef = BC688D801012462600D35128 /* borderlessbackground.png */; }; BC8C8532100E0A8000D7A129 /* SPTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = BC8C8531100E0A8000D7A129 /* SPTableView.m */; }; BC9F0881100FCF2C00A80D32 /* SPFieldEditorController.m in Sources */ = {isa = PBXBuildFile; fileRef = BC9F0880100FCF2C00A80D32 /* SPFieldEditorController.m */; }; BCA6F631100FA7D700E80253 /* FieldEditorSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = BCA6F62F100FA7D700E80253 /* FieldEditorSheet.xib */; }; @@ -456,12 +458,15 @@ B5E92F3A0F75B32100012500 /* toolbar-export-xml.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "toolbar-export-xml.tiff"; sourceTree = ""; }; B5EAC0FC0EC87FF900CC579C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; B5F4F7800F7BCF990059AE84 /* toolbar-switch-to-procedures.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "toolbar-switch-to-procedures.tiff"; sourceTree = ""; }; + BC05F1C3101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AMIndeterminateProgressIndicatorCell.h; sourceTree = ""; }; + BC05F1C4101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AMIndeterminateProgressIndicatorCell.m; sourceTree = ""; }; BC1847E80FE6EC8400094BFB /* SPEditSheetTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPEditSheetTextView.h; sourceTree = ""; }; BC1847E90FE6EC8400094BFB /* SPEditSheetTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPEditSheetTextView.m; sourceTree = ""; }; BC1E55C3100DC92200AAE9F0 /* table-view-small-square.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "table-view-small-square.tiff"; sourceTree = ""; }; BC2C16D20FEBEDF10003993B /* SPDataAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDataAdditions.h; sourceTree = ""; }; BC2C16D30FEBEDF10003993B /* SPDataAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDataAdditions.m; sourceTree = ""; }; BC2C8E210FA8C2DB008468C7 /* sequel-pro-mysql-help-template.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "sequel-pro-mysql-help-template.html"; sourceTree = ""; }; + BC688D801012462600D35128 /* borderlessbackground.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = borderlessbackground.png; sourceTree = ""; }; BC8C8530100E0A8000D7A129 /* SPTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPTableView.h; sourceTree = ""; }; BC8C8531100E0A8000D7A129 /* SPTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPTableView.m; sourceTree = ""; }; BC9F087F100FCF2C00A80D32 /* SPFieldEditorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPFieldEditorController.h; sourceTree = ""; }; @@ -753,6 +758,8 @@ 17E641710EF01F5C001BC333 /* GUI */ = { isa = PBXGroup; children = ( + BC05F1C3101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.h */, + BC05F1C4101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.m */, 17E6417C0EF01FA8001BC333 /* CMCopyTable.h */, 17E6417D0EF01FA8001BC333 /* CMCopyTable.m */, 17E6417E0EF01FA8001BC333 /* CMImageView.h */, @@ -784,6 +791,7 @@ 17E6418B0EF01FF7001BC333 /* Images */ = { isa = PBXGroup; children = ( + BC688D801012462600D35128 /* borderlessbackground.png */, BC1E55C3100DC92200AAE9F0 /* table-view-small-square.tiff */, 177E792B0FCB54EC00E9E122 /* database-small.png */, 177E792C0FCB54EC00E9E122 /* dummy-small.png */, @@ -1181,6 +1189,7 @@ 58D2E22E101222870063EF1D /* link-arrow-clicked.png in Resources */, 58D2E22F101222870063EF1D /* link-arrow-highlighted.png in Resources */, 58D2E230101222870063EF1D /* link-arrow.png in Resources */, + BC688D811012462600D35128 /* borderlessbackground.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1292,6 +1301,7 @@ BC8C8532100E0A8000D7A129 /* SPTableView.m in Sources */, BC9F0881100FCF2C00A80D32 /* SPFieldEditorController.m in Sources */, 58D2E229101222670063EF1D /* SPTextAndLinkCell.m in Sources */, + BC05F1C5101241DF008A97F8 /* AMIndeterminateProgressIndicatorCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; -- cgit v1.2.3