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

Side by Side Diff: ios/chrome/browser/ui/stack_view/card_stack_layout_manager.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_STACK_LAYOUT_MANAGER_H_
6 #define IOS_CHROME_BROWSER_UI_STACK_VIEW_CARD_STACK_LAYOUT_MANAGER_H_
7
8 #import <CoreGraphics/CoreGraphics.h>
9 #import <Foundation/Foundation.h>
10
11 #include "base/mac/scoped_nsobject.h"
12
13 @class StackCard;
14
15 // Encapsulates a stack of cards and their layout behavior, supporting
16 // fanning the cards out along an axis and gathering them to fit in a given
17 // area.
18 @interface CardStackLayoutManager : NSObject {
19 @private
20 base::scoped_nsobject<NSMutableArray> cards_;
21 // YES if the previous call to one of {|scrollCardAtIndex|,
22 // |handleMultitouchWithFirstDelta|} was to the former method; NO otherwise.
23 BOOL treatOverExtensionAsScroll_;
24 NSUInteger previousFirstPinchCardIndex_;
25 NSUInteger previousSecondPinchCardIndex_;
26 }
27
28 // The size of a card. Setting this property preserves card origins with the
29 // exception that cards are moved as necessary to satisfy placement constraints
30 // (e.g., that a card is not placed too far away from its preceding neighbor).
31 @property(nonatomic, assign) CGSize cardSize;
32 // The center of a card along the axis that is not the layout axis.
33 @property(nonatomic, assign) CGFloat layoutAxisPosition;
34 // The amount cards should be staggered at full expansion.
35 @property(nonatomic, assign) CGFloat maxStagger;
36 // The maximum amount that the first card is allowed to overextend toward the
37 // start or the end.
38 @property(nonatomic, assign) CGFloat maximumOverextensionAmount;
39 // The offset denoting the start of the visible stack.
40 @property(nonatomic, assign) CGFloat startLimit;
41 // The offset denoting the end of the visible stack. Setting this property
42 // causes the end stack to be recomputed.
43 @property(nonatomic, assign) CGFloat endLimit;
44 // YES if the cards should be laid out vertically. Default is YES. A change in
45 // this property also sets the cards' positions along the new layout axis to
46 // their positions along the previous layout axis.
47 @property(nonatomic, assign) BOOL layoutIsVertical;
48 // TODO(blundell): The below two vars should be changed to NSUIntegers so that
49 // the implementation can uniformly use NSUIntegers. b/5956653
50 // The index of the last card that is in the initial stack.
51 @property(nonatomic, readonly, assign) NSInteger lastStartStackCardIndex;
52 // The index of the first card that is in the ending stack.
53 @property(nonatomic, readonly, assign) NSInteger firstEndStackCardIndex;
54
55 // Adds a |card| to the top (z-index) of the stack.
56 - (void)addCard:(StackCard*)card;
57
58 // Adds a |card| to the stack at the given index.
59 - (void)insertCard:(StackCard*)card atIndex:(NSUInteger)index;
60
61 // Removes |card| from the stack.
62 - (void)removeCard:(StackCard*)card;
63
64 // Removes all cards from the stack.
65 - (void)removeAllCards;
66
67 // Returns an array of cards, ordered from bottom to top of the stack (in
68 // z-order terms).
69 - (NSArray*)cards;
70
71 // Based on the cards' current positions and the value of |startLimit|, caps
72 // cards that should be in the start stack.
73 - (void)layOutStartStack;
74
75 // Fans out the cards and then gathers them in such that the first card not
76 // collapsed into the start stack is the card at |startIndex|.
77 - (void)fanOutCardsWithStartIndex:(NSUInteger)startIndex;
78
79 // Scrolls the card at |index| by |delta| (and trailing cards by a maximum of
80 // |delta| depending on whether evening out after pinching needs to occur).
81 // Scrolls leading cards by delta if |scrollLeadingCards| is |YES|; otherwise,
82 // does not scroll leading cards. Allows a certain amount of overscrolling
83 // toward the start and end. If |decayOnOverscroll| is |YES|, the impact of the
84 // scroll decays once the stack is overscrolled. If |allowEarlyOverscroll|
85 // is |YES|, overscrolling is allowed to occur naturally on the scrolled card;
86 // otherwise, overscrolling is not allowed to occur until the stack is fully
87 // collapsed/fanned out.
88 - (void)scrollCardAtIndex:(NSUInteger)index
89 byDelta:(CGFloat)delta
90 allowEarlyOverscroll:(BOOL)allowEarlyOverscroll
91 decayOnOverscroll:(BOOL)decayOnOverscroll
92 scrollLeadingCards:(BOOL)scrollLeadingCards;
93
94 // Returns whether the card at |index| is overextended toward the start.
95 - (BOOL)overextensionTowardStartOnCardAtIndex:(NSUInteger)index;
96 // Returns whether the first card is overextended toward the end. Note that
97 // overextension is not a meaningful concept for other cards, as a pinch is
98 // allowed to leave cards other than the first card resting in arbitrary
99 // positions.
100 - (BOOL)overextensionTowardEndOnFirstCard;
101 // Moves the cards so that any overextension is eliminated, with the nature of
102 // the movement being dependent on whether a scroll or a pinch occurred last.
103 - (void)eliminateOverextension;
104
105 // Scrolls the card at |index| to be at the maximum separation from the
106 // neighboring card, followed by handling start and end capping. If |preceding|,
107 // the card at |index| is scrolled away from the previous card toward the end
108 // stack, otherwise it is scrolled away from the next card toward the start
109 // stack. Also scrolls the cards that the card at |index| is scrolled toward,
110 // but does not alter the positions of the cards it is being scrolled away from.
111 - (void)scrollCardAtIndex:(NSUInteger)index awayFromNeighbor:(BOOL)preceding;
112
113 // Updates the card positions based on the passed-in multitouch event, in which
114 // |firstCardIndex| represents the card closer to the start stack,
115 // |secondCardIndex > firstCardIndex| represents the card closer to the end
116 // stack, and |firstDelta| and |secondDelta| represent the two cards'
117 // respective movements. Caps card positions when cards get too close to each
118 // other. Allows overpinch toward the start stack, and allows the first card to
119 // overpinch toward the end stack when it is being pinched. If
120 // |decayOnOverpinch| is |YES|, the impact of each side of the pinch is
121 // decayed once the card being pinched is overpinched.
122 - (void)handleMultitouchWithFirstDelta:(CGFloat)firstDelta
123 secondDelta:(CGFloat)secondDelta
124 firstCardIndex:(NSInteger)firstCardIndex
125 secondCardIndex:(NSInteger)secondCardIndex
126 decayOnOverpinch:(BOOL)decayOnOverpinch;
127
128 // The length required to display a fully fanned-out stack.
129 - (CGFloat)fannedStackLength;
130
131 // The maximum length that the stack could possibly grow to accounting for the
132 // fact that the user can pinch to pull cards apart further than the fanned-out
133 // separation.
134 - (CGFloat)maximumStackLength;
135
136 // The length required to display a fully collapsed stack. Note that this does
137 // not depend on the number of cards in the stack; it will always return the
138 // amount needed to show an arbitrarily large stack, so that it has a
139 // consistent result that can be used to compute card sizes/margins.
140 - (CGFloat)fullyCollapsedStackLength;
141
142 // Returns YES if |card| is completely covered by other cards.
143 - (BOOL)cardIsCovered:(StackCard*)card;
144
145 // Returns whether |card| is collapsed behind its succeeding neighbor, defined
146 // as being separated by <= the separation distance between visible cards in the
147 // edge stacks.
148 - (BOOL)cardIsCollapsed:(StackCard*)card;
149
150 // Returns whether the title label for |card| is covered by its succeeding
151 // neighbor or the edge of the screen.
152 - (BOOL)cardLabelCovered:(StackCard*)card;
153
154 // Returns |YES| if all cards are scrolled into the start stack.
155 - (BOOL)stackIsFullyCollapsed;
156
157 // Returns |YES| if the stack is fully fanned out.
158 - (BOOL)stackIsFullyFannedOut;
159
160 // Returns |YES| if the stack is fully overextended toward the start or the
161 // end.
162 - (BOOL)stackIsFullyOverextended;
163
164 // The amount that the first card is currently overextended.
165 - (CGFloat)overextensionAmount;
166
167 // The number of cards visible when stack is fanned out.
168 - (NSUInteger)fannedStackCount;
169
170 @end
171
172 #endif // IOS_CHROME_BROWSER_UI_STACK_VIEW_CARD_STACK_LAYOUT_MANAGER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/stack_view/card_set_unittest.mm ('k') | ios/chrome/browser/ui/stack_view/card_stack_layout_manager.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698