diff options
Diffstat (limited to 'iphone/Maps/Classes')
-rw-r--r-- | iphone/Maps/Classes/EAGLView.h | 13 | ||||
-rw-r--r-- | iphone/Maps/Classes/EAGLView.mm | 19 | ||||
-rw-r--r-- | iphone/Maps/Classes/GuideView.xib | 343 | ||||
-rw-r--r-- | iphone/Maps/Classes/GuideViewController.h | 24 | ||||
-rw-r--r-- | iphone/Maps/Classes/GuideViewController.mm | 148 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapViewController.h | 6 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapViewController.mm | 112 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapsAppDelegate.h | 15 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapsAppDelegate.mm | 55 | ||||
-rw-r--r-- | iphone/Maps/Classes/SearchVC.h | 22 | ||||
-rw-r--r-- | iphone/Maps/Classes/SearchVC.mm | 166 |
11 files changed, 243 insertions, 680 deletions
diff --git a/iphone/Maps/Classes/EAGLView.h b/iphone/Maps/Classes/EAGLView.h index ff9b0e7938..222ca3dd05 100644 --- a/iphone/Maps/Classes/EAGLView.h +++ b/iphone/Maps/Classes/EAGLView.h @@ -1,11 +1,3 @@ -// -// EAGLView.h -// chuchu_iphone -// -// Created by Yury Melnichek on 08.03.09. -// Copyright __MyCompanyName__ 2009. All rights reserved. -// - #import <UIKit/UIKit.h> #import <OpenGLES/EAGL.h> #import <OpenGLES/ES1/gl.h> @@ -51,11 +43,8 @@ namespace yg MapViewController * controller; } -/// Called as a result of invalidate on iphone::WindowHandle -- (void)drawView; -- (void)drawViewThunk:(id)obj; +// Called as a result of invalidate on iphone::WindowHandle - (void)drawViewOnMainThread; -- (void)onSize:(int)width withHeight:(int)height; @property (nonatomic, assign) MapViewController * controller; @property (nonatomic, assign) shared_ptr<iphone::WindowHandle> windowHandle; diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index e5d01fc5a6..efa3975aa2 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -13,11 +13,6 @@ #include "RenderBuffer.hpp" #include "RenderContext.hpp" -// A class extension to declare private methods -@interface EAGLView () - -@end - @implementation EAGLView @synthesize controller; @@ -132,8 +127,6 @@ windowHandle->setRenderContext(renderContext); } - self.multipleTouchEnabled = YES; - return self; } @@ -153,7 +146,6 @@ drawer->screen()->beginFrame(); drawer->screen()->clear(); drawer->screen()->endFrame(); - } - (void)drawView @@ -174,13 +166,10 @@ - (void)layoutSubviews { - CGFloat scaleFactor = 1.0; - if ([self respondsToSelector:@selector(contentScaleFactor)]) - scaleFactor = self.contentScaleFactor; - - [[self controller] onResize:self.frame.size.width * scaleFactor withHeight:self.frame.size.height * scaleFactor]; - [self onSize:self.frame.size.width * scaleFactor withHeight:self.frame.size.height * scaleFactor]; - // This crashes on iPad: [self drawView]; + CGFloat const scale = self.contentScaleFactor; + CGSize const s = self.frame.size; + [self.controller onResize:s.width * scale withHeight:s.height * scale]; + [self onSize:s.width * scale withHeight:s.height * scale]; } - (void)dealloc diff --git a/iphone/Maps/Classes/GuideView.xib b/iphone/Maps/Classes/GuideView.xib deleted file mode 100644 index 1d745e44e4..0000000000 --- a/iphone/Maps/Classes/GuideView.xib +++ /dev/null @@ -1,343 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10"> - <data> - <int key="IBDocument.SystemTarget">1056</int> - <string key="IBDocument.SystemVersion">10J869</string> - <string key="IBDocument.InterfaceBuilderVersion">1306</string> - <string key="IBDocument.AppKitVersion">1038.35</string> - <string key="IBDocument.HIToolboxVersion">461.00</string> - <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> - <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string key="NS.object.0">301</string> - </object> - <object class="NSArray" key="IBDocument.IntegratedClassDependencies"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>IBProxyObject</string> - <string>IBUIBarButtonItem</string> - <string>IBUIToolbar</string> - <string>IBUISearchBar</string> - <string>IBUISegmentedControl</string> - <string>IBUITableView</string> - <string>IBUIView</string> - </object> - <object class="NSArray" key="IBDocument.PluginDependencies"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - </object> - <object class="NSMutableDictionary" key="IBDocument.Metadata"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys" id="0"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> - <reference key="dict.values" ref="0"/> - </object> - <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBProxyObject" id="372490531"> - <string key="IBProxiedObjectIdentifier">IBFilesOwner</string> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - </object> - <object class="IBProxyObject" id="975951072"> - <string key="IBProxiedObjectIdentifier">IBFirstResponder</string> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - </object> - <object class="IBUIView" id="191373211"> - <reference key="NSNextResponder"/> - <int key="NSvFlags">274</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBUITableView" id="218186158"> - <reference key="NSNextResponder" ref="191373211"/> - <int key="NSvFlags">274</int> - <string key="NSFrame">{{0, 44}, {320, 372}}</string> - <reference key="NSSuperview" ref="191373211"/> - <object class="NSColor" key="IBUIBackgroundColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MQA</bytes> - </object> - <bool key="IBUIClipsSubviews">YES</bool> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <bool key="IBUIAlwaysBounceVertical">YES</bool> - <int key="IBUISeparatorStyle">1</int> - <int key="IBUISectionIndexMinimumDisplayRowCount">0</int> - <bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool> - <float key="IBUIRowHeight">44</float> - <float key="IBUISectionHeaderHeight">22</float> - <float key="IBUISectionFooterHeight">22</float> - </object> - <object class="IBUIToolbar" id="705821200"> - <reference key="NSNextResponder" ref="191373211"/> - <int key="NSvFlags">266</int> - <object class="NSMutableArray" key="NSSubviews"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBUISegmentedControl" id="200966199"> - <reference key="NSNextResponder" ref="705821200"/> - <int key="NSvFlags">292</int> - <string key="NSFrame">{{90, 8}, {140, 30}}</string> - <reference key="NSSuperview" ref="705821200"/> - <reference key="NSNextKeyView"/> - <bool key="IBUIOpaque">NO</bool> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <int key="IBSegmentControlStyle">2</int> - <int key="IBNumberOfSegments">2</int> - <int key="IBSelectedSegmentIndex">1</int> - <object class="NSArray" key="IBSegmentTitles"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>Map</string> - <string>Guide</string> - </object> - <object class="NSMutableArray" key="IBSegmentWidths"> - <bool key="EncodedWithXMLCoder">YES</bool> - <real value="0.0"/> - <real value="0.0"/> - </object> - <object class="NSMutableArray" key="IBSegmentEnabledStates"> - <bool key="EncodedWithXMLCoder">YES</bool> - <boolean value="YES"/> - <boolean value="YES"/> - </object> - <object class="NSMutableArray" key="IBSegmentContentOffsets"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>{0, 0}</string> - <string>{0, 0}</string> - </object> - <object class="NSMutableArray" key="IBSegmentImages"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSNull" id="4"/> - <reference ref="4"/> - </object> - </object> - </object> - <string key="NSFrame">{{0, 416}, {320, 44}}</string> - <reference key="NSSuperview" ref="191373211"/> - <reference key="NSNextKeyView" ref="200966199"/> - <bool key="IBUIOpaque">NO</bool> - <bool key="IBUIClearsContextBeforeDrawing">NO</bool> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <object class="NSMutableArray" key="IBUIItems"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBUIBarButtonItem" id="1014543794"> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <reference key="IBUIToolbar" ref="705821200"/> - <int key="IBUISystemItemIdentifier">5</int> - </object> - <object class="IBUIBarButtonItem" id="809087089"> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <int key="IBUIStyle">1</int> - <reference key="IBUICustomView" ref="200966199"/> - <reference key="IBUIToolbar" ref="705821200"/> - </object> - <object class="IBUIBarButtonItem" id="699616299"> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <reference key="IBUIToolbar" ref="705821200"/> - <int key="IBUISystemItemIdentifier">5</int> - </object> - </object> - </object> - <object class="IBUISearchBar" id="100183820"> - <reference key="NSNextResponder" ref="191373211"/> - <int key="NSvFlags">290</int> - <string key="NSFrameSize">{320, 44}</string> - <reference key="NSSuperview" ref="191373211"/> - <reference key="NSNextKeyView" ref="705821200"/> - <int key="IBUIContentMode">3</int> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - <string key="IBText"/> - <object class="IBUITextInputTraits" key="IBTextInputTraits"> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - </object> - </object> - </object> - <string key="NSFrame">{{0, 20}, {320, 460}}</string> - <reference key="NSSuperview"/> - <reference key="NSNextKeyView" ref="100183820"/> - <object class="NSColor" key="IBUIBackgroundColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MQA</bytes> - <object class="NSColorSpace" key="NSCustomColorSpace"> - <int key="NSID">2</int> - </object> - </object> - <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/> - <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> - </object> - </object> - <object class="IBObjectContainer" key="IBDocument.Objects"> - <object class="NSMutableArray" key="connectionRecords"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBConnectionRecord"> - <object class="IBCocoaTouchOutletConnection" key="connection"> - <string key="label">view</string> - <reference key="source" ref="372490531"/> - <reference key="destination" ref="191373211"/> - </object> - <int key="connectionID">3</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBCocoaTouchEventConnection" key="connection"> - <string key="label">OnMapClicked:</string> - <reference key="source" ref="200966199"/> - <reference key="destination" ref="372490531"/> - <int key="IBEventType">13</int> - </object> - <int key="connectionID">21</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBCocoaTouchOutletConnection" key="connection"> - <string key="label">searchBar</string> - <reference key="source" ref="372490531"/> - <reference key="destination" ref="100183820"/> - </object> - <int key="connectionID">23</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBCocoaTouchOutletConnection" key="connection"> - <string key="label">resultsView</string> - <reference key="source" ref="372490531"/> - <reference key="destination" ref="218186158"/> - </object> - <int key="connectionID">25</int> - </object> - </object> - <object class="IBMutableOrderedSet" key="objectRecords"> - <object class="NSArray" key="orderedObjects"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBObjectRecord"> - <int key="objectID">0</int> - <reference key="object" ref="0"/> - <reference key="children" ref="1000"/> - <nil key="parent"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-1</int> - <reference key="object" ref="372490531"/> - <reference key="parent" ref="0"/> - <string key="objectName">File's Owner</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">-2</int> - <reference key="object" ref="975951072"/> - <reference key="parent" ref="0"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">1</int> - <reference key="object" ref="191373211"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="705821200"/> - <reference ref="100183820"/> - <reference ref="218186158"/> - </object> - <reference key="parent" ref="0"/> - <string key="objectName">View</string> - </object> - <object class="IBObjectRecord"> - <int key="objectID">11</int> - <reference key="object" ref="705821200"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="809087089"/> - <reference ref="1014543794"/> - <reference ref="699616299"/> - </object> - <reference key="parent" ref="191373211"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">12</int> - <reference key="object" ref="809087089"/> - <object class="NSMutableArray" key="children"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="200966199"/> - </object> - <reference key="parent" ref="705821200"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">13</int> - <reference key="object" ref="1014543794"/> - <reference key="parent" ref="705821200"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">15</int> - <reference key="object" ref="699616299"/> - <reference key="parent" ref="705821200"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">17</int> - <reference key="object" ref="200966199"/> - <reference key="parent" ref="809087089"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">22</int> - <reference key="object" ref="100183820"/> - <reference key="parent" ref="191373211"/> - </object> - <object class="IBObjectRecord"> - <int key="objectID">24</int> - <reference key="object" ref="218186158"/> - <reference key="parent" ref="191373211"/> - </object> - </object> - </object> - <object class="NSMutableDictionary" key="flattenedProperties"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>-1.CustomClassName</string> - <string>-1.IBAttributePlaceholdersKey</string> - <string>-2.CustomClassName</string> - <string>1.IBEditorWindowLastContentRect</string> - <string>1.IBPluginDependency</string> - <string>11.IBPluginDependency</string> - <string>13.IBPluginDependency</string> - <string>15.IBPluginDependency</string> - <string>17.IBPluginDependency</string> - <string>17.IUISegmentedControlInspectorSelectedSegmentMetadataKey</string> - <string>22.IBPluginDependency</string> - <string>24.IBPluginDependency</string> - </object> - <object class="NSMutableArray" key="dict.values"> - <bool key="EncodedWithXMLCoder">YES</bool> - <string>GuideViewController</string> - <object class="NSMutableDictionary"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> - <reference key="dict.values" ref="0"/> - </object> - <string>UIResponder</string> - <string>{{556, 412}, {320, 480}}</string> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <integer value="1"/> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> - </object> - </object> - <object class="NSMutableDictionary" key="unlocalizedProperties"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> - <reference key="dict.values" ref="0"/> - </object> - <nil key="activeLocalization"/> - <object class="NSMutableDictionary" key="localizations"> - <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> - <reference key="dict.values" ref="0"/> - </object> - <nil key="sourceID"/> - <int key="maxID">25</int> - </object> - <object class="IBClassDescriber" key="IBDocument.Classes"/> - <int key="IBDocument.localizationMode">0</int> - <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string> - <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> - <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string> - <integer value="3000" key="NS.object.0"/> - </object> - <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> - <int key="IBDocument.defaultPropertyAccessControl">3</int> - <string key="IBCocoaTouchPluginVersion">301</string> - </data> -</archive> diff --git a/iphone/Maps/Classes/GuideViewController.h b/iphone/Maps/Classes/GuideViewController.h deleted file mode 100644 index 18e7b82f83..0000000000 --- a/iphone/Maps/Classes/GuideViewController.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// GuideViewController.h -// Maps -// -// Created by Yury Melnichek on 15.03.11. -// Copyright 2011 MapsWithMe. All rights reserved. -// - -#import <UIKit/UIKit.h> -#import "../../Sloynik/Shared/SearchVC.h" - -@interface GuideViewController : SearchVC -{ - UIActivityIndicatorView * activityIndicator; - UILabel * loadingLabel; -} - -@property (nonatomic, retain) UIActivityIndicatorView * activityIndicator; -@property (nonatomic, retain) UILabel * loadingLabel; - -- (IBAction)OnMapClicked:(id)sender; -- (void)OnSloynikEngineInitialized; - -@end diff --git a/iphone/Maps/Classes/GuideViewController.mm b/iphone/Maps/Classes/GuideViewController.mm deleted file mode 100644 index 36ce9620b1..0000000000 --- a/iphone/Maps/Classes/GuideViewController.mm +++ /dev/null @@ -1,148 +0,0 @@ -// -// GuideViewController.mm -// Maps -// -// Created by Yury Melnichek on 15.03.11. -// Copyright 2011 MapsWithMe. All rights reserved. -// - -#import "GuideViewController.h" -#import "MapsAppDelegate.h" -#import "MapViewController.h" -#import "ArticleVC.h" -#include "global.hpp" - -@implementation GuideViewController - -@synthesize activityIndicator; -@synthesize loadingLabel; - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) - { - // Custom initialization - } - return self; -} - -- (void)dealloc -{ - [super dealloc]; -} - -- (void)didReceiveMemoryWarning -{ - // Releases the view if it doesn't have a superview. - [super didReceiveMemoryWarning]; - - // Release any cached data, images, etc that aren't in use. -} - -- (IBAction)OnMapClicked:(id)sender -{ - UISegmentedControl * pSegmentedControl = (UISegmentedControl *)sender; - int const selectedIndex = pSegmentedControl.selectedSegmentIndex; - - if (selectedIndex != 1) - { - LOG(LINFO, (selectedIndex)); - [UIView transitionFromView:self.view - toView:[MapsAppDelegate theApp].mapViewController.view - duration:0 - options:UIViewAnimationOptionTransitionNone - completion:nil]; - [pSegmentedControl setSelectedSegmentIndex:1]; - } -} - -- (void)onEmptySearch -{ - // Do nothing. Don't hide the results view. -} - -- (void)willShowArticleVC:(ArticleVC *) viewController -{ - [super willShowArticleVC:viewController]; - viewController.articleFormat = @ - "<html>" - " <head>" - " <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>" - " <meta name='viewport' content='width=device-width; initial-scale=1.0; " - " maximum-scale=1.0; user-scalable=0;'/>" - " <style type='text/css'>" - " img, object { border:none; max-width:280px; height:auto; }" - " div { clear:both; }" - " div.thumbcaption div.magnify { display:none; }" - " div.thumbinner { padding:6px; margin:6px 0 0 0; border:1px solid #777;" - " -webkit-border-radius:6px;" - " font-size:12px; display:table; }" - " div#content h2 button { display:none; }" - " </style>" - " </head>" - " <body style='-webkit-text-size-adjust:%d%%'>" - " %@" - " </body>" - "</html>"; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view from its nib. - if (!GetSloynikEngine()) - { - CGRect frame = self.view.frame; - self.activityIndicator = [[[UIActivityIndicatorView alloc] - initWithFrame:CGRectMake(frame.origin.x + frame.size.width / 2 - 15, - 80, 30, 30)] autorelease]; - - [self.activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray]; - [self.view addSubview:self.activityIndicator]; - - self.loadingLabel = [[[UILabel alloc] - initWithFrame:CGRectMake(frame.origin.x + frame.size.width / 2 - 30, - 110, 60, 30)] autorelease]; - self.loadingLabel.text = @"Indexing..."; - self.loadingLabel.textAlignment = UITextAlignmentCenter; - self.loadingLabel.userInteractionEnabled = NO; - self.loadingLabel.numberOfLines = 1; - self.loadingLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - self.loadingLabel.adjustsFontSizeToFitWidth = YES; - [self.view addSubview:self.loadingLabel]; - - self.searchBar.hidden = YES; - self.resultsView.hidden = YES; - - [self.activityIndicator startAnimating]; - } -} - -- (void)viewDidUnload -{ - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; -} - -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation -{ - // Return YES for supported orientations - return YES; -} - -- (void)OnSloynikEngineInitialized -{ - if (self.activityIndicator) - { - [self.activityIndicator removeFromSuperview]; - [self.loadingLabel removeFromSuperview]; - self.activityIndicator = nil; - self.searchBar.hidden = NO; - self.resultsView.hidden = NO; - [self.resultsView reloadData]; - } -} - -@end diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index 094ac01919..03fea4f54a 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -24,7 +24,7 @@ m2::PointD m_Pt1, m_Pt2; - UIBarButtonItem * m_myPositionButton; + UIButton * m_myPositionButton; NSTimer * m_iconTimer; bool m_mapIsVisible; @@ -42,8 +42,8 @@ - (IBAction)OnMyPositionClicked:(id)sender; - (IBAction)OnSettingsClicked:(id)sender; -- (IBAction)OnGuideClicked:(id)sender; +- (IBAction)OnSearchClicked:(id)sender; -@property (nonatomic, retain) IBOutlet UIBarButtonItem * m_myPositionButton; +@property (nonatomic, retain) IBOutlet UIButton * m_myPositionButton; @end diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index a204df06ab..544910842f 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -1,5 +1,5 @@ #import "MapViewController.h" -#import "GuideViewController.h" +#import "SearchVC.h" #import "MapsAppDelegate.h" #import "EAGLView.h" #import "WindowHandle.h" @@ -30,55 +30,42 @@ storage::Storage m_storage; - (void)OnLocationUpdated { - m_myPositionButton.image = [UIImage imageNamed:@"location.png"]; + [m_myPositionButton setImage:[UIImage imageNamed:@"location.png"] forState:UIControlStateSelected]; } - (IBAction)OnMyPositionClicked:(id)sender -{ - if (((UIBarButtonItem *)sender).style == UIBarButtonItemStyleBordered) +{ + if (m_myPositionButton.isSelected == NO) { typedef void (*OnLocationUpdatedFunc)(id, SEL); SEL onLocUpdatedSel = @selector(OnLocationUpdated); OnLocationUpdatedFunc locUpdatedImpl = (OnLocationUpdatedFunc)[self methodForSelector:onLocUpdatedSel]; m_framework->StartLocationService(bind(locUpdatedImpl, self, onLocUpdatedSel)); - ((UIBarButtonItem *)sender).style = UIBarButtonItemStyleDone; - ((UIBarButtonItem *)sender).image = [UIImage imageNamed:@"location-search.png"]; + m_myPositionButton.selected = YES; + [m_myPositionButton setImage:[UIImage imageNamed:@"location-search.png"] forState:UIControlStateSelected]; [[MapsAppDelegate theApp] disableStandby]; } else { m_framework->StopLocationService(); - ((UIBarButtonItem *)sender).style = UIBarButtonItemStyleBordered; - m_myPositionButton.image = [UIImage imageNamed:@"location.png"]; + m_myPositionButton.selected = NO; + [m_myPositionButton setImage:[UIImage imageNamed:@"location.png"] forState:UIControlStateSelected]; [[MapsAppDelegate theApp] enableStandby]; } } - (IBAction)OnSettingsClicked:(id)sender { - m_framework->SetUpdatesEnabled(false); [[[MapsAppDelegate theApp] settingsManager] Show:self WithStorage:&m_storage]; } -- (IBAction)OnGuideClicked:(id)sender +- (IBAction)OnSearchClicked:(id)sender { - UISegmentedControl * pSegmentedControl = (UISegmentedControl *)sender; - int const selectedIndex = pSegmentedControl.selectedSegmentIndex; - - if (selectedIndex != 0) - { - LOG(LINFO, (selectedIndex)); - m_framework->SetUpdatesEnabled(false); - UIView * guideView = [MapsAppDelegate theApp].guideViewController.view; - [guideView setFrame:self.view.frame]; - [UIView transitionFromView:self.view - toView:guideView - duration:0 - options:UIViewAnimationOptionTransitionNone - completion:nil]; - [pSegmentedControl setSelectedSegmentIndex:0]; - } + SearchVC * searchVC = [[[SearchVC alloc] + initWithSearchFunc:bind(&framework_t::Search, m_framework, _1, _2) + andShowRectFunc:bind(&framework_t::ShowRect, m_framework, _1)] autorelease]; + [self.navigationController pushViewController:searchVC animated:YES]; } - (void) dealloc @@ -107,8 +94,6 @@ storage::Storage m_storage; // initialize with currently active screen orientation [self didRotateFromInterfaceOrientation: self.interfaceOrientation]; - // to perform a proper resize - [(EAGLView*)self.view layoutSubviews]; // restore previous screen position bool res = m_framework->LoadState(); @@ -118,9 +103,6 @@ storage::Storage m_storage; m_framework->InitializeGL([(EAGLView*)self.view renderContext], resourceManager); m_framework->Invalidate(); - - -// m_framework->UpdateNow(); } return self; @@ -128,10 +110,6 @@ storage::Storage m_storage; - (void)onResize:(GLint) width withHeight:(GLint) height { - UIInterfaceOrientation orientation = [self interfaceOrientation]; - if ((orientation == UIInterfaceOrientationLandscapeLeft) - ||(orientation == UIInterfaceOrientationLandscapeRight)) - std::swap(width, height); m_framework->OnSize(width, height); } @@ -143,22 +121,19 @@ NSInteger compareAddress(id l, id r, void * context) - (void)updatePointsFromEvent:(UIEvent*)event { NSSet * allTouches = [event allTouches]; - int touchCount = [allTouches count]; - CGFloat scaleFactor = 1.0; - if ([self.view respondsToSelector:@selector(contentScaleFactor)]) - scaleFactor = self.view.contentScaleFactor; + CGFloat const scaleFactor = self.view.contentScaleFactor; - if (touchCount == 1) + if ([allTouches count] == 1) { - CGPoint pt = [[[allTouches allObjects] objectAtIndex:0] locationInView:nil]; + CGPoint const pt = [[[allTouches allObjects] objectAtIndex:0] locationInView:nil]; m_Pt1 = m2::PointD(pt.x * scaleFactor, pt.y * scaleFactor); } else { NSArray * sortedTouches = [[allTouches allObjects] sortedArrayUsingFunction:compareAddress context:NULL]; - CGPoint pt1 = [[sortedTouches objectAtIndex:0] locationInView:nil]; - CGPoint pt2 = [[sortedTouches objectAtIndex:1] locationInView:nil]; + CGPoint const pt1 = [[sortedTouches objectAtIndex:0] locationInView:nil]; + CGPoint const pt2 = [[sortedTouches objectAtIndex:1] locationInView:nil]; m_Pt1 = m2::PointD(pt1.x * scaleFactor, pt1.y * scaleFactor); m_Pt2 = m2::PointD(pt2.x * scaleFactor, pt2.y * scaleFactor); @@ -184,9 +159,8 @@ NSInteger compareAddress(id l, id r, void * context) - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { [self updatePointsFromEvent:event]; - int touchCount = [[event allTouches] count]; - // NSLog(@"touchesBeg %i", touchCount); - if (touchCount == 1) + + if ([[event allTouches] count] == 1) { m_framework->StartDrag(DragEvent(m_Pt1.x, m_Pt1.y)); m_CurrentAction = DRAGGING; @@ -202,8 +176,8 @@ NSInteger compareAddress(id l, id r, void * context) - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { - m2::PointD TempPt1 = m_Pt1; - m2::PointD TempPt2 = m_Pt2; + m2::PointD const TempPt1 = m_Pt1; + m2::PointD const TempPt2 = m_Pt2; [self updatePointsFromEvent:event]; @@ -247,13 +221,13 @@ NSInteger compareAddress(id l, id r, void * context) [self updatePointsFromEvent:event]; [self stopCurrentAction]; - int tapCount = ((UITouch*)[touches anyObject]).tapCount; - int touchesCount = [[event allTouches] count]; + int const tapCount = ((UITouch*)[touches anyObject]).tapCount; + int const touchesCount = [[event allTouches] count]; if (tapCount == 2 && (touchesCount == 1) && m_isSticking) m_framework->ScaleToPoint(ScaleToPointEvent(m_Pt1.x, m_Pt1.y, 2.0)); - if ((touchesCount == 2) && (tapCount = 1) && m_isSticking) + if ((touchesCount == 2) && (tapCount == 1) && m_isSticking) m_framework->Scale(0.5); } @@ -262,13 +236,13 @@ NSInteger compareAddress(id l, id r, void * context) [self updatePointsFromEvent:event]; [self stopCurrentAction]; - int tapCount = ((UITouch*)[touches anyObject]).tapCount; - int touchesCount = [[event allTouches] count]; + int const tapCount = ((UITouch*)[touches anyObject]).tapCount; + int const touchesCount = [[event allTouches] count]; if (tapCount == 2 && (touchesCount == 1) && m_isSticking) m_framework->ScaleToPoint(ScaleToPointEvent(m_Pt1.x, m_Pt1.y, 2.0)); - if ((touchesCount == 2) && (tapCount = 1) && m_isSticking) + if ((touchesCount == 2) && (tapCount == 1) && m_isSticking) m_framework->Scale(0.5); } @@ -279,41 +253,15 @@ NSInteger compareAddress(id l, id r, void * context) m_framework->Paint(paintEvent); } - -/* -// Implement loadView to create a view hierarchy programmatically, without using a nib. -- (void)loadView { -} -*/ - -// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -- (void)viewDidLoad -{ - [super viewDidLoad]; -} - - -// Override to allow orientations other than the default portrait orientation. - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation { - return YES; + return YES; // We support all orientations } - (void)didReceiveMemoryWarning { - // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; - m_framework->MemoryWarning(); -// m_framework->Repaint(); - - // Release any cached data, images, etc that aren't in use. -} - -- (void)viewDidUnload -{ - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; } - (void) didRotateFromInterfaceOrientation: (UIInterfaceOrientation) fromInterfaceOrientation @@ -369,12 +317,14 @@ NSInteger compareAddress(id l, id r, void * context) m_mapIsVisible = true; if (m_framework) [self Invalidate]; + [self.navigationController setNavigationBarHidden:YES animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { m_mapIsVisible = false; m_framework->SetUpdatesEnabled(false); + [self.navigationController setNavigationBarHidden:NO animated:YES]; } @end diff --git a/iphone/Maps/Classes/MapsAppDelegate.h b/iphone/Maps/Classes/MapsAppDelegate.h index bed8ea7fb2..8d6204d4a8 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.h +++ b/iphone/Maps/Classes/MapsAppDelegate.h @@ -1,27 +1,24 @@ #import <UIKit/UIKit.h> @class MapViewController; -@class GuideViewController; @class SettingsManager; -@class UIWindow; @interface MapsAppDelegate : NSObject <UIApplicationDelegate> { - GuideViewController * m_guideViewController; + UINavigationController * m_navigationController; + UIWindow * m_window; + MapViewController * m_mapViewController; SettingsManager * m_settingsManager; NSInteger m_standbyCounter; } -@property (nonatomic, retain) IBOutlet UIWindow * window; -@property (nonatomic, retain) IBOutlet MapViewController * mapViewController; -@property (nonatomic, retain, readonly) GuideViewController * guideViewController; -@property (nonatomic, retain, readonly) SettingsManager * settingsManager; +@property (nonatomic, retain) IBOutlet UINavigationController * m_navigationController; +@property (nonatomic, retain) IBOutlet UIWindow * m_window; +@property (nonatomic, retain) IBOutlet MapViewController * m_mapViewController; + (MapsAppDelegate *) theApp; -- (GuideViewController *)guideViewController; - (SettingsManager *)settingsManager; -- (void)onSloynikEngineInitialized:(void *)pEngine; - (void)disableStandby; - (void)enableStandby; diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index c32d364adf..b40815f2e0 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -1,70 +1,37 @@ #import "MapsAppDelegate.h" #import "MapViewController.h" -#import "GuideViewController.h" #import "SettingsManager.h" -#import "../../Sloynik/Shared/global.hpp" @implementation MapsAppDelegate -@synthesize window; -@synthesize mapViewController; +@synthesize m_navigationController; +@synthesize m_window; +@synthesize m_mapViewController; + (MapsAppDelegate *) theApp { return [[UIApplication sharedApplication] delegate]; } -// here we're - (void) applicationWillTerminate: (UIApplication *) application { - [mapViewController OnTerminate]; + [m_mapViewController OnTerminate]; } - (void) applicationDidEnterBackground: (UIApplication *) application { - [mapViewController OnEnterBackground]; + [m_mapViewController OnEnterBackground]; } - (void) applicationWillEnterForeground: (UIApplication *) application { - [mapViewController OnEnterForeground]; -} - -- (void) onSloynikEngineInitialized: (void *) pEngine -{ - SetSloynikEngine(static_cast<sl::SloynikEngine *>(pEngine)); - if (m_guideViewController) - [m_guideViewController OnSloynikEngineInitialized]; + [m_mapViewController OnEnterForeground]; } - (void) applicationDidFinishLaunching: (UIApplication *) application { - // Initialize Sloynik engine. - // It takes long for the first time, so we do it while startup image is visible. - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ - sl::SloynikEngine * pEngine = CreateSloynikEngine(); - dispatch_async(dispatch_get_main_queue(), ^{ - [[MapsAppDelegate theApp] onSloynikEngineInitialized:pEngine]; - }); - }); - - - // Add the tab bar controller's current view as a subview of the window - [window addSubview:mapViewController.view]; - [window makeKeyAndVisible]; -} - -- (GuideViewController *)guideViewController -{ - if (!m_guideViewController) - { - m_guideViewController = [GuideViewController alloc]; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) - m_guideViewController = [m_guideViewController initWithNibName:@"GuideView-iPad" bundle:nil]; - else - m_guideViewController = [m_guideViewController initWithNibName:@"GuideView" bundle:nil]; - } - return m_guideViewController; + [m_window addSubview:m_mapViewController.view]; + [m_window makeKeyAndVisible]; } - (SettingsManager *)settingsManager @@ -76,10 +43,9 @@ - (void) dealloc { - [m_guideViewController release]; [m_settingsManager release]; - mapViewController = nil; - window = nil; + m_mapViewController = nil; + m_window = nil; [super dealloc]; } @@ -97,4 +63,3 @@ } @end - diff --git a/iphone/Maps/Classes/SearchVC.h b/iphone/Maps/Classes/SearchVC.h new file mode 100644 index 0000000000..ccabe67566 --- /dev/null +++ b/iphone/Maps/Classes/SearchVC.h @@ -0,0 +1,22 @@ +#import <UIKit/UIKit.h> + +#include "../../map/framework.hpp" + +#include "../../std/vector.hpp" +#include "../../std/function.hpp" +#include "../../std/string.hpp" + +namespace search { class Result; } + +typedef function<void (string const &, SearchCallbackT)> SearchF; +typedef function<void (m2::RectD)> ShowRectF; + +@interface SearchVC : UIViewController + <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource> +{ + vector<search::Result> m_results; +} + +- (id)initWithSearchFunc:(SearchF)s andShowRectFunc:(ShowRectF)r; + +@end diff --git a/iphone/Maps/Classes/SearchVC.mm b/iphone/Maps/Classes/SearchVC.mm new file mode 100644 index 0000000000..3ce4773e32 --- /dev/null +++ b/iphone/Maps/Classes/SearchVC.mm @@ -0,0 +1,166 @@ +#import "SearchVC.h" + +#include "../../map/framework.hpp" +#include "../../search/result.hpp" + +SearchVC * g_searchVC = nil; +SearchF g_searchF; +ShowRectF g_showRectF; +volatile int g_queryId = 0; + +@interface Wrapper : NSObject +{ // HACK: ownership is taken by the "get" method caller + search::Result * m_result; +} +- (id)initWithResult:(search::Result const &) res; +- (search::Result *)get; +@end + +@implementation Wrapper + +- (id)initWithResult:(search::Result const &) res +{ + if ((self = [super init])) + m_result = new search::Result(res); + return self; +} + +- (void)dealloc +{ + delete m_result; + [super dealloc]; +} + +- (search::Result const *)get +{ + return m_result; +} +@end + +static void OnSearchResultCallback(search::Result const & res, int queryId) +{ + if (g_searchVC && queryId == g_queryId) + { + Wrapper * w = [[Wrapper alloc] initWithResult:res]; + [g_searchVC performSelectorOnMainThread:@selector(addResult:) + withObject:w + waitUntilDone:NO]; + [w release]; + } +} + +@implementation SearchVC + +- (id)initWithSearchFunc:(SearchF)s andShowRectFunc:(ShowRectF)r +{ + if ((self = [super initWithNibName:nil bundle:nil])) + { + g_searchF = s; + g_showRectF = r; + } + return self; +} + +- (void)clearResults +{ + m_results.clear(); +} + +- (void)dealloc +{ + g_searchVC = nil; + [self clearResults]; + [super dealloc]; +} + +- (void)loadView +{ + UITableView * tableView = [[[UITableView alloc] init] autorelease]; + tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + tableView.delegate = self; + tableView.dataSource = self; + self.view = tableView; + self.title = @"Search"; + + UISearchBar * searchBar = [[[UISearchBar alloc] init] autorelease]; + searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.navigationItem.titleView = searchBar; + [searchBar sizeToFit]; + searchBar.delegate = self; +} + +- (void)viewDidLoad +{ + g_searchVC = self; +} + +- (void)viewDidUnload +{ + g_searchVC = nil; +} + +- (void)searchBar:(UISearchBar *)sender textDidChange:(NSString *)searchText +{ + [self clearResults]; + [(UITableView *)self.view reloadData]; + ++g_queryId; + + if ([searchText length] > 0) + { + g_searchF([[searchText precomposedStringWithCompatibilityMapping] UTF8String], + bind(&OnSearchResultCallback, _1, g_queryId)); + } +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return m_results.size(); +} + +- (UITableViewCell *)tableView:(UITableView *)tableView + cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"MyTableViewCell"]; + if (!cell) + cell = [[[UITableViewCell alloc] + initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyTableViewCell"] + autorelease]; + + if (indexPath.row < m_results.size()) + { + cell.textLabel.text = [NSString stringWithUTF8String:m_results[indexPath.row].GetString()]; + } + else + cell.textLabel.text = @""; + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (indexPath.row < m_results.size()) + { + if (m_results[indexPath.row].GetResultType() == search::Result::RESULT_FEATURE) + { + g_showRectF(m_results[indexPath.row].GetFeatureRect()); + [self.navigationController popViewControllerAnimated:YES]; + } + } +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; // All orientations are supported. +} + +- (void)addResult:(id)result +{ + m_results.push_back(*[result get]); + [(UITableView *)self.view reloadData]; +} + +@end |