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

Side by Side Diff: ios/chrome/browser/ui/stack_view/card_view.h

Issue 2587023002: Upstream Chrome on iOS source code [8/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 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_CARD_VIEW_H_
6 #define IOS_CHROME_BROWSER_UI_STACK_VIEW_CARD_VIEW_H_
7
8 #import <UIKit/UIKit.h>
9
10 struct LayoutRect;
11
12 // The insets of the snapshot image within the card.
13 extern const UIEdgeInsets kCardImageInsets;
14 // Inset from the edge of the card view to the edge of the card frame image.
15 extern const CGFloat kCardFrameInset;
16 // Thickness of the shadow cast by a card view.
17 extern const CGFloat kCardShadowThickness;
18 // The corner radius of the card frame image.
19 extern const CGFloat kCardFrameCornerRadius;
20 // The inset from the top of the card to the beginning of its tab view.
21 extern const CGFloat kCardTabTopInset;
22 // The brightness values for the background colors of the card frame images.
23 extern const CGFloat kCardFrameBackgroundBrightness;
24 extern const CGFloat kCardFrameBackgroundBrightnessIncognito;
25 // The amount by which the card frame image overlaps the content snapshot.
26 extern const CGFloat kCardFrameImageSnapshotOverlap;
27 // The name of the shadow image used for the card views.
28 extern NSString* const kCardShadowImageName;
29 // The outsets that will line the edge of a view with the shadow image.
30 extern const UIEdgeInsets kCardShadowLayoutOutsets;
31
32 // Enum class describing on which side to draw the close button.
33 enum class CardCloseButtonSide : short { LEADING = 0, TRAILING };
34
35 typedef enum {
36 CARD_TAB_ANIMATION_STYLE_NONE = 0,
37 CARD_TAB_ANIMATION_STYLE_FADE_IN,
38 CARD_TAB_ANIMATION_STYLE_FADE_OUT
39 } CardTabAnimationStyle;
40
41 @class CardSnapshotView;
42 @class CardTabView;
43 @class TitleLabel;
44
45 // A view class for displaying a card in the tab-switching stack. Has a title
46 // and an image. On its target, has actions for when the close box is clicked,
47 // when the card is selected, when it's dragged, and when VoiceOver focuses on
48 // its title label or close button.
49 @interface CardView : UIView
50
51 // |YES| if this card represents the current active tab.
52 @property(nonatomic, assign) BOOL isActiveTab;
53
54 // The snapshot displayed on the card.
55 @property(nonatomic, retain) UIImage* image;
56
57 // Whether the card view should render its shadow.
58 @property(nonatomic, assign) BOOL shouldShowShadow;
59
60 // Whether the card view should mask its shadow to only the overlapping portion.
61 @property(nonatomic, assign) BOOL shouldMaskShadow;
62
63 // The side on which to draw the close button.
64 @property(nonatomic, assign) CardCloseButtonSide closeButtonSide;
65
66 // Initializes CardView with |frame| and |isIncognito| state.
67 - (instancetype)initWithFrame:(CGRect)frame
68 isIncognito:(BOOL)isIncognito NS_DESIGNATED_INITIALIZER;
69
70 - (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
71
72 // Sets the page title. Can be nil.
73 - (void)setTitle:(NSString*)title;
74
75 // Returns TitleLabel element.
76 - (TitleLabel*)titleLabel;
77
78 // Sets the favicon. Can be nil, in which case the default favicon will be
79 // displayed.
80 - (void)setFavicon:(UIImage*)favicon;
81
82 // Sets the opacity of the tab. Uses opacity instead of hidden so that it's
83 // animatable.
84 - (void)setTabOpacity:(CGFloat)opacity;
85
86 // Sets target-action that is called when the close button is tapped. |target|
87 // can be nil and is not retained.
88 - (void)addCardCloseTarget:(id)target action:(SEL)action;
89
90 // Returns the touch target area of the button used to close the card.
91 - (CGRect)closeButtonFrame;
92
93 // Sets target-action that is called when VoiceOver focuses on the card view.
94 // |target| can be nil and is not retained.
95 - (void)addAccessibilityTarget:(id)target action:(SEL)action;
96
97 // Posts accessibility notification in VoiceOver to indicate when screen
98 // has changed and move cursor to CardView's titleLabel.
99 - (void)postAccessibilityNotification;
100
101 // Animates from |beginFrame| to |endFrame|, animating the card's tab as
102 // specified by |tabAnimationStyle|:
103 // - CardTabAnimationStyleNone: Animate frames of tab subviews
104 // - CardTabAnimationStyleFadeIn: Animate frames and fade in tab subviews
105 // - CardTabAnimationStyleFadeOut: Aniamte frames and fade out tab subviews
106 - (void)animateFromBeginFrame:(CGRect)beginFrame
107 toEndFrame:(CGRect)endFrame
108 tabAnimationStyle:(CardTabAnimationStyle)tabAnimationStyle;
109
110 // Removes the top-level frame animation added by
111 // |-animateFromBeginFrame:toEndFrame:tabAnimationStyle:|. This is necessary to
112 // avoid animation glitches that occur when a card is closed mid-animation, as
113 // ios_internal::page_animation_util::AnimateOutWithCompletion updates the
114 // CardView's anchorPoint.
115 - (void)removeFrameAnimation;
116
117 // Adds the dummy toolbar background view to the back of the card tab view.
118 - (void)installDummyToolbarBackgroundView:(UIView*)dummyToolbarBackgroundView;
119
120 // Reverses animations added by
121 // |-animateFromBeginFrame:toEndFrame:tabAnimationStyle:|.
122 - (void)reverseAnimations;
123
124 // Removes animations added by
125 // |-animateFromBeginFrame:toEndFrame:tabAnimationStyle:|.
126 - (void)cleanUpAnimations;
127
128 @end
129
130 @interface CardView (ExposedForTesting)
131
132 // The LayoutRect for CardTabView.
133 - (LayoutRect)tabLayout;
134
135 // The a11y ID of the "close" button in the find-in-page bar.
136 @property(nonatomic, readonly) NSString* closeButtonId;
137
138 @end
139
140 #endif // IOS_CHROME_BROWSER_UI_STACK_VIEW_CARD_VIEW_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/stack_view/card_stack_pinch_gesture_recognizer.mm ('k') | ios/chrome/browser/ui/stack_view/card_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698