diff --git a/iphone/Maps/Classes/CompassView.h b/iphone/Maps/Classes/CompassView.h new file mode 100644 index 0000000000..1c321ec0f2 --- /dev/null +++ b/iphone/Maps/Classes/CompassView.h @@ -0,0 +1,11 @@ +#import + +// Custom view which drows an arrow +@interface CompassView : UIView +{ + float m_angle; +} + +@property (nonatomic, assign) float angle; + +@end diff --git a/iphone/Maps/Classes/CompassView.mm b/iphone/Maps/Classes/CompassView.mm new file mode 100644 index 0000000000..5430c17203 --- /dev/null +++ b/iphone/Maps/Classes/CompassView.mm @@ -0,0 +1,46 @@ +#import "CompassView.h" + +@implementation CompassView + +@synthesize angle = m_angle; + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) + { + self.opaque = NO; + self.clearsContextBeforeDrawing = YES; + } + return self; +} + +- (void)setAngle:(float)angle +{ + m_angle = angle; + [self setNeedsDisplay]; +} + +- (void)drawRect:(CGRect)rect +{ + UIBezierPath * aPath = [UIBezierPath bezierPath]; + + float const w = rect.size.width; + float const w2 = w / 2.0; + float const w3 = w / 3.0; + [aPath moveToPoint:CGPointMake(w3, w2)]; + [aPath addLineToPoint:CGPointMake(0, w2 - w3)]; + [aPath addLineToPoint:CGPointMake(w, w2)]; + [aPath addLineToPoint:CGPointMake(0, w2 + w3)]; + [aPath closePath]; + + CGAffineTransform matrix = CGAffineTransformMakeTranslation(w2, w2); + matrix = CGAffineTransformRotate(matrix, m_angle); + matrix = CGAffineTransformTranslate(matrix, -w2, -w2); + [aPath applyTransform:matrix]; + + [[UIColor blueColor] setFill]; + [aPath fill]; +} + +@end diff --git a/iphone/Maps/Classes/SearchVC.mm b/iphone/Maps/Classes/SearchVC.mm index 3ce4773e32..b7fe17c075 100644 --- a/iphone/Maps/Classes/SearchVC.mm +++ b/iphone/Maps/Classes/SearchVC.mm @@ -1,4 +1,5 @@ #import "SearchVC.h" +#import "CompassView.h" #include "../../map/framework.hpp" #include "../../search/result.hpp" @@ -134,9 +135,17 @@ static void OnSearchResultCallback(search::Result const & res, int queryId) if (indexPath.row < m_results.size()) { cell.textLabel.text = [NSString stringWithUTF8String:m_results[indexPath.row].GetString()]; + float const h = tableView.rowHeight * 0.6; + CompassView * v = [[[CompassView alloc] initWithFrame: + CGRectMake(0, 0, h, h)] autorelease]; + v.angle = (float)m_results[indexPath.row].GetDirectionFromCenter(); + cell.accessoryView = v; } else + { cell.textLabel.text = @""; + cell.accessoryView = nil; + } return cell; } diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 509361b74c..8ec59fed12 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -80,6 +80,7 @@ FA8F8938132D5DB00048E3FE /* libtomcrypt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8F8937132D5DB00048E3FE /* libtomcrypt.a */; }; FAAFD697139D9BE2000AE70C /* categories.txt in Resources */ = {isa = PBXBuildFile; fileRef = FAAFD696139D9BE2000AE70C /* categories.txt */; }; FAAFD699139D9C6B000AE70C /* libsearch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAAFD698139D9C6B000AE70C /* libsearch.a */; }; + FABF223E13FAA97A003D4D49 /* CompassView.mm in Sources */ = {isa = PBXBuildFile; fileRef = FABF223D13FAA97A003D4D49 /* CompassView.mm */; }; FAD4906C13EFF61F005E7D43 /* search.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD4906A13EFF61F005E7D43 /* search.png */; }; FAD4906D13EFF61F005E7D43 /* search@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD4906B13EFF61F005E7D43 /* search@2x.png */; }; FAF37EFF126DCE6F005EA154 /* IPhoneDownload.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAF37EFA126DCE6F005EA154 /* IPhoneDownload.mm */; }; @@ -179,6 +180,8 @@ FAAE8D5D1338FF8B003ECAD5 /* GetActiveConnectionType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetActiveConnectionType.h; sourceTree = ""; }; FAAFD696139D9BE2000AE70C /* categories.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = categories.txt; path = ../../data/categories.txt; sourceTree = SOURCE_ROOT; }; FAAFD698139D9C6B000AE70C /* libsearch.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libsearch.a; sourceTree = SOURCE_ROOT; }; + FABF223C13FAA97A003D4D49 /* CompassView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompassView.h; sourceTree = ""; }; + FABF223D13FAA97A003D4D49 /* CompassView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CompassView.mm; sourceTree = ""; }; FAD4906A13EFF61F005E7D43 /* search.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = search.png; sourceTree = ""; }; FAD4906B13EFF61F005E7D43 /* search@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "search@2x.png"; sourceTree = ""; }; FAF37EFA126DCE6F005EA154 /* IPhoneDownload.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = IPhoneDownload.mm; path = Platform/IPhoneDownload.mm; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -228,6 +231,8 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + FABF223C13FAA97A003D4D49 /* CompassView.h */, + FABF223D13FAA97A003D4D49 /* CompassView.mm */, FA09E00F13F71F6C007E69CA /* SearchVC.h */, FA09E01013F71F6C007E69CA /* SearchVC.mm */, EE7F297C1219ECA300EB67A9 /* RenderBuffer.hpp */, @@ -542,6 +547,7 @@ FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */, FA34BECA1338D72F00FFB2A7 /* CustomAlertView.mm in Sources */, FA09E01113F71F6C007E69CA /* SearchVC.mm in Sources */, + FABF223E13FAA97A003D4D49 /* CompassView.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };