From e976f3580288b1eef3c441636fab982fab5fee53 Mon Sep 17 00:00:00 2001 From: Nick Takayama Date: Fri, 24 Oct 2008 20:30:21 +0800 Subject: [PATCH] removing CPKulerPicker as per ticket 64 Signed-off-by: Nick Takayama --- AppKit/CPColorPanel.j | 44 +----- AppKit/CPKulerColorPicker.j | 372 ------------------------------------------- 2 files changed, 4 insertions(+), 412 deletions(-) delete mode 100644 AppKit/CPKulerColorPicker.j diff --git a/AppKit/CPColorPanel.j b/AppKit/CPColorPanel.j index 12fe58f..58cdbed 100644 --- a/AppKit/CPColorPanel.j +++ b/AppKit/CPColorPanel.j @@ -23,7 +23,6 @@ import "CPButton.j" import "CPColorPicker.j" import "CPCookie.j" -import "CPKulerColorPicker.j" import "CPPanel.j" import "CPSliderColorPicker.j" import "CPView.j" @@ -44,17 +43,11 @@ var SharedColorPanel = nil; */ CPWheelColorPickerMode = 1; /* - Kuler color picker - @global - @group CPColorPanelMode -*/ -CPKulerColorPickerMode = 2; -/* Slider based picker @global @group CPColorPanelMode */ -CPSliderColorPickerMode = 3; +CPSliderColorPickerMode = 2; CPColorPickerViewWidth = 265, CPColorPickerViewHeight = 370; @@ -74,11 +67,10 @@ CPColorPickerViewHeight = 370; CPTextField _previewLabel; CPTextField _swatchLabel; - CPView _activeView; + CPView _currentView; CPColorPicker _activePicker; CPColorPicker _wheelPicker; - CPColorPicker _kulerPicker; CPColorPicker _sliderPicker; CPColor _color; @@ -225,7 +217,6 @@ CPColorPickerViewHeight = 370; switch(mode) { case CPWheelColorPickerMode: _activePicker = _wheelPicker; break; - case CPKulerColorPickerMode: _activePicker = _kulerPicker; break; case CPSliderColorPickerMode: _activePicker = _sliderPicker; break; } @@ -310,9 +301,6 @@ CPColorPickerViewHeight = 370; [_currentView setFrameOrigin: CPPointMake(5, TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5+SWATCH_HEIGHT+10)]; [_currentView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)]; - _kulerPicker = [[CPKulerColorPicker alloc] initWithPickerMask: 1|2|3 colorPanel: self]; - [_kulerPicker provideNewView: YES]; - _sliderPicker = [[CPSliderColorPicker alloc] initWithPickerMask: 1|2|3 colorPanel: self]; [_sliderPicker provideNewView: YES]; @@ -335,7 +323,7 @@ CPColorPickerViewHeight = 370; @end var iconSize = 32, - totalIcons = 3; + totalIcons = 2; /* @ignore */ @implementation _CPColorPanelToolbar : CPView @@ -347,10 +335,6 @@ var iconSize = 32, CPImage _sliderImage; CPImage _sliderAlternateImage; CPButton _sliderButton; - - CPImage _kulerImage; - CPImage _kulerAlternateImage; - CPButton _kulerButton; } - (id)initWithFrame:(CPRect)aFrame @@ -399,32 +383,12 @@ var iconSize = 32, [self addSubview: _sliderButton]; - _kulerButton = [[CPButton alloc] initWithFrame:CPRectMake(start, 0, iconSize, iconSize)]; - start += iconSize + 8; - - path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"kuler_button.png"]; - _kulerImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)]; - - path = [[CPBundle bundleForClass: _CPColorPanelToolbar] pathForResource:@"kuler_button_h.png"]; - _kulerAlternateImage = [[CPImage alloc] initWithContentsOfFile:path size: CPSizeMake(iconSize, iconSize)]; - - [_kulerButton setBordered:NO]; - [_kulerButton setImage: _kulerImage]; - [_kulerButton setAlternateImage: _kulerAlternateImage]; - [_kulerButton setTarget: self]; - [_kulerButton setAction: @selector(setMode:)]; - [_kulerButton setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin]; - - [self addSubview: _kulerButton]; - return self; } - (void)setMode:(id)sender { - if(sender == _kulerButton) - [[CPColorPanel sharedColorPanel] setMode: CPKulerColorPickerMode]; - else if(sender == _wheelButton) + if(sender == _wheelButton) [[CPColorPanel sharedColorPanel] setMode: CPWheelColorPickerMode]; else [[CPColorPanel sharedColorPanel] setMode: CPSliderColorPickerMode]; diff --git a/AppKit/CPKulerColorPicker.j b/AppKit/CPKulerColorPicker.j deleted file mode 100644 index 2e3f649..0000000 --- a/AppKit/CPKulerColorPicker.j +++ /dev/null @@ -1,372 +0,0 @@ -/* - * CPApplication.j - * AppKit - * - * Created by Ross Boucher. - * Copyright 2008, 280 North, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -import - -import "CPView.j" -import "CPButton.j" -import "CPImage.j" -import "CPImageView.j" -import "CPColorPicker.j" -import "CPColorPanel.j" -import "CPTabView.j" -import "CPTabViewItem.j" - - -/* - @ignore -*/ -@implementation CPKulerColorPicker : CPColorPicker -{ - CPView _contentView; - CPTabView _tabView; - - CPScrollView _searchView; - CPScrollView _popularView; - - CPView _searchView; - DOMElement _FIXME_searchField; - - CPURLConnection _searchConnection; - CPURLConnection _popularConnection -} - -- (id)initWithPickerMask:(int)mask colorPanel:(CPColorPanel)owningColorPanel -{ - return [super initWithPickerMask:mask colorPanel: owningColorPanel]; -} - --(id)initView -{ - aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight); - _contentView = [[CPView alloc] initWithFrame:aFrame]; - - _tabView = [[CPTabView alloc] initWithFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(aFrame), CGRectGetHeight(aFrame) - 20)]; - [_tabView setAutoresizingMask: CPViewWidthSizable | CPViewHeightSizable]; - [_tabView setDelegate: self]; - [_contentView addSubview: _tabView]; - - var label = [[CPButton alloc] initWithFrame:CPRectMake((CPColorPickerViewWidth-150)/2, CPColorPickerViewHeight-20, 150, 20)]; - [label setAutoresizingMask: CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin]; - [label setFont:[CPFont boldSystemFontOfSize:10.0]]; - [label setTextColor: [CPColor whiteColor]]; - [label setTitle: @"Powered by Adobe Kuler"]; - [label setTarget: self]; - [label setAction: @selector(openKulerLink:)]; - [label setBordered: NO]; - [_contentView addSubview: label]; - - var searchThemeView = [[_CPKulerThemeView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, 0)]; - [searchThemeView setDelegate: self]; - [searchThemeView setAutoresizingMask: CPViewWidthSizable]; - - _searchView = [[CPScrollView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, CPColorPickerViewHeight - 10)]; - [_searchView setDocumentView: searchThemeView]; - [_searchView setHasHorizontalScroller: NO]; - [_searchView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)]; - [[_searchView verticalScroller] setControlSize:CPSmallControlSize]; - [_searchView setAutohidesScrollers:YES]; - - var auxiliarySearchView = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, CPColorPickerViewWidth, 26.0)]; - [auxiliarySearchView setAutoresizingMask: (CPViewMinYMargin | CPViewWidthSizable)]; - - _FIXME_searchField = document.createElement("input"); - - if(!window.addEventListener) - _FIXME_searchField.type = "text"; - else - _FIXME_searchField.type = "search"; - - _FIXME_searchField.style.position = "absolute"; - _FIXME_searchField.style.width = "96%"; - _FIXME_searchField.style.left = "2%"; - _FIXME_searchField.style.top = "2px"; - _FIXME_searchField.onkeypress = function(aDOMEvent) - { - aDOMEvent = aDOMEvent || window.event; - if (aDOMEvent.keyCode == 13) - { - [self search]; - - if(aDOMEvent.preventDefault) - aDOMEvent.preventDefault(); - else if(aDOMEvent.stopPropagation) - aDOMEvent.stopPropagation(); - - _FIXME_searchField.blur(); - } - }; - - auxiliarySearchView._DOMElement.appendChild(_FIXME_searchField); - - var popularThemeView = [[_CPKulerThemeView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, 0)]; - [popularThemeView setDelegate: self]; - [popularThemeView setAutoresizingMask: CPViewWidthSizable]; - - _popularView = [[CPScrollView alloc] initWithFrame: CPRectMake(0, 0, aFrame.size.width, CPColorPickerViewHeight)]; - [_popularView setDocumentView: popularThemeView]; - [_popularView setHasHorizontalScroller: NO]; - [_popularView setAutoresizingMask: (CPViewWidthSizable | CPViewHeightSizable)]; - [[_popularView verticalScroller] setControlSize:CPSmallControlSize]; - [_popularView setAutohidesScrollers:YES]; - - var mostPopularItem = [[CPTabViewItem alloc] initWithIdentifier:@"Popular"]; - var searchItem = [[CPTabViewItem alloc] initWithIdentifier:@"Search"]; - - [searchItem setLabel:@"Search"]; - [searchItem setView:_searchView]; - [searchItem setAuxiliaryView: auxiliarySearchView]; - - [mostPopularItem setLabel:@"Popular"]; - [mostPopularItem setView: _popularView]; - - [_tabView addTabViewItem: mostPopularItem]; - [_tabView addTabViewItem: searchItem]; - - [self popularThemes]; -} - -- (void)openKulerLink:(id)sender -{ - window.open("http://kuler.adobe.com"); -} - -- (CPView)provideNewView:(BOOL)initialRequest -{ - if (initialRequest) - [self initView]; - - return _contentView; -} - -- (int)currentMode -{ - return CPKulerColorPickerMode; -} - -- (BOOL)supportsMode:(int)mode -{ - return (mode == CPKulerColorPickerMode) ? YES : NO; -} - --(void)search -{ - var query = escape(_FIXME_searchField.value); - - if(query.replace("%20", "") == "") - return; - - [_searchConnection cancel]; - - _searchConnection = nil; - _searchConnection = [CPURLConnection connectionWithRequest: - [CPURLRequest requestWithURL: BASE_URL + "kuler.php?mode=search&query="+query] - delegate: self]; -} - --(void)popularThemes -{ - [_popularConnection cancel]; - _popularConnection = nil; - _popularConnection = [CPURLConnection connectionWithRequest: - [CPURLRequest requestWithURL: BASE_URL + "kuler.php?mode=popular"] delegate: self]; -} - -/* --(void)topRatedThemes -{ - _connection = [CPURLConnection connectionWithRequest: - [CPURLRequest requestWithURL: BASE_URL + "kuler.php?mode=rating"] delegate:self]; -} -*/ - -- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data -{ - var data = CPJSObjectCreateWithJSON(data); - - if(!data) - var themes = []; - else - var themes = data.result; - - if(aConnection == _popularConnection) - [[_popularView documentView] setThemes: themes]; - - if(aConnection == _searchConnection) - [[_searchView documentView] setThemes: themes]; -} - -- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError -{ - [self connectionDidFinishLoading:aConnection]; -} - --(void)connectionDidFinishLoading:(CPURLConnection)aConnection -{ - -} - --(void)chooseColor:(CPColor)aColor -{ - [[self colorPanel] setColor: aColor]; -} - -@end - -/* @ignore */ -@implementation _CPKulerThemeView : CPView -{ - CPArray _themes; - id _delegate; - - CPColor _alternateBGColor; -} - --(id)initWithFrame:(CPRect)aFrame -{ - self = [super initWithFrame:aFrame]; - - _alternateBGColor = [CPColor colorWithCalibratedRed: 241.0/255.0 green: 245.0/255.0 blue: 250.0/255.0 alpha: 1.0]; - - return self; -} - --(id)delegate -{ - return _delegate; -} - --(void)setDelegate:(id)delegate -{ - _delegate = delegate; -} - --(CPArray)themes -{ - return _themes; -} - --(void)setThemes:(CPArray)themes -{ - _themes = themes; - [self updateDisplay]; -} - --(void)updateDisplay -{ - var width = [self frame].size.width; - - var subviews = [self subviews]; - for(var i = [subviews count]-1; i >= 0; --i) - [subviews[i] removeFromSuperview]; - - for(var i=0, count = [_themes count]; i