OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "app/animation.h" |
| 10 #include "base/scoped_ptr.h" |
9 #include "views/view.h" | 11 #include "views/view.h" |
10 | 12 |
| 13 class SlideAnimation; |
11 class TabContents; | 14 class TabContents; |
12 | 15 |
| 16 namespace views { |
| 17 class Widget; |
| 18 } |
| 19 |
13 // ContentsContainer is responsible for managing the TabContents views. | 20 // ContentsContainer is responsible for managing the TabContents views. |
14 // ContentsContainer has up to two children: one for the currently active | 21 // ContentsContainer has up to two children: one for the currently active |
15 // TabContents and one for instant's TabContents. | 22 // TabContents and one for instant's TabContents. |
16 class ContentsContainer : public views::View { | 23 class ContentsContainer : public views::View, public AnimationDelegate { |
17 public: | 24 public: |
18 explicit ContentsContainer(views::View* active); | 25 explicit ContentsContainer(views::View* active); |
19 virtual ~ContentsContainer(); | 26 virtual ~ContentsContainer(); |
20 | 27 |
21 // Makes the preview view the active view and nulls out the old active view. | 28 // Makes the preview view the active view and nulls out the old active view. |
22 // It's assumed the caller will delete or remove the old active view | 29 // It's assumed the caller will delete or remove the old active view |
23 // separately. | 30 // separately. |
24 void MakePreviewContentsActiveContents(); | 31 void MakePreviewContentsActiveContents(); |
25 | 32 |
26 // Sets the preview view. This does not delete the old. | 33 // Sets the preview view. This does not delete the old. |
27 void SetPreview(views::View* preview, TabContents* preview_tab_contents); | 34 void SetPreview(views::View* preview, TabContents* preview_tab_contents); |
28 | 35 |
29 TabContents* preview_tab_contents() const { return preview_tab_contents_; } | 36 TabContents* preview_tab_contents() const { return preview_tab_contents_; } |
30 | 37 |
31 // Sets the active top margin. | 38 // Sets the active top margin. |
32 void SetActiveTopMargin(int margin); | 39 void SetActiveTopMargin(int margin); |
33 | 40 |
34 // Returns the bounds of the preview. If the preview isn't active this | 41 // Returns the bounds of the preview. If the preview isn't active this |
35 // retuns the bounds the preview would be shown at. | 42 // retuns the bounds the preview would be shown at. |
36 gfx::Rect GetPreviewBounds(); | 43 gfx::Rect GetPreviewBounds(); |
37 | 44 |
| 45 // Fades out the active contents. |
| 46 void FadeActiveContents(); |
| 47 |
| 48 // Removes the fade. This is done implicitly when the preview is made active. |
| 49 void RemoveFade(); |
| 50 |
38 // View overrides: | 51 // View overrides: |
39 virtual void Layout(); | 52 virtual void Layout(); |
40 | 53 |
| 54 // AnimationDelegate overrides: |
| 55 virtual void AnimationProgressed(const Animation* animation); |
| 56 |
41 private: | 57 private: |
42 views::View* active_; | 58 views::View* active_; |
43 | 59 |
44 views::View* preview_; | 60 views::View* preview_; |
45 | 61 |
46 TabContents* preview_tab_contents_; | 62 TabContents* preview_tab_contents_; |
47 | 63 |
| 64 // Translucent Widget positioned right above the active view that is used to |
| 65 // make the active view appear faded out. |
| 66 views::Widget* active_overlay_; |
| 67 |
| 68 // Animation used to vary the opacity of active_overlay. |
| 69 scoped_ptr<SlideAnimation> overlay_animation_; |
| 70 |
48 // The margin between the top and the active view. This is used to make the | 71 // The margin between the top and the active view. This is used to make the |
49 // preview overlap the bookmark bar on the new tab page. | 72 // preview overlap the bookmark bar on the new tab page. |
50 int active_top_margin_; | 73 int active_top_margin_; |
51 | 74 |
52 DISALLOW_COPY_AND_ASSIGN(ContentsContainer); | 75 DISALLOW_COPY_AND_ASSIGN(ContentsContainer); |
53 }; | 76 }; |
54 | 77 |
55 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ | 78 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_CONTENTS_CONTAINER_H_ |
OLD | NEW |