diff --git a/iphone/Maps/Bookmarks/BalloonView.h b/iphone/Maps/Bookmarks/BalloonView.h index a55407fcbb..8ad9748d1b 100644 --- a/iphone/Maps/Bookmarks/BalloonView.h +++ b/iphone/Maps/Bookmarks/BalloonView.h @@ -4,7 +4,7 @@ @interface BalloonView : NSObject { - UITableViewCell * m_titleView; + UIImageView * m_titleView; id m_target; SEL m_selector; diff --git a/iphone/Maps/Bookmarks/BalloonView.mm b/iphone/Maps/Bookmarks/BalloonView.mm index 5c3f4121bb..23d60d742f 100644 --- a/iphone/Maps/Bookmarks/BalloonView.mm +++ b/iphone/Maps/Bookmarks/BalloonView.mm @@ -21,7 +21,6 @@ color = [[NSString alloc] initWithString:@"placemark-purple"]; setName = [[NSString alloc] initWithString:NSLocalizedString(@"my_places", @"Default bookmarks set name")]; pinImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:self.color]]; - m_titleView = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"BookmarkTitle"]; isDisplayed = NO; m_target = target; m_selector = selector; @@ -41,21 +40,69 @@ [super dealloc]; } +- (UIImage *)createPopupImageWithName:(NSString *)name andAddress:(NSString *)address +{ + UIImage * left = [UIImage imageNamed:@"left"]; + UIImage * right = [UIImage imageNamed:@"right"]; + UIImage * middle = [UIImage imageNamed:@"middle"]; + UIImage * tail = [UIImage imageNamed:@"tail"]; + UIImage * arrow = [UIImage imageNamed:@"arrow"]; + + // Calculate text width and height + UIFont * nameFont = [UIFont boldSystemFontOfSize:[UIFont buttonFontSize]]; + UIFont * addressFont = [UIFont systemFontOfSize:[UIFont systemFontSize]]; + + CGSize const defSize = CGSizeMake(arrow.size.width + tail.size.width + left.size.width + right.size.width, + tail.size.height); + CGSize const nameSize = name ? [name sizeWithFont:nameFont] : defSize; + CGSize const addressSize = address ? [address sizeWithFont:addressFont] : defSize; + + CGFloat const minScreenWidth = MIN([UIScreen mainScreen].applicationFrame.size.width, + [UIScreen mainScreen].applicationFrame.size.height); + + CGFloat const padding = 1.; + + // Generated image size + CGFloat const height = tail.size.height; + CGFloat const additionalPadding = padding * 3 + arrow.size.width + left.size.width + right.size.width; + CGFloat const width = MAX(MIN(minScreenWidth, nameSize.width + additionalPadding), + MIN(minScreenWidth, addressSize.width + additionalPadding)); + + UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 0.0); + + // Draw background + [left drawAtPoint:CGPointMake(0, 0)]; + [right drawAtPoint:CGPointMake(width - right.size.width, 0)]; + CGFloat const tailStartsAt = (long)(width - tail.size.width) / 2; + [tail drawAtPoint:CGPointMake(tailStartsAt, 0)]; + [middle drawInRect:CGRectMake(left.size.width, 0, tailStartsAt - left.size.width, middle.size.height)]; + [middle drawInRect:CGRectMake(tailStartsAt + tail.size.width, 0, width - tailStartsAt - tail.size.width - right.size.width, middle.size.height)]; + + // Draw text + CGFloat const textW = width - left.size.width - right.size.width - arrow.size.width; + CGFloat const nameTextH = left.size.height / 2; + [[UIColor whiteColor] set]; + [name drawInRect:CGRectMake(left.size.width, nameTextH / 8, textW, nameTextH) withFont:nameFont lineBreakMode:UILineBreakModeTailTruncation]; + [[UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1.0] set]; + [address drawInRect:CGRectMake(left.size.width, nameTextH - (nameTextH / 8), textW, nameTextH) withFont:addressFont lineBreakMode:UILineBreakModeTailTruncation]; + + // Draw Arrow image + CGFloat const arrowPadding = (left.size.height - arrow.size.height) / 2; + [arrow drawAtPoint:CGPointMake(width - arrow.size.width - arrowPadding, arrowPadding)]; + + UIImage * theImage = UIGraphicsGetImageFromCurrentImageContext(); + + UIGraphicsEndImageContext(); + // return the image + return theImage; +} + - (void) showButtonsInView:(UIView *)view atPoint:(CGPoint)pt { - m_titleView.textLabel.text = self.title; - m_titleView.textLabel.textColor = [UIColor whiteColor]; - m_titleView.detailTextLabel.text = self.description; - m_titleView.detailTextLabel.textColor = [UIColor whiteColor]; - m_titleView.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; - m_titleView.backgroundColor = [UIColor blackColor]; - m_titleView.layer.cornerRadius = 10; -// m_titleView.alpha = 0.8; -// m_titleView.textLabel.backgroundColor = [UIColor clearColor]; -// m_titleView.detailTextLabel.backgroundColor = [UIColor clearColor]; - CGFloat const w = view.bounds.size.width - 30; - CGFloat const h = m_titleView.bounds.size.height; - m_titleView.frame = CGRectMake(pt.x - w/2, pt.y - h, w, h); + [m_titleView release]; + m_titleView = [[UIImageView alloc] initWithImage:[self createPopupImageWithName:self.title andAddress:self.description]]; + CGSize const s = m_titleView.bounds.size; + m_titleView.frame = CGRectMake(pt.x - s.width/2, pt.y - s.height, s.width, s.height); m_titleView.userInteractionEnabled = YES; UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] @@ -132,4 +179,5 @@ color = newColor; self.pinImage.image = [UIImage imageNamed:newColor]; } + @end diff --git a/iphone/Maps/Bookmarks/arrow.png b/iphone/Maps/Bookmarks/arrow.png new file mode 100644 index 0000000000..9acd3c1e40 Binary files /dev/null and b/iphone/Maps/Bookmarks/arrow.png differ diff --git a/iphone/Maps/Bookmarks/arrow@2x.png b/iphone/Maps/Bookmarks/arrow@2x.png new file mode 100644 index 0000000000..dfd720ee39 Binary files /dev/null and b/iphone/Maps/Bookmarks/arrow@2x.png differ diff --git a/iphone/Maps/Bookmarks/left.png b/iphone/Maps/Bookmarks/left.png new file mode 100644 index 0000000000..c7a334e271 Binary files /dev/null and b/iphone/Maps/Bookmarks/left.png differ diff --git a/iphone/Maps/Bookmarks/left@2x.png b/iphone/Maps/Bookmarks/left@2x.png new file mode 100644 index 0000000000..f114d15695 Binary files /dev/null and b/iphone/Maps/Bookmarks/left@2x.png differ diff --git a/iphone/Maps/Bookmarks/middle.png b/iphone/Maps/Bookmarks/middle.png new file mode 100644 index 0000000000..8b9ef677f3 Binary files /dev/null and b/iphone/Maps/Bookmarks/middle.png differ diff --git a/iphone/Maps/Bookmarks/middle@2x.png b/iphone/Maps/Bookmarks/middle@2x.png new file mode 100644 index 0000000000..972ca75562 Binary files /dev/null and b/iphone/Maps/Bookmarks/middle@2x.png differ diff --git a/iphone/Maps/Bookmarks/right.png b/iphone/Maps/Bookmarks/right.png new file mode 100644 index 0000000000..a960378e9b Binary files /dev/null and b/iphone/Maps/Bookmarks/right.png differ diff --git a/iphone/Maps/Bookmarks/right@2x.png b/iphone/Maps/Bookmarks/right@2x.png new file mode 100644 index 0000000000..c60e221cb2 Binary files /dev/null and b/iphone/Maps/Bookmarks/right@2x.png differ diff --git a/iphone/Maps/Bookmarks/tail.png b/iphone/Maps/Bookmarks/tail.png new file mode 100644 index 0000000000..403a790975 Binary files /dev/null and b/iphone/Maps/Bookmarks/tail.png differ diff --git a/iphone/Maps/Bookmarks/tail@2x.png b/iphone/Maps/Bookmarks/tail@2x.png new file mode 100644 index 0000000000..ce94068013 Binary files /dev/null and b/iphone/Maps/Bookmarks/tail@2x.png differ diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index bbabd5dc5e..36d5816463 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -175,6 +175,16 @@ FAA7A73514055351009F76D8 /* location-selected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAA7A73314055351009F76D8 /* location-selected@2x.png */; }; FAAFD697139D9BE2000AE70C /* categories.txt in Resources */ = {isa = PBXBuildFile; fileRef = FAAFD696139D9BE2000AE70C /* categories.txt */; }; FAAFD699139D9C6B000AE70C /* libsearch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAAFD698139D9C6B000AE70C /* libsearch.a */; }; + FAB2D51615DAB53F00C706C3 /* arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D50C15DAB53F00C706C3 /* arrow.png */; }; + FAB2D51715DAB53F00C706C3 /* arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D50D15DAB53F00C706C3 /* arrow@2x.png */; }; + FAB2D51815DAB53F00C706C3 /* left.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D50E15DAB53F00C706C3 /* left.png */; }; + FAB2D51915DAB53F00C706C3 /* left@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D50F15DAB53F00C706C3 /* left@2x.png */; }; + FAB2D51A15DAB53F00C706C3 /* middle.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51015DAB53F00C706C3 /* middle.png */; }; + FAB2D51B15DAB53F00C706C3 /* middle@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51115DAB53F00C706C3 /* middle@2x.png */; }; + FAB2D51C15DAB53F00C706C3 /* right.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51215DAB53F00C706C3 /* right.png */; }; + FAB2D51D15DAB53F00C706C3 /* right@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51315DAB53F00C706C3 /* right@2x.png */; }; + FAB2D51E15DAB53F00C706C3 /* tail.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51415DAB53F00C706C3 /* tail.png */; }; + FAB2D51F15DAB53F00C706C3 /* tail@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51515DAB53F00C706C3 /* tail@2x.png */; }; 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 */; }; @@ -1469,6 +1479,16 @@ 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; }; FAB09895148E2F1500892860 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = ""; }; + FAB2D50C15DAB53F00C706C3 /* arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = arrow.png; path = Bookmarks/arrow.png; sourceTree = SOURCE_ROOT; }; + FAB2D50D15DAB53F00C706C3 /* arrow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "arrow@2x.png"; path = "Bookmarks/arrow@2x.png"; sourceTree = SOURCE_ROOT; }; + FAB2D50E15DAB53F00C706C3 /* left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = left.png; path = Bookmarks/left.png; sourceTree = SOURCE_ROOT; }; + FAB2D50F15DAB53F00C706C3 /* left@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "left@2x.png"; path = "Bookmarks/left@2x.png"; sourceTree = SOURCE_ROOT; }; + FAB2D51015DAB53F00C706C3 /* middle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = middle.png; path = Bookmarks/middle.png; sourceTree = SOURCE_ROOT; }; + FAB2D51115DAB53F00C706C3 /* middle@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "middle@2x.png"; path = "Bookmarks/middle@2x.png"; sourceTree = SOURCE_ROOT; }; + FAB2D51215DAB53F00C706C3 /* right.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = right.png; path = Bookmarks/right.png; sourceTree = SOURCE_ROOT; }; + FAB2D51315DAB53F00C706C3 /* right@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "right@2x.png"; path = "Bookmarks/right@2x.png"; sourceTree = SOURCE_ROOT; }; + FAB2D51415DAB53F00C706C3 /* tail.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = tail.png; path = Bookmarks/tail.png; sourceTree = SOURCE_ROOT; }; + FAB2D51515DAB53F00C706C3 /* tail@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "tail@2x.png"; path = "Bookmarks/tail@2x.png"; 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 = ""; }; @@ -2300,6 +2320,16 @@ FA36B8171540466A004560CC /* Images */ = { isa = PBXGroup; children = ( + FAB2D50C15DAB53F00C706C3 /* arrow.png */, + FAB2D50D15DAB53F00C706C3 /* arrow@2x.png */, + FAB2D50E15DAB53F00C706C3 /* left.png */, + FAB2D50F15DAB53F00C706C3 /* left@2x.png */, + FAB2D51015DAB53F00C706C3 /* middle.png */, + FAB2D51115DAB53F00C706C3 /* middle@2x.png */, + FAB2D51215DAB53F00C706C3 /* right.png */, + FAB2D51315DAB53F00C706C3 /* right@2x.png */, + FAB2D51415DAB53F00C706C3 /* tail.png */, + FAB2D51515DAB53F00C706C3 /* tail@2x.png */, FA0545E0155C22D4001F4E37 /* placemark-blue.png */, FA0545E1155C22D4001F4E37 /* placemark-blue@2x.png */, FA0545E2155C22D4001F4E37 /* placemark-brown.png */, @@ -3555,6 +3585,16 @@ FA05460A155C22D4001F4E37 /* placemark-red@2x.png in Resources */, FA05460C155C22D4001F4E37 /* placemark-yellow.png in Resources */, FA05460E155C22D4001F4E37 /* placemark-yellow@2x.png in Resources */, + FAB2D51615DAB53F00C706C3 /* arrow.png in Resources */, + FAB2D51715DAB53F00C706C3 /* arrow@2x.png in Resources */, + FAB2D51815DAB53F00C706C3 /* left.png in Resources */, + FAB2D51915DAB53F00C706C3 /* left@2x.png in Resources */, + FAB2D51A15DAB53F00C706C3 /* middle.png in Resources */, + FAB2D51B15DAB53F00C706C3 /* middle@2x.png in Resources */, + FAB2D51C15DAB53F00C706C3 /* right.png in Resources */, + FAB2D51D15DAB53F00C706C3 /* right@2x.png in Resources */, + FAB2D51E15DAB53F00C706C3 /* tail.png in Resources */, + FAB2D51F15DAB53F00C706C3 /* tail@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };