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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/util/label_observer.h
diff --git a/ios/chrome/browser/ui/util/label_observer.h b/ios/chrome/browser/ui/util/label_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..f102efbd012807f71646bde9815bf505ea59b726
--- /dev/null
+++ b/ios/chrome/browser/ui/util/label_observer.h
@@ -0,0 +1,47 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_UI_UTIL_LABEL_OBSERVER_H_
+#define IOS_CHROME_BROWSER_UI_UTIL_LABEL_OBSERVER_H_
+
+#import <UIKit/UIKit.h>
+
+// Class that observes changes to UILabel properties via KVO. This allows
+// various classes that manage a UILabel's style via NSAttributedStrings to
+// reapply their styling in response to property changes that would invalidate
+// the attributed text. This class also synchronizes notifications of style
+// invalidation so that property changes that occur as the result of a
+// LabelObserverAction do not trigger other actions.
+@interface LabelObserver : NSObject
+
+// Returns the LabelObserver for |label|, laziliy instantiating one if
+// necessary. LabelObservers are associated with the label, and will be
+// deallocated upon |label|'s deallocation.
++ (instancetype)observerForLabel:(UILabel*)label;
+
+// LabelObservers should be created via |+observerForLabel:|.
+- (instancetype)init NS_UNAVAILABLE;
+
+// Block type that takes a label. Blocks registered for a label will be called
+// when property values are updated.
+typedef void (^LabelObserverAction)(UILabel* label);
+
+// Registers |action| to be called when stylistic properties on the observed
+// label are changed. Style changes include changes to the label's font,
+// textColor, textAlignment, lineBreakMode, shadowColor, or shadowOffset.
+- (void)addStyleChangedAction:(LabelObserverAction)action;
+
+// Registers |action| to be called when the observed label's layout has changed.
+// Layout changes include changes to the label's bounds, frame, or superview, as
+// well as changes to its center, which doesn't affect the label's layout
+// internally but does affect its position in its superview.
+- (void)addLayoutChangedAction:(LabelObserverAction)action;
+
+// Registers |action| to be called when the observed label's text has changed.
+// Text changes include changes to the label's text or attributedText.
+- (void)addTextChangedAction:(LabelObserverAction)action;
+
+@end
+
+#endif // IOS_CHROME_BROWSER_UI_UTIL_LABEL_OBSERVER_H_
« 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