Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: ios/chrome/browser/ui/fancy_ui/tinted_button.mm

Issue 2590473002: Upstream Chrome on iOS source code [5/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/file_locations_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 #include "ios/chrome/browser/ui/fancy_ui/tinted_button.h"
6
7 #import "base/mac/scoped_nsobject.h"
8
9 @interface TintedButton () {
10 base::scoped_nsobject<UIColor> normalStateTint_;
11 base::scoped_nsobject<UIColor> highlightedTint_;
12 }
13
14 // Makes the button's tint color reflect its current state.
15 - (void)updateTint;
16
17 @end
18
19 @implementation TintedButton
20
21 - (void)setTintColor:(UIColor*)color forState:(UIControlState)state {
22 switch (state) {
23 case UIControlStateNormal:
24 normalStateTint_.reset([color copy]);
25 break;
26 case UIControlStateHighlighted:
27 highlightedTint_.reset([color copy]);
28 break;
29 default:
30 return;
31 }
32
33 if (normalStateTint_ || highlightedTint_)
34 self.adjustsImageWhenHighlighted = NO;
35 else
36 self.adjustsImageWhenHighlighted = YES;
37 [self updateTint];
38 }
39
40 #pragma mark - UIControl
41
42 - (void)setHighlighted:(BOOL)highlighted {
43 [super setHighlighted:highlighted];
44 [self updateTint];
45 }
46
47 #pragma mark - Private
48
49 - (void)updateTint {
50 UIColor* newTint = nil;
51 switch (self.state) {
52 case UIControlStateNormal:
53 newTint = normalStateTint_.get();
54 break;
55 case UIControlStateHighlighted:
56 newTint = highlightedTint_.get();
57 break;
58 default:
59 newTint = normalStateTint_.get();
60 break;
61 }
62 self.tintColor = newTint;
63 }
64
65 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/file_locations_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698