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

Side by Side Diff: chrome/browser/infobars/infobar.h

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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
« no previous file with comments | « chrome/browser/extensions/extension_action.cc ('k') | chrome/browser/infobars/infobar.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_INFOBARS_INFOBAR_H_ 5 #ifndef CHROME_BROWSER_INFOBARS_INFOBAR_H_
6 #define CHROME_BROWSER_INFOBARS_INFOBAR_H_ 6 #define CHROME_BROWSER_INFOBARS_INFOBAR_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/infobars/infobar_delegate.h" 13 #include "chrome/browser/infobars/infobar_delegate.h"
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/base/animation/animation_delegate.h" 15 #include "ui/gfx/animation/animation_delegate.h"
16 #include "ui/base/animation/slide_animation.h" 16 #include "ui/gfx/animation/slide_animation.h"
17 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
18 18
19 // TODO(sail): These functions should be static methods in the InfoBar class 19 // TODO(sail): These functions should be static methods in the InfoBar class
20 // below once all platforms use that class. 20 // below once all platforms use that class.
21 SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type); 21 SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type);
22 SkColor GetInfoBarBottomColor(InfoBarDelegate::Type infobar_type); 22 SkColor GetInfoBarBottomColor(InfoBarDelegate::Type infobar_type);
23 23
24 // TODO(pkasting): Same with these notification-related typedefs. 24 // TODO(pkasting): Same with these notification-related typedefs.
25 typedef InfoBarDelegate InfoBarAddedDetails; 25 typedef InfoBarDelegate InfoBarAddedDetails;
26 typedef std::pair<InfoBarDelegate*, bool> InfoBarRemovedDetails; 26 typedef std::pair<InfoBarDelegate*, bool> InfoBarRemovedDetails;
27 typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarReplacedDetails; 27 typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarReplacedDetails;
28 28
29 class InfoBarContainer; 29 class InfoBarContainer;
30 class InfoBarService; 30 class InfoBarService;
31 31
32 class InfoBar : public ui::AnimationDelegate { 32 class InfoBar : public gfx::AnimationDelegate {
33 public: 33 public:
34 InfoBar(InfoBarService* owner, InfoBarDelegate* delegate); 34 InfoBar(InfoBarService* owner, InfoBarDelegate* delegate);
35 virtual ~InfoBar(); 35 virtual ~InfoBar();
36 36
37 // Platforms must define these. 37 // Platforms must define these.
38 static const int kDefaultBarTargetHeight; 38 static const int kDefaultBarTargetHeight;
39 static const int kSeparatorLineHeight; 39 static const int kSeparatorLineHeight;
40 static const int kDefaultArrowTargetHeight; 40 static const int kDefaultArrowTargetHeight;
41 static const int kMaximumArrowTargetHeight; 41 static const int kMaximumArrowTargetHeight;
42 // The half-width (see comments on |arrow_half_width_| below) scales to its 42 // The half-width (see comments on |arrow_half_width_| below) scales to its
(...skipping 17 matching lines...) Expand all
60 // effect once the infobar is animating closed. 60 // effect once the infobar is animating closed.
61 void SetArrowTargetHeight(int height); 61 void SetArrowTargetHeight(int height);
62 62
63 // Notifies the infobar that it is no longer owned and should close its 63 // Notifies the infobar that it is no longer owned and should close its
64 // delegate once it is invisible. 64 // delegate once it is invisible.
65 void CloseSoon(); 65 void CloseSoon();
66 66
67 // Changes the target height of the main ("bar") portion of the infobar. 67 // Changes the target height of the main ("bar") portion of the infobar.
68 void SetBarTargetHeight(int height); 68 void SetBarTargetHeight(int height);
69 69
70 const ui::SlideAnimation& animation() const { return animation_; } 70 const gfx::SlideAnimation& animation() const { return animation_; }
71 int arrow_height() const { return arrow_height_; } 71 int arrow_height() const { return arrow_height_; }
72 int arrow_target_height() const { return arrow_target_height_; } 72 int arrow_target_height() const { return arrow_target_height_; }
73 int arrow_half_width() const { return arrow_half_width_; } 73 int arrow_half_width() const { return arrow_half_width_; }
74 int total_height() const { return arrow_height_ + bar_height_; } 74 int total_height() const { return arrow_height_ + bar_height_; }
75 75
76 protected: 76 protected:
77 // ui::AnimationDelegate: 77 // gfx::AnimationDelegate:
78 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 78 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
79 79
80 // Forwards a close request to our owner. 80 // Forwards a close request to our owner.
81 // NOTE: Subclasses should not call this if we're already unowned. 81 // NOTE: Subclasses should not call this if we're already unowned.
82 void RemoveSelf(); 82 void RemoveSelf();
83 83
84 // Given a control with size |prefsize|, returns the centered y position 84 // Given a control with size |prefsize|, returns the centered y position
85 // within us, taking into account animation so the control "slides in" (or 85 // within us, taking into account animation so the control "slides in" (or
86 // out) as we animate open and closed. 86 // out) as we animate open and closed.
87 int OffsetY(const gfx::Size& prefsize) const; 87 int OffsetY(const gfx::Size& prefsize) const;
88 88
89 InfoBarService* owner() const { return owner_; } 89 InfoBarService* owner() const { return owner_; }
90 const InfoBarContainer* container() const { return container_; } 90 const InfoBarContainer* container() const { return container_; }
91 InfoBarContainer* container() { return container_; } 91 InfoBarContainer* container() { return container_; }
92 ui::SlideAnimation* animation() { return &animation_; } 92 gfx::SlideAnimation* animation() { return &animation_; }
93 int bar_height() const { return bar_height_; } 93 int bar_height() const { return bar_height_; }
94 int bar_target_height() const { return bar_target_height_; } 94 int bar_target_height() const { return bar_target_height_; }
95 95
96 // Platforms may optionally override these if they need to do work during 96 // Platforms may optionally override these if they need to do work during
97 // processing of the given calls. 97 // processing of the given calls.
98 virtual void PlatformSpecificShow(bool animate) {} 98 virtual void PlatformSpecificShow(bool animate) {}
99 virtual void PlatformSpecificHide(bool animate) {} 99 virtual void PlatformSpecificHide(bool animate) {}
100 virtual void PlatformSpecificOnCloseSoon() {} 100 virtual void PlatformSpecificOnCloseSoon() {}
101 virtual void PlatformSpecificOnHeightsRecalculated() {} 101 virtual void PlatformSpecificOnHeightsRecalculated() {}
102 102
103 private: 103 private:
104 // ui::AnimationDelegate: 104 // gfx::AnimationDelegate:
105 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; 105 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
106 106
107 // Finds the new desired arrow and bar heights, and if they differ from the 107 // Finds the new desired arrow and bar heights, and if they differ from the
108 // current ones, calls PlatformSpecificOnHeightRecalculated(). Informs our 108 // current ones, calls PlatformSpecificOnHeightRecalculated(). Informs our
109 // container our state has changed if either the heights have changed or 109 // container our state has changed if either the heights have changed or
110 // |force_notify| is set. 110 // |force_notify| is set.
111 void RecalculateHeights(bool force_notify); 111 void RecalculateHeights(bool force_notify);
112 112
113 // Checks whether we're closed. If so, notifies the container that it should 113 // Checks whether we're closed. If so, notifies the container that it should
114 // remove us (which will cause the platform-specific code to asynchronously 114 // remove us (which will cause the platform-specific code to asynchronously
115 // delete us) and closes the delegate. 115 // delete us) and closes the delegate.
116 void MaybeDelete(); 116 void MaybeDelete();
117 117
118 InfoBarService* owner_; 118 InfoBarService* owner_;
119 InfoBarDelegate* delegate_; 119 InfoBarDelegate* delegate_;
120 InfoBarContainer* container_; 120 InfoBarContainer* container_;
121 ui::SlideAnimation animation_; 121 gfx::SlideAnimation animation_;
122 122
123 // The current and target heights of the arrow and bar portions, and half the 123 // The current and target heights of the arrow and bar portions, and half the
124 // current arrow width. (It's easier to work in half-widths as we draw the 124 // current arrow width. (It's easier to work in half-widths as we draw the
125 // arrow as two halves on either side of a center point.) 125 // arrow as two halves on either side of a center point.)
126 int arrow_height_; // Includes both fill and top stroke. 126 int arrow_height_; // Includes both fill and top stroke.
127 int arrow_target_height_; 127 int arrow_target_height_;
128 int arrow_half_width_; // Includes only fill. 128 int arrow_half_width_; // Includes only fill.
129 int bar_height_; // Includes both fill and bottom separator. 129 int bar_height_; // Includes both fill and bottom separator.
130 int bar_target_height_; 130 int bar_target_height_;
131 131
132 DISALLOW_COPY_AND_ASSIGN(InfoBar); 132 DISALLOW_COPY_AND_ASSIGN(InfoBar);
133 }; 133 };
134 134
135 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_H_ 135 #endif // CHROME_BROWSER_INFOBARS_INFOBAR_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_action.cc ('k') | chrome/browser/infobars/infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698