From d5f011e9f553670de4d5408f5e96e23a4a84b904 Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Sun, 25 Jul 2010 14:45:41 -0700 Subject: [PATCH] fixes for dashboard --- .../examples/table_view_api_controls.js | 2 +- .../examples/vertical_layout_table_view.js | 2 +- iphone/Classes/LauncherButton.m | 26 ++++++++++++++++--- iphone/Classes/LauncherItem.h | 4 ++- iphone/Classes/LauncherItem.m | 10 ++++++- iphone/Classes/TiUIDashboardItem.h | 19 ++++++++++++++ iphone/Classes/TiUIDashboardItem.m | 16 ++++++++++++ iphone/Classes/TiUIDashboardItemProxy.h | 4 +-- iphone/Classes/TiUIDashboardItemProxy.m | 16 ++++++++++++ iphone/Classes/TiUIDashboardView.h | 1 - iphone/Classes/TiUIDashboardView.m | 10 +++---- iphone/Classes/TiUIiPadPopoverProxy.m | 8 +++--- .../iphone/Titanium.xcodeproj/project.pbxproj | 8 ++++++ 13 files changed, 105 insertions(+), 21 deletions(-) create mode 100644 iphone/Classes/TiUIDashboardItem.h create mode 100644 iphone/Classes/TiUIDashboardItem.m diff --git a/demos/KitchenSink/Resources/examples/table_view_api_controls.js b/demos/KitchenSink/Resources/examples/table_view_api_controls.js index 2cfae0af610..0e6508289fc 100644 --- a/demos/KitchenSink/Resources/examples/table_view_api_controls.js +++ b/demos/KitchenSink/Resources/examples/table_view_api_controls.js @@ -23,7 +23,7 @@ for (var c=0;c<10;c++) { Ti.API.info("button click on row. index = "+e.index+", row = "+e.source.row+", section = "+e.source.section+",rightButton = "+rightButton); }); - var row = Ti.UI.createTableViewRow({height:'auto'}); + var row = Ti.UI.createTableViewRow({height:'auto',className:'row'}); row.add(label); row.add(rightButton); data[c].add(row); diff --git a/demos/KitchenSink/Resources/examples/vertical_layout_table_view.js b/demos/KitchenSink/Resources/examples/vertical_layout_table_view.js index 31a302f48d7..af075a098bd 100644 --- a/demos/KitchenSink/Resources/examples/vertical_layout_table_view.js +++ b/demos/KitchenSink/Resources/examples/vertical_layout_table_view.js @@ -10,7 +10,7 @@ var data = []; for (var i=0;i<50;i++) { - var row = Ti.UI.createTableViewRow({height:'auto'}); + var row = Ti.UI.createTableViewRow({height:'auto',className:"row"}); var textView = Ti.UI.createView({ height:'auto', diff --git a/iphone/Classes/LauncherButton.m b/iphone/Classes/LauncherButton.m index 96a3927c556..5f71b1fcdf9 100644 --- a/iphone/Classes/LauncherButton.m +++ b/iphone/Classes/LauncherButton.m @@ -32,6 +32,8 @@ #import #import "LauncherButton.h" #import "LauncherItem.h" +#import "TiUtils.h" +#import "TiUIView.h" @implementation LauncherButton @@ -56,6 +58,15 @@ -(void)dealloc [super dealloc]; } +-(void)setFrame:(CGRect)frame +{ + [super setFrame:frame]; + if (item.view!=nil) + { + [(TiUIView*)item.view relayout:self.bounds]; + } +} + -(void)setItem:(LauncherItem *)item_ { if (item!=nil) @@ -69,10 +80,19 @@ -(void)setItem:(LauncherItem *)item_ { item = [item_ retain]; item.button = self; - [self setImage:item.image forState:UIControlStateNormal]; - if (item.selectedImage!=nil) + + if (item.view!=nil) { - [self setImage:item.selectedImage forState:UIControlStateHighlighted]; + item.view.userInteractionEnabled = NO; + [self addSubview:item.view]; + } + else + { + [self setImage:item.image forState:UIControlStateNormal]; + if (item.selectedImage!=nil) + { + [self setImage:item.selectedImage forState:UIControlStateHighlighted]; + } } } [self setNeedsLayout]; diff --git a/iphone/Classes/LauncherItem.h b/iphone/Classes/LauncherItem.h index 4e8025cd914..27dae0ad442 100644 --- a/iphone/Classes/LauncherItem.h +++ b/iphone/Classes/LauncherItem.h @@ -40,15 +40,17 @@ NSInteger badgeValue; BOOL canDelete; LauncherButton *button; - + UIView *view; id userData; } @property(nonatomic,readwrite,retain) NSString *title; @property(nonatomic,readwrite,retain) UIImage *image; @property(nonatomic,readwrite,retain) UIImage *selectedImage; +@property(nonatomic,readwrite,retain) UIView *view; @property(nonatomic,assign) LauncherButton *button; + @property(nonatomic,readwrite,retain) id userData; diff --git a/iphone/Classes/LauncherItem.m b/iphone/Classes/LauncherItem.m index afaed3a5ae6..00579261e38 100644 --- a/iphone/Classes/LauncherItem.m +++ b/iphone/Classes/LauncherItem.m @@ -35,7 +35,7 @@ @implementation LauncherItem -@synthesize title, canDelete, badgeValue, image, selectedImage, button, userData; +@synthesize title, canDelete, badgeValue, image, selectedImage, button, userData, view; -(id)init { @@ -53,6 +53,7 @@ -(void)dealloc [image release]; [selectedImage release]; [userData release]; + [view release]; [super dealloc]; } @@ -90,6 +91,13 @@ -(void)setButton:(LauncherButton *)button_ [self repaint]; } +-(void)setView:(UIView*)view_ +{ + [view release]; + view = [view_ retain]; + [self repaint]; +} + @end diff --git a/iphone/Classes/TiUIDashboardItem.h b/iphone/Classes/TiUIDashboardItem.h new file mode 100644 index 00000000000..9ca78115de1 --- /dev/null +++ b/iphone/Classes/TiUIDashboardItem.h @@ -0,0 +1,19 @@ +/** + * Appcelerator Titanium Mobile + * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ +#ifdef USE_TI_UIDASHBOARDVIEW + +#import "TiUIView.h" + +@interface TiUIDashboardItem : TiUIView { + +@private + +} + +@end + +#endif \ No newline at end of file diff --git a/iphone/Classes/TiUIDashboardItem.m b/iphone/Classes/TiUIDashboardItem.m new file mode 100644 index 00000000000..c4e9d32d4eb --- /dev/null +++ b/iphone/Classes/TiUIDashboardItem.m @@ -0,0 +1,16 @@ +/** + * Appcelerator Titanium Mobile + * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ +#ifdef USE_TI_UIDASHBOARDVIEW + +#import "TiUIDashboardItem.h" +#import "TiUtils.h" + +@implementation TiUIDashboardItem + +@end + +#endif \ No newline at end of file diff --git a/iphone/Classes/TiUIDashboardItemProxy.h b/iphone/Classes/TiUIDashboardItemProxy.h index 38991ee5f88..3edc801bf1e 100644 --- a/iphone/Classes/TiUIDashboardItemProxy.h +++ b/iphone/Classes/TiUIDashboardItemProxy.h @@ -6,10 +6,10 @@ */ #ifdef USE_TI_UIDASHBOARDVIEW -#import "TiProxy.h" +#import "TiViewProxy.h" #import "LauncherItem.h" -@interface TiUIDashboardItemProxy : TiProxy { +@interface TiUIDashboardItemProxy : TiViewProxy { @private LauncherItem *item; } diff --git a/iphone/Classes/TiUIDashboardItemProxy.m b/iphone/Classes/TiUIDashboardItemProxy.m index 44d2f6c979e..9430932dd50 100644 --- a/iphone/Classes/TiUIDashboardItemProxy.m +++ b/iphone/Classes/TiUIDashboardItemProxy.m @@ -64,6 +64,22 @@ -(void)setCanDelete:(id)value [[self ensureItem] setCanDelete:canDelete]; } +#pragma mark internal + +-(void)add:(id)child +{ + [super add:child]; + + // called when we have a child, which means we want to use ourself + // as the view + LauncherItem *item_ = [self ensureItem]; + if (item_.view==nil) + { + [item_ setView:[self view]]; + } +} + + @end #endif \ No newline at end of file diff --git a/iphone/Classes/TiUIDashboardView.h b/iphone/Classes/TiUIDashboardView.h index 88512c204ec..dc6301c5630 100644 --- a/iphone/Classes/TiUIDashboardView.h +++ b/iphone/Classes/TiUIDashboardView.h @@ -12,7 +12,6 @@ @interface TiUIDashboardView : TiUIView { @private - UIView *wrapper; LauncherView *launcher; } diff --git a/iphone/Classes/TiUIDashboardView.m b/iphone/Classes/TiUIDashboardView.m index f3339545d77..1b42742762a 100644 --- a/iphone/Classes/TiUIDashboardView.m +++ b/iphone/Classes/TiUIDashboardView.m @@ -19,22 +19,18 @@ @implementation TiUIDashboardView -(void)dealloc { + launcher.delegate = nil; RELEASE_TO_NIL(launcher); [super dealloc]; } -(LauncherView*)launcher { - if (wrapper==nil) - { - wrapper = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; - [self addSubview:wrapper]; - } if (launcher==nil) { launcher = [[LauncherView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)]; launcher.delegate = self; - [wrapper addSubview:launcher]; + [self addSubview:launcher]; } return launcher; } @@ -43,7 +39,7 @@ -(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds { if (!CGRectIsEmpty(bounds)) { - [TiUtils setView:wrapper positionRect:bounds]; + [TiUtils setView:launcher positionRect:bounds]; } } diff --git a/iphone/Classes/TiUIiPadPopoverProxy.m b/iphone/Classes/TiUIiPadPopoverProxy.m index 8cc08abcb16..de9ca28df55 100644 --- a/iphone/Classes/TiUIiPadPopoverProxy.m +++ b/iphone/Classes/TiUIiPadPopoverProxy.m @@ -35,15 +35,15 @@ -(void)refreshTitleBarWithObject:(id)properties } ENSURE_UI_THREAD_1_ARG(properties); - BOOL animated = [TiUtils boolValue:@"animated" properties:properties def:YES]; + BOOL animated_ = [TiUtils boolValue:@"animated" properties:properties def:YES]; UINavigationItem * ourItem = [viewController navigationItem]; [ourItem setTitle:[TiUtils stringValue:[self valueForKey:@"title"]]]; - [ourItem setLeftBarButtonItem:[[self valueForKey:@"leftNavButton"] barButtonItem] animated:animated]; - [ourItem setRightBarButtonItem:[[self valueForKey:@"rightNavButton"] barButtonItem] animated:animated]; + [ourItem setLeftBarButtonItem:[[self valueForKey:@"leftNavButton"] barButtonItem] animated:animated_]; + [ourItem setRightBarButtonItem:[[self valueForKey:@"rightNavButton"] barButtonItem] animated:animated_]; - [[self navigationController] setNavigationBarHidden:[TiUtils boolValue:[self valueForKey:@"navBarHidden"]] animated:animated]; + [[self navigationController] setNavigationBarHidden:[TiUtils boolValue:[self valueForKey:@"navBarHidden"]] animated:animated_]; } diff --git a/iphone/iphone/Titanium.xcodeproj/project.pbxproj b/iphone/iphone/Titanium.xcodeproj/project.pbxproj index 19ac3e03dbb..6c3c96d651e 100755 --- a/iphone/iphone/Titanium.xcodeproj/project.pbxproj +++ b/iphone/iphone/Titanium.xcodeproj/project.pbxproj @@ -23,6 +23,8 @@ 242E989A11BAF7DB0046A0D0 /* TiDebuggerCallFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 242E989911BAF7DB0046A0D0 /* TiDebuggerCallFrame.mm */; }; 242E989B11BAF7DB0046A0D0 /* TiDebuggerCallFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 242E989911BAF7DB0046A0D0 /* TiDebuggerCallFrame.mm */; }; 242EA11611BD956F0046A0D0 /* ExternalAccessory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 242EA11511BD956F0046A0D0 /* ExternalAccessory.framework */; }; + 243AAFB511FCE62600E37D8B /* TiUIDashboardItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 243AAFB411FCE62600E37D8B /* TiUIDashboardItem.m */; }; + 243AAFB611FCE62600E37D8B /* TiUIDashboardItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 243AAFB411FCE62600E37D8B /* TiUIDashboardItem.m */; }; 243ECCAA1126981C00639DF4 /* TiUITableViewSectionProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 243EC5EA112617F900639DF4 /* TiUITableViewSectionProxy.m */; }; 243ECCAB1126981C00639DF4 /* TiUITableViewStyleProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 243EC9691126632700639DF4 /* TiUITableViewStyleProxy.m */; }; 243ECCAC1126981C00639DF4 /* TiUITableViewSeparatorStyleProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 243ECB2411267CC100639DF4 /* TiUITableViewSeparatorStyleProxy.m */; }; @@ -552,6 +554,8 @@ 242E989811BAF7DB0046A0D0 /* TiDebuggerCallFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TiDebuggerCallFrame.h; path = ../Classes/TiDebuggerCallFrame.h; sourceTree = SOURCE_ROOT; }; 242E989911BAF7DB0046A0D0 /* TiDebuggerCallFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TiDebuggerCallFrame.mm; path = ../Classes/TiDebuggerCallFrame.mm; sourceTree = SOURCE_ROOT; }; 242EA11511BD956F0046A0D0 /* ExternalAccessory.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ExternalAccessory.framework; path = System/Library/Frameworks/ExternalAccessory.framework; sourceTree = SDKROOT; }; + 243AAFB311FCE62500E37D8B /* TiUIDashboardItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiUIDashboardItem.h; sourceTree = ""; }; + 243AAFB411FCE62600E37D8B /* TiUIDashboardItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiUIDashboardItem.m; sourceTree = ""; }; 243EC5E9112617F900639DF4 /* TiUITableViewSectionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiUITableViewSectionProxy.h; sourceTree = ""; }; 243EC5EA112617F900639DF4 /* TiUITableViewSectionProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TiUITableViewSectionProxy.m; sourceTree = ""; }; 243EC7D5112634AF00639DF4 /* TiUITableViewAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TiUITableViewAction.h; sourceTree = ""; }; @@ -2126,6 +2130,8 @@ 24E50E2A116066B400AF54AF /* TiUIDashboardView.m */, 24E50F8A1160792D00AF54AF /* TiUIDashboardItemProxy.h */, 24E50F8B1160792D00AF54AF /* TiUIDashboardItemProxy.m */, + 243AAFB311FCE62500E37D8B /* TiUIDashboardItem.h */, + 243AAFB411FCE62600E37D8B /* TiUIDashboardItem.m */, ); name = Dashboard; sourceTree = ""; @@ -2673,6 +2679,7 @@ 24F1591E11D7356D000DD736 /* TiMapRouteAnnotationView.m in Sources */, 2467310811E2549300D39AF7 /* Webcolor.m in Sources */, 2465592411E5862F0059BBF4 /* TiFilesystemBlobProxy.m in Sources */, + 243AAFB511FCE62600E37D8B /* TiUIDashboardItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2917,6 +2924,7 @@ 24F1591D11D7356D000DD736 /* TiMapRouteAnnotationView.m in Sources */, 2467310711E2549300D39AF7 /* Webcolor.m in Sources */, 2465592511E5862F0059BBF4 /* TiFilesystemBlobProxy.m in Sources */, + 243AAFB611FCE62600E37D8B /* TiUIDashboardItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };