1 // Copyright 2018 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_TOOLBAR_CONTAINER_TOOLBAR_HEIGHT_RANGE_H_
6 #define IOS_CHROME_BROWSER_UI_TOOLBAR_CONTAINER_TOOLBAR_HEIGHT_RANGE_H_
7 
8 #import <QuartzCore/QuartzCore.h>
9 
10 namespace toolbar_container {
11 
12 // A simple container object used to store the height range for a collapsible
13 // toolbar.
14 class HeightRange {
15  public:
16   HeightRange() = default;
17   HeightRange(CGFloat min_height, CGFloat max_height);
18 
19   // The max and min heights.
min_height()20   CGFloat min_height() const { return min_height_; }
max_height()21   CGFloat max_height() const { return max_height_; }
22 
23   // Returns the delta between the max and min height.
delta()24   CGFloat delta() const { return max_height_ - min_height_; }
25 
26   // Returns the height value at the given interpolation value.
27   CGFloat GetInterpolatedHeight(CGFloat progress) const;
28 
29   // Operators.
30   bool operator==(const HeightRange& other) const;
31   bool operator!=(const HeightRange& other) const;
32   HeightRange operator+(const HeightRange& other) const;
33   HeightRange operator-(const HeightRange& other) const;
34   HeightRange& operator+=(const HeightRange& other);
35   HeightRange& operator-=(const HeightRange& other);
36 
37  private:
38   // The min and max heights.
39   CGFloat min_height_ = 0.0;
40   CGFloat max_height_ = 0.0;
41 };
42 
43 }  // namespace toolbar_container
44 
45 #endif  // IOS_CHROME_BROWSER_UI_TOOLBAR_CONTAINER_TOOLBAR_HEIGHT_RANGE_H_
46