| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/ui/bookmarks/bookmark_collection_view_background.h" | 5 #include "ios/chrome/browser/ui/bookmarks/bookmark_collection_view_background.h" |
| 6 | 6 |
| 7 #include "base/mac/objc_property_releaser.h" | 7 #include "base/mac/objc_release_properties.h" |
| 8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 NSString* const kBookmarkGrayStar = @"bookmark_gray_star_large"; | 11 NSString* const kBookmarkGrayStar = @"bookmark_gray_star_large"; |
| 12 const CGFloat kEmptyBookmarkTextSize = 16.0; | 12 const CGFloat kEmptyBookmarkTextSize = 16.0; |
| 13 // Offset of the image view on top of the text. | 13 // Offset of the image view on top of the text. |
| 14 const CGFloat kImageViewOffsetFromText = 5.0; | 14 const CGFloat kImageViewOffsetFromText = 5.0; |
| 15 } // namespace | 15 } // namespace |
| 16 | 16 |
| 17 @interface BookmarkCollectionViewBackground () { | 17 @interface BookmarkCollectionViewBackground () |
| 18 base::mac::ObjCPropertyReleaser | |
| 19 _propertyReleaser_BookmarkBookmarkCollectionViewBackground; | |
| 20 } | |
| 21 | 18 |
| 22 // Star image view shown on top of the label. | 19 // Star image view shown on top of the label. |
| 23 @property(nonatomic, retain) UIImageView* emptyBookmarksImageView; | 20 @property(nonatomic, retain) UIImageView* emptyBookmarksImageView; |
| 24 // Label centered on the view showing the empty bookmarks text. | 21 // Label centered on the view showing the empty bookmarks text. |
| 25 @property(nonatomic, retain) UILabel* emptyBookmarksLabel; | 22 @property(nonatomic, retain) UILabel* emptyBookmarksLabel; |
| 26 | 23 |
| 27 @end | 24 @end |
| 28 | 25 |
| 29 @implementation BookmarkCollectionViewBackground | 26 @implementation BookmarkCollectionViewBackground |
| 30 | 27 |
| 31 @synthesize emptyBookmarksImageView = _emptyBookmarksImageView; | 28 @synthesize emptyBookmarksImageView = _emptyBookmarksImageView; |
| 32 @synthesize emptyBookmarksLabel = _emptyBookmarksLabel; | 29 @synthesize emptyBookmarksLabel = _emptyBookmarksLabel; |
| 33 | 30 |
| 34 - (instancetype)initWithFrame:(CGRect)frame { | 31 - (instancetype)initWithFrame:(CGRect)frame { |
| 35 self = [super initWithFrame:frame]; | 32 self = [super initWithFrame:frame]; |
| 36 if (self) { | 33 if (self) { |
| 37 _propertyReleaser_BookmarkBookmarkCollectionViewBackground.Init( | |
| 38 self, [BookmarkCollectionViewBackground class]); | |
| 39 _emptyBookmarksImageView = [self newBookmarkImageView]; | 34 _emptyBookmarksImageView = [self newBookmarkImageView]; |
| 40 [self addSubview:_emptyBookmarksImageView]; | 35 [self addSubview:_emptyBookmarksImageView]; |
| 41 _emptyBookmarksLabel = [self newEmptyBookmarkLabel]; | 36 _emptyBookmarksLabel = [self newEmptyBookmarkLabel]; |
| 42 [self addSubview:_emptyBookmarksLabel]; | 37 [self addSubview:_emptyBookmarksLabel]; |
| 43 } | 38 } |
| 44 return self; | 39 return self; |
| 45 } | 40 } |
| 46 | 41 |
| 42 - (void)dealloc { |
| 43 base::mac::ReleaseProperties(self); |
| 44 [super dealloc]; |
| 45 } |
| 46 |
| 47 - (void)layoutSubviews { | 47 - (void)layoutSubviews { |
| 48 [super layoutSubviews]; | 48 [super layoutSubviews]; |
| 49 _emptyBookmarksLabel.frame = [self emptyBookmarkLabelFrame]; | 49 _emptyBookmarksLabel.frame = [self emptyBookmarkLabelFrame]; |
| 50 _emptyBookmarksImageView.frame = [self bookmarkImageViewFrame]; | 50 _emptyBookmarksImageView.frame = [self bookmarkImageViewFrame]; |
| 51 } | 51 } |
| 52 | 52 |
| 53 - (NSString*)text { | 53 - (NSString*)text { |
| 54 return self.emptyBookmarksLabel.text; | 54 return self.emptyBookmarksLabel.text; |
| 55 } | 55 } |
| 56 | 56 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 - (CGRect)bookmarkImageViewFrame { | 91 - (CGRect)bookmarkImageViewFrame { |
| 92 const CGRect labelRect = [self emptyBookmarkLabelFrame]; | 92 const CGRect labelRect = [self emptyBookmarkLabelFrame]; |
| 93 const CGSize imageViewSize = self.emptyBookmarksImageView.image.size; | 93 const CGSize imageViewSize = self.emptyBookmarksImageView.image.size; |
| 94 return CGRectMake((CGRectGetWidth(self.bounds) - imageViewSize.width) / 2.0, | 94 return CGRectMake((CGRectGetWidth(self.bounds) - imageViewSize.width) / 2.0, |
| 95 CGRectGetMinY(labelRect) - kImageViewOffsetFromText - | 95 CGRectGetMinY(labelRect) - kImageViewOffsetFromText - |
| 96 imageViewSize.height, | 96 imageViewSize.height, |
| 97 imageViewSize.width, imageViewSize.height); | 97 imageViewSize.width, imageViewSize.height); |
| 98 } | 98 } |
| 99 | 99 |
| 100 @end | 100 @end |
| OLD | NEW |