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" | |
8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 7 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
9 | 8 |
| 9 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 10 #error "This file requires ARC support." |
| 11 #endif |
| 12 |
10 namespace { | 13 namespace { |
11 NSString* const kBookmarkGrayStar = @"bookmark_gray_star_large"; | 14 NSString* const kBookmarkGrayStar = @"bookmark_gray_star_large"; |
12 const CGFloat kEmptyBookmarkTextSize = 16.0; | 15 const CGFloat kEmptyBookmarkTextSize = 16.0; |
13 // Offset of the image view on top of the text. | 16 // Offset of the image view on top of the text. |
14 const CGFloat kImageViewOffsetFromText = 5.0; | 17 const CGFloat kImageViewOffsetFromText = 5.0; |
15 } // namespace | 18 } // namespace |
16 | 19 |
17 @interface BookmarkCollectionViewBackground () { | 20 @interface BookmarkCollectionViewBackground () |
18 base::mac::ObjCPropertyReleaser | |
19 _propertyReleaser_BookmarkBookmarkCollectionViewBackground; | |
20 } | |
21 | 21 |
22 // Star image view shown on top of the label. | 22 // Star image view shown on top of the label. |
23 @property(nonatomic, retain) UIImageView* emptyBookmarksImageView; | 23 @property(nonatomic, retain) UIImageView* emptyBookmarksImageView; |
24 // Label centered on the view showing the empty bookmarks text. | 24 // Label centered on the view showing the empty bookmarks text. |
25 @property(nonatomic, retain) UILabel* emptyBookmarksLabel; | 25 @property(nonatomic, retain) UILabel* emptyBookmarksLabel; |
26 | 26 |
27 @end | 27 @end |
28 | 28 |
29 @implementation BookmarkCollectionViewBackground | 29 @implementation BookmarkCollectionViewBackground |
30 | 30 |
31 @synthesize emptyBookmarksImageView = _emptyBookmarksImageView; | 31 @synthesize emptyBookmarksImageView = _emptyBookmarksImageView; |
32 @synthesize emptyBookmarksLabel = _emptyBookmarksLabel; | 32 @synthesize emptyBookmarksLabel = _emptyBookmarksLabel; |
33 | 33 |
34 - (instancetype)initWithFrame:(CGRect)frame { | 34 - (instancetype)initWithFrame:(CGRect)frame { |
35 self = [super initWithFrame:frame]; | 35 self = [super initWithFrame:frame]; |
36 if (self) { | 36 if (self) { |
37 _propertyReleaser_BookmarkBookmarkCollectionViewBackground.Init( | |
38 self, [BookmarkCollectionViewBackground class]); | |
39 _emptyBookmarksImageView = [self newBookmarkImageView]; | 37 _emptyBookmarksImageView = [self newBookmarkImageView]; |
40 [self addSubview:_emptyBookmarksImageView]; | 38 [self addSubview:_emptyBookmarksImageView]; |
41 _emptyBookmarksLabel = [self newEmptyBookmarkLabel]; | 39 _emptyBookmarksLabel = [self newEmptyBookmarkLabel]; |
42 [self addSubview:_emptyBookmarksLabel]; | 40 [self addSubview:_emptyBookmarksLabel]; |
43 } | 41 } |
44 return self; | 42 return self; |
45 } | 43 } |
46 | 44 |
47 - (void)layoutSubviews { | 45 - (void)layoutSubviews { |
48 [super layoutSubviews]; | 46 [super layoutSubviews]; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 - (CGRect)bookmarkImageViewFrame { | 89 - (CGRect)bookmarkImageViewFrame { |
92 const CGRect labelRect = [self emptyBookmarkLabelFrame]; | 90 const CGRect labelRect = [self emptyBookmarkLabelFrame]; |
93 const CGSize imageViewSize = self.emptyBookmarksImageView.image.size; | 91 const CGSize imageViewSize = self.emptyBookmarksImageView.image.size; |
94 return CGRectMake((CGRectGetWidth(self.bounds) - imageViewSize.width) / 2.0, | 92 return CGRectMake((CGRectGetWidth(self.bounds) - imageViewSize.width) / 2.0, |
95 CGRectGetMinY(labelRect) - kImageViewOffsetFromText - | 93 CGRectGetMinY(labelRect) - kImageViewOffsetFromText - |
96 imageViewSize.height, | 94 imageViewSize.height, |
97 imageViewSize.width, imageViewSize.height); | 95 imageViewSize.width, imageViewSize.height); |
98 } | 96 } |
99 | 97 |
100 @end | 98 @end |
OLD | NEW |