OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/popup_menu/popup_menu_view.h" |
| 6 |
| 7 #import <QuartzCore/QuartzCore.h> |
| 8 |
| 9 #include "base/mac/scoped_nsobject.h" |
| 10 |
| 11 namespace { |
| 12 // The image edge insets for popup_background.png. |
| 13 NS_INLINE UIEdgeInsets PopupBackgroundInsets() { |
| 14 return UIEdgeInsetsMake(28, 28, 28, 28); |
| 15 } |
| 16 }; |
| 17 |
| 18 @implementation PopupMenuView { |
| 19 base::scoped_nsobject<UIImageView> imageView_; |
| 20 } |
| 21 |
| 22 @synthesize delegate = delegate_; |
| 23 |
| 24 - (instancetype)initWithFrame:(CGRect)frame { |
| 25 self = [super initWithFrame:frame]; |
| 26 if (self) |
| 27 [self commonInitialization]; |
| 28 |
| 29 return self; |
| 30 } |
| 31 |
| 32 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 33 self = [super initWithCoder:aDecoder]; |
| 34 if (self) |
| 35 [self commonInitialization]; |
| 36 |
| 37 return self; |
| 38 } |
| 39 |
| 40 - (void)commonInitialization { |
| 41 UIImage* image = [UIImage imageNamed:@"popup_background"]; |
| 42 image = [image resizableImageWithCapInsets:PopupBackgroundInsets()]; |
| 43 |
| 44 imageView_.reset([[UIImageView alloc] initWithImage:image]); |
| 45 [self addSubview:imageView_]; |
| 46 } |
| 47 |
| 48 - (void)layoutSubviews { |
| 49 [super layoutSubviews]; |
| 50 [imageView_ setFrame:[self bounds]]; |
| 51 } |
| 52 |
| 53 - (BOOL)accessibilityPerformEscape { |
| 54 if (delegate_) { |
| 55 [delegate_ dismissPopupMenu]; |
| 56 UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, |
| 57 nil); |
| 58 return YES; |
| 59 } |
| 60 return NO; |
| 61 } |
| 62 |
| 63 @end |
OLD | NEW |