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

Side by Side Diff: ios/chrome/browser/ui/util/label_observer.h

Issue 2588733002: Upstream Chrome on iOS source code [9/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
OLDNEW
(Empty)
1 // Copyright 2015 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 #ifndef IOS_CHROME_BROWSER_UI_UTIL_LABEL_OBSERVER_H_
6 #define IOS_CHROME_BROWSER_UI_UTIL_LABEL_OBSERVER_H_
7
8 #import <UIKit/UIKit.h>
9
10 // Class that observes changes to UILabel properties via KVO. This allows
11 // various classes that manage a UILabel's style via NSAttributedStrings to
12 // reapply their styling in response to property changes that would invalidate
13 // the attributed text. This class also synchronizes notifications of style
14 // invalidation so that property changes that occur as the result of a
15 // LabelObserverAction do not trigger other actions.
16 @interface LabelObserver : NSObject
17
18 // Returns the LabelObserver for |label|, laziliy instantiating one if
19 // necessary. LabelObservers are associated with the label, and will be
20 // deallocated upon |label|'s deallocation.
21 + (instancetype)observerForLabel:(UILabel*)label;
22
23 // LabelObservers should be created via |+observerForLabel:|.
24 - (instancetype)init NS_UNAVAILABLE;
25
26 // Block type that takes a label. Blocks registered for a label will be called
27 // when property values are updated.
28 typedef void (^LabelObserverAction)(UILabel* label);
29
30 // Registers |action| to be called when stylistic properties on the observed
31 // label are changed. Style changes include changes to the label's font,
32 // textColor, textAlignment, lineBreakMode, shadowColor, or shadowOffset.
33 - (void)addStyleChangedAction:(LabelObserverAction)action;
34
35 // Registers |action| to be called when the observed label's layout has changed.
36 // Layout changes include changes to the label's bounds, frame, or superview, as
37 // well as changes to its center, which doesn't affect the label's layout
38 // internally but does affect its position in its superview.
39 - (void)addLayoutChangedAction:(LabelObserverAction)action;
40
41 // Registers |action| to be called when the observed label's text has changed.
42 // Text changes include changes to the label's text or attributedText.
43 - (void)addTextChangedAction:(LabelObserverAction)action;
44
45 @end
46
47 #endif // IOS_CHROME_BROWSER_UI_UTIL_LABEL_OBSERVER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/util/label_link_controller_unittest.mm ('k') | ios/chrome/browser/ui/util/label_observer.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698