OLD | NEW |
(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_CONTEXTUAL_SEARCH_PANEL_CONFIGURATION_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_PANEL_CONFIGURATION_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 namespace ContextualSearch { |
| 11 |
| 12 // Possible states (static positions) of the panel. |
| 13 typedef NS_ENUM(NSInteger, PanelState) { |
| 14 // TODO(crbug.com/546210): Rename to match Android implementation. |
| 15 // Ordering matters for these values. |
| 16 UNDEFINED = -1, |
| 17 DISMISSED, // (CLOSED) Offscreen |
| 18 PEEKING, // (PEEKED) Showing a small amount at the bottom of the screen |
| 19 PREVIEWING, // (EXPANDED) Panel covers 2/3 of the tab. |
| 20 COVERING, // (MAXIMIZED) Panel covers entire tab. |
| 21 }; |
| 22 |
| 23 } // namespace ContextualSearch |
| 24 |
| 25 // A PanelConfiguration object manages the panel's size, and the mapping between |
| 26 // states and y-coordinates for the panel. Nothing in the configuration object |
| 27 // changes the position or state of the panel; it just provides information for |
| 28 // other classes that make such changes. |
| 29 // PanelConfiguration is an abstract superclass; one of the device-specific |
| 30 // classes should be instantiated instead. |
| 31 @interface PanelConfiguration : NSObject |
| 32 |
| 33 // Size of the view that contains the panel. |
| 34 @property(nonatomic, assign) CGSize containerSize; |
| 35 // Current horizontal size class of the view that contains the panel. |
| 36 @property(nonatomic, assign) UIUserInterfaceSizeClass horizontalSizeClass; |
| 37 // Height that the panel peeks into the containing view when peeking. |
| 38 @property(nonatomic, readonly) CGFloat peekingHeight; |
| 39 |
| 40 // Creates and returns a configuration object for a container of the given size. |
| 41 + (instancetype)configurationForContainerSize:(CGSize)containerSize |
| 42 horizontalSizeClass: |
| 43 (UIUserInterfaceSizeClass)horizontalSizeClass; |
| 44 |
| 45 // Given the current configuration, returns the y-coordinate for the top of the |
| 46 // panel in |state|. This can be called "the position for |state|". |
| 47 - (CGFloat)positionForPanelState:(ContextualSearch::PanelState)state; |
| 48 |
| 49 // Given the current configuration, returns the state for a panel whose top |
| 50 // edge is at |positions|. The range of positions for a state are the half- |
| 51 // closed interval (J .. I], where I is position for |state| and J is the |
| 52 // position for |state| + 1. (Note that positions decrease, moving towards |
| 53 // the y-origin, as states increase). |
| 54 - (ContextualSearch::PanelState)panelStateForPosition:(CGFloat)position; |
| 55 |
| 56 // Returns the gradation (a value in [0.0 .. 1.0]) of |position| in terms of the |
| 57 // distance from |fromState| to |toState|. A gradation of 0.0 means |position| |
| 58 // is equal to the position for |fromState|; a gradation of 1.0 means it is |
| 59 // equal to the position for |toState|, and intermediate values correspond |
| 60 // linearly to intermediate values. |
| 61 - (CGFloat)gradationToState:(ContextualSearch::PanelState)toState |
| 62 fromState:(ContextualSearch::PanelState)fromState |
| 63 atPosition:(CGFloat)position; |
| 64 |
| 65 // Given |panel|, a view being used as the panel that the receiver configures, |
| 66 // return constraints to size the panel as defined by the receiver. |
| 67 - (NSArray*)constraintsForSizingPanel:(UIView*)panel; |
| 68 |
| 69 // Given a |guide|, which must have a non-nil owning view, constructs and |
| 70 // returns an autoreleased layout constraint that correctly sets the height of |
| 71 // |guide| for |guide| to act as a positioning guide for a panel in |state|. |
| 72 - (NSLayoutConstraint*) |
| 73 constraintForPositioningGuide:(UILayoutGuide*)view |
| 74 atState:(ContextualSearch::PanelState)state; |
| 75 |
| 76 @end |
| 77 |
| 78 // Panel configuration for phone formats. |
| 79 @interface PhonePanelConfiguration : PanelConfiguration |
| 80 @end |
| 81 |
| 82 // Panel configuration for iPad interface idioms. |
| 83 @interface PadPanelConfiguration : PanelConfiguration |
| 84 @end |
| 85 |
| 86 #endif // IOS_CHROME_BROWSER_UI_CONTEXTUAL_SEARCH_PANEL_CONFIGURATION_H_ |
OLD | NEW |