OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 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_STACK_VIEW_STACK_CARD_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_STACK_VIEW_STACK_CARD_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 @class CardView; |
| 11 struct LayoutRect; |
| 12 @class StackCard; |
| 13 |
| 14 @protocol StackCardViewProvider |
| 15 // Returns the view to use for the given card. |
| 16 - (CardView*)cardViewWithFrame:(CGRect)frame forStackCard:(StackCard*)card; |
| 17 @end |
| 18 |
| 19 // Abstract representation of a card in the card stack. Allows operating on |
| 20 // the layout aspects of the card without the card actually having a view, so |
| 21 // that the view can easily be constructed lazily, purged for low memory, etc. |
| 22 // |StackCard| does not pixel-align its coordinates to avoid losing precision, |
| 23 // but does ensure that the origin of its view is always pixel-aligned. |
| 24 @interface StackCard : NSObject |
| 25 |
| 26 // The view corresponding to this card. |
| 27 // WARNING: The coordinates of the view should not be set directly, as doing so |
| 28 // will result in inconsistency. |
| 29 @property(nonatomic, readonly, retain) CardView* view; |
| 30 // The layout of the underyling CardView. |
| 31 @property(nonatomic, readwrite, assign) LayoutRect layout; |
| 32 // The size of the underlying CardView. Setting this property updates |layout| |
| 33 // with thew new size while maintaining the center of the card. |
| 34 @property(nonatomic, readwrite, assign) CGSize size; |
| 35 // If set to |YES|, updates to the frame/bounds/center of the card will also |
| 36 // update the corresponding properties of its view; if |NO|, they will not |
| 37 // (but immediate synchronization will occur the next time that the property is |
| 38 // set to |YES|). Default is |YES|. |
| 39 // NOTE: This property exists to enable updating a card's coordinates multiple |
| 40 // times within an animation, as setting the coordinates of a |UIView| more |
| 41 // than once inside an animation can result in undesired animation. Use this |
| 42 // property with care. |
| 43 @property(nonatomic, readwrite, assign) BOOL synchronizeView; |
| 44 // |YES| if this card represents the current active tab. |
| 45 @property(nonatomic, assign) BOOL isActiveTab; |
| 46 // Opaque value representing the Tab to which this card corresponds. Do not add |
| 47 // uses of this property. |
| 48 // TODO(blundell): Remove this. b/8321162 |
| 49 @property(nonatomic, assign) NSUInteger tabID; |
| 50 // Returns YES if the view for the card currently exists. Normally clients don't |
| 51 // need to know this, since |view| will create the view on demand, but this can |
| 52 // be used in cases where an operation should only be done if the view exists. |
| 53 @property(nonatomic, readonly) BOOL viewIsLive; |
| 54 |
| 55 // Initializes a new card which uses |viewProvider| to create its view. |
| 56 // |viewProvider| is not retained, and must outlive this object. |
| 57 - (instancetype)initWithViewProvider:(id<StackCardViewProvider>)viewProvider |
| 58 NS_DESIGNATED_INITIALIZER; |
| 59 |
| 60 - (instancetype)init NS_UNAVAILABLE; |
| 61 |
| 62 // Releases the view; it will be re-created on next access. Can be used to |
| 63 // temporarily free memory. |
| 64 - (void)releaseView; |
| 65 |
| 66 @end |
| 67 |
| 68 #endif // IOS_CHROME_BROWSER_UI_STACK_VIEW_STACK_CARD_H_ |
OLD | NEW |