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

Side by Side Diff: chrome/browser/ui/views/infobars/infobars.h

Issue 6154001: Move animation code to new ui/base/animation directory.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 | Annotate | Revision Log
OLDNEW
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_INFOBARS_INFOBARS_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBARS_H_
6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBARS_H_ 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBARS_H_
7 #pragma once 7 #pragma once
8 8
9 #include "app/animation_delegate.h"
10 #include "base/task.h" 9 #include "base/task.h"
11 #include "chrome/browser/tab_contents/infobar_delegate.h" 10 #include "chrome/browser/tab_contents/infobar_delegate.h"
11 #include "ui/base/animation/animation_delegate.h"
12 #include "views/controls/button/button.h" 12 #include "views/controls/button/button.h"
13 #include "views/controls/link.h" 13 #include "views/controls/link.h"
14 #include "views/focus/focus_manager.h" 14 #include "views/focus/focus_manager.h"
15 15
16 class InfoBarContainer; 16 class InfoBarContainer;
17
18 namespace ui {
17 class SlideAnimation; 19 class SlideAnimation;
20 }
21
18 namespace views { 22 namespace views {
19 class ExternalFocusTracker; 23 class ExternalFocusTracker;
20 class ImageButton; 24 class ImageButton;
21 class ImageView; 25 class ImageView;
22 class Label; 26 class Label;
23 class NativeButton; 27 class NativeButton;
24 } 28 }
25 29
26 // This file contains implementations for some general purpose InfoBars. See 30 // This file contains implementations for some general purpose InfoBars. See
27 // chrome/browser/tab_contents/infobar_delegate.h for the delegate interface(s) 31 // chrome/browser/tab_contents/infobar_delegate.h for the delegate interface(s)
28 // that you must implement to use these. 32 // that you must implement to use these.
29 33
30 class InfoBarBackground : public views::Background { 34 class InfoBarBackground : public views::Background {
31 public: 35 public:
32 explicit InfoBarBackground(InfoBarDelegate::Type infobar_type); 36 explicit InfoBarBackground(InfoBarDelegate::Type infobar_type);
33 37
34 // Overridden from views::Background: 38 // Overridden from views::Background:
35 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; 39 virtual void Paint(gfx::Canvas* canvas, views::View* view) const;
36 40
37 private: 41 private:
38 scoped_ptr<views::Background> gradient_background_; 42 scoped_ptr<views::Background> gradient_background_;
39 43
40 DISALLOW_COPY_AND_ASSIGN(InfoBarBackground); 44 DISALLOW_COPY_AND_ASSIGN(InfoBarBackground);
41 }; 45 };
42 46
43 class InfoBar : public views::View, 47 class InfoBar : public views::View,
44 public views::ButtonListener, 48 public views::ButtonListener,
45 public views::FocusChangeListener, 49 public views::FocusChangeListener,
46 public AnimationDelegate { 50 public ui::AnimationDelegate {
47 public: 51 public:
48 explicit InfoBar(InfoBarDelegate* delegate); 52 explicit InfoBar(InfoBarDelegate* delegate);
49 virtual ~InfoBar(); 53 virtual ~InfoBar();
50 54
51 InfoBarDelegate* delegate() const { return delegate_; } 55 InfoBarDelegate* delegate() const { return delegate_; }
52 56
53 // Set a link to the parent InfoBarContainer. This must be set before the 57 // Set a link to the parent InfoBarContainer. This must be set before the
54 // InfoBar is added to the view hierarchy. 58 // InfoBar is added to the view hierarchy.
55 void set_container(InfoBarContainer* container) { container_ = container; } 59 void set_container(InfoBarContainer* container) { container_ = container; }
56 60
(...skipping 22 matching lines...) Expand all
79 // Returns the available width of the View for use by child view layout, 83 // Returns the available width of the View for use by child view layout,
80 // excluding the close button. 84 // excluding the close button.
81 virtual int GetAvailableWidth() const; 85 virtual int GetAvailableWidth() const;
82 86
83 // Removes our associated InfoBarDelegate from the associated TabContents. 87 // Removes our associated InfoBarDelegate from the associated TabContents.
84 // (Will lead to this InfoBar being closed). 88 // (Will lead to this InfoBar being closed).
85 void RemoveInfoBar() const; 89 void RemoveInfoBar() const;
86 90
87 void set_target_height(double height) { target_height_ = height; } 91 void set_target_height(double height) { target_height_ = height; }
88 92
89 SlideAnimation* animation() { return animation_.get(); } 93 ui::SlideAnimation* animation() { return animation_.get(); }
90 94
91 // Returns a centered y-position of a control of height specified in 95 // Returns a centered y-position of a control of height specified in
92 // |prefsize| within the standard InfoBar height. Stable during an animation. 96 // |prefsize| within the standard InfoBar height. Stable during an animation.
93 int CenterY(const gfx::Size prefsize); 97 int CenterY(const gfx::Size prefsize);
94 98
95 // Returns a centered y-position of a control of height specified in 99 // Returns a centered y-position of a control of height specified in
96 // |prefsize| within the standard InfoBar height, adjusted according to the 100 // |prefsize| within the standard InfoBar height, adjusted according to the
97 // current amount of animation offset the |parent| InfoBar currently has. 101 // current amount of animation offset the |parent| InfoBar currently has.
98 // Changes during an animation. 102 // Changes during an animation.
99 int OffsetY(views::View* parent, const gfx::Size prefsize); 103 int OffsetY(views::View* parent, const gfx::Size prefsize);
100 104
101 // Overridden from views::ButtonListener: 105 // Overridden from views::ButtonListener:
102 virtual void ButtonPressed(views::Button* sender, const views::Event& event); 106 virtual void ButtonPressed(views::Button* sender, const views::Event& event);
103 107
104 // Overridden from views::FocusChangeListener: 108 // Overridden from views::FocusChangeListener:
105 virtual void FocusWillChange(View* focused_before, View* focused_now); 109 virtual void FocusWillChange(View* focused_before, View* focused_now);
106 110
107 // Overridden from AnimationDelegate: 111 // Overridden from ui::AnimationDelegate:
108 virtual void AnimationProgressed(const Animation* animation); 112 virtual void AnimationProgressed(const ui::Animation* animation);
109 virtual void AnimationEnded(const Animation* animation); 113 virtual void AnimationEnded(const ui::Animation* animation);
110 114
111 private: 115 private:
112 friend class InfoBarContainer; 116 friend class InfoBarContainer;
113 117
114 // Starts animating the InfoBar open. 118 // Starts animating the InfoBar open.
115 void AnimateOpen(); 119 void AnimateOpen();
116 120
117 // Opens the InfoBar immediately. 121 // Opens the InfoBar immediately.
118 void Open(); 122 void Open();
119 123
(...skipping 23 matching lines...) Expand all
143 // The InfoBar's container 147 // The InfoBar's container
144 InfoBarContainer* container_; 148 InfoBarContainer* container_;
145 149
146 // The InfoBar's delegate. 150 // The InfoBar's delegate.
147 InfoBarDelegate* delegate_; 151 InfoBarDelegate* delegate_;
148 152
149 // The Close Button at the right edge of the InfoBar. 153 // The Close Button at the right edge of the InfoBar.
150 views::ImageButton* close_button_; 154 views::ImageButton* close_button_;
151 155
152 // The animation that runs when the InfoBar is opened or closed. 156 // The animation that runs when the InfoBar is opened or closed.
153 scoped_ptr<SlideAnimation> animation_; 157 scoped_ptr<ui::SlideAnimation> animation_;
154 158
155 // Tracks and stores the last focused view which is not the InfoBar or any of 159 // Tracks and stores the last focused view which is not the InfoBar or any of
156 // its children. Used to restore focus once the InfoBar is closed. 160 // its children. Used to restore focus once the InfoBar is closed.
157 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; 161 scoped_ptr<views::ExternalFocusTracker> focus_tracker_;
158 162
159 // Used to delete this object after a return to the message loop. 163 // Used to delete this object after a return to the message loop.
160 ScopedRunnableMethodFactory<InfoBar> delete_factory_; 164 ScopedRunnableMethodFactory<InfoBar> delete_factory_;
161 165
162 // The target height for the InfoBar. 166 // The target height for the InfoBar.
163 double target_height_; 167 double target_height_;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 views::NativeButton* cancel_button_; 246 views::NativeButton* cancel_button_;
243 views::Link* link_; 247 views::Link* link_;
244 248
245 bool initialized_; 249 bool initialized_;
246 250
247 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBar); 251 DISALLOW_COPY_AND_ASSIGN(ConfirmInfoBar);
248 }; 252 };
249 253
250 254
251 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBARS_H_ 255 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBARS_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/extension_infobar.cc ('k') | chrome/browser/ui/views/infobars/infobars.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698