Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_INFOBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "ui/base/animation/animation_delegate.h" | 10 #include "ui/base/animation/animation_delegate.h" |
| 11 #include "views/controls/button/button.h" | 11 #include "views/controls/button/button.h" |
| 12 #include "views/focus/focus_manager.h" | 12 #include "views/focus/focus_manager.h" |
| 13 | 13 |
| 14 class InfoBarContainer; | 14 class InfoBarContainer; |
| 15 class InfoBarDelegate; | 15 class InfoBarDelegate; |
| 16 class SkPath; | |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 class SlideAnimation; | 19 class SlideAnimation; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace views { | 22 namespace views { |
| 22 class ExternalFocusTracker; | 23 class ExternalFocusTracker; |
| 23 class ImageButton; | 24 class ImageButton; |
| 24 class ImageView; | 25 class ImageView; |
| 25 class Label; | 26 class Label; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // Makes the infobar hidden. If |animate| is true, the infobar is first | 66 // Makes the infobar hidden. If |animate| is true, the infobar is first |
| 66 // animated to zero size. Once the infobar is hidden, it is removed from its | 67 // animated to zero size. Once the infobar is hidden, it is removed from its |
| 67 // container (triggering its deletion), and its delegate is closed. | 68 // container (triggering its deletion), and its delegate is closed. |
| 68 void Hide(bool animate); | 69 void Hide(bool animate); |
| 69 | 70 |
| 70 // Closes the InfoBar immediately and removes it from its container. Notifies | 71 // Closes the InfoBar immediately and removes it from its container. Notifies |
| 71 // the delegate that it has closed. The InfoBar is deleted after this function | 72 // the delegate that it has closed. The InfoBar is deleted after this function |
| 72 // is called. | 73 // is called. |
| 73 void Close(); | 74 void Close(); |
| 74 | 75 |
| 75 // Paint the arrow on |canvas|. |arrow_center_x| indicates the | 76 // Overlap the previous view by this amount, vertically, so that |
| 76 // desired location of the center of the arrow in the |outer_view| | 77 // this InfoBarView may draw its tab on top. |
| 77 // coordinate system. | 78 int vertical_overlap() const { return preferred_tab_height(); } |
| 78 void PaintArrow(gfx::Canvas* canvas, View* outer_view, int arrow_center_x); | |
| 79 | 79 |
| 80 protected: | 80 protected: |
| 81 // The target height of the InfoBar, regardless of what its current height | 81 // The target height of the InfoBar, regardless of what its current height |
| 82 // is (due to animation). | 82 // is (due to animation). |
| 83 static const int kDefaultTargetHeight; | 83 static const int kDefaultTargetHeight; |
| 84 static const int kButtonButtonSpacing; | 84 static const int kButtonButtonSpacing; |
| 85 static const int kEndOfLabelSpacing; | 85 static const int kEndOfLabelSpacing; |
| 86 | 86 |
| 87 virtual ~InfoBarView(); | 87 virtual ~InfoBarView(); |
| 88 | 88 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 void set_target_height(int height) { target_height_ = height; } | 127 void set_target_height(int height) { target_height_ = height; } |
| 128 | 128 |
| 129 ui::SlideAnimation* animation() { return animation_.get(); } | 129 ui::SlideAnimation* animation() { return animation_.get(); } |
| 130 | 130 |
| 131 // These return x coordinates delimiting the usable area for subclasses to lay | 131 // These return x coordinates delimiting the usable area for subclasses to lay |
| 132 // out their controls. | 132 // out their controls. |
| 133 int StartX() const; | 133 int StartX() const; |
| 134 int EndX() const; | 134 int EndX() const; |
| 135 | 135 |
| 136 // Returns a centered y-position of a control of height specified in | 136 // Returns a centered y-position of a control of height specified in |
| 137 // |prefsize| within the standard InfoBar height. Stable during an animation. | |
| 138 int CenterY(const gfx::Size prefsize) const; | |
| 139 | |
| 140 // Returns a centered y-position of a control of height specified in | |
| 141 // |prefsize| within the standard InfoBar height, adjusted according to the | 137 // |prefsize| within the standard InfoBar height, adjusted according to the |
| 142 // current amount of animation offset the |parent| InfoBar currently has. | 138 // current amount of animation offset the |parent| InfoBar currently has. |
| 143 // Changes during an animation. | 139 // Changes during an animation. |
| 144 int OffsetY(const gfx::Size prefsize) const; | 140 int OffsetY(const gfx::Size prefsize) const; |
| 145 | 141 |
| 146 private: | 142 private: |
| 143 static const int kTabPadding; | |
| 144 static const int kCurveDistance; | |
| 147 static const int kHorizontalPadding; | 145 static const int kHorizontalPadding; |
| 146 static const int kIconWidth; | |
| 147 static const int kTabHeight; | |
| 148 static const int kTabStrokeWidth; | |
| 149 static const int kTabWidth; | |
| 150 | |
| 151 friend class InfoBarBackground; | |
|
Peter Kasting
2011/03/07 20:14:30
Nit: If these need to be friends, we're doing some
Sheridan Rawlins
2011/03/08 01:38:19
Fixed by using views::View and casting to InfoBarV
| |
| 152 friend class InfoBarContainer; | |
| 148 | 153 |
| 149 // views::View: | 154 // views::View: |
| 150 virtual AccessibilityTypes::Role GetAccessibleRole(); | 155 virtual AccessibilityTypes::Role GetAccessibleRole(); |
| 151 virtual gfx::Size GetPreferredSize(); | 156 virtual gfx::Size GetPreferredSize(); |
| 157 virtual void OnBoundsChanged(); | |
| 158 virtual void PaintChildren(gfx::Canvas* canvas); | |
| 152 | 159 |
| 153 // views::FocusChangeListener: | 160 // views::FocusChangeListener: |
| 154 virtual void FocusWillChange(View* focused_before, View* focused_now); | 161 virtual void FocusWillChange(View* focused_before, View* focused_now); |
| 155 | 162 |
| 156 // ui::AnimationDelegate: | 163 // ui::AnimationDelegate: |
| 157 virtual void AnimationEnded(const ui::Animation* animation); | 164 virtual void AnimationEnded(const ui::Animation* animation); |
| 158 | 165 |
| 166 // Use the same clip path as the |fill_path_|. | |
| 167 SkPath* clip_path() const { return fill_path_.get(); } | |
|
Peter Kasting
2011/03/07 20:14:30
Nit: Remove this function and call fill_path() dir
Sheridan Rawlins
2011/03/08 01:38:19
Done.
| |
| 168 SkPath* fill_path() const { return fill_path_.get(); } | |
| 169 SkPath* stroke_path() const { return stroke_path_.get(); } | |
| 170 | |
| 171 // Returns a centered y-position of a control of height specified in | |
| 172 // |prefsize| within the standard InfoBar height. Stable during an animation. | |
| 173 int CenterY(const gfx::Size prefsize) const; | |
| 174 | |
| 175 int preferred_tab_height() const; | |
|
Peter Kasting
2011/03/07 20:14:30
Nit: Use CamelCase because neither of these is a c
Sheridan Rawlins
2011/03/08 01:38:19
Choosing Animated instead of Preferred or Current,
| |
| 176 int preferred_bar_height() const; | |
| 177 | |
| 159 // Destroys the external focus tracker, if present. If |restore_focus| is | 178 // Destroys the external focus tracker, if present. If |restore_focus| is |
| 160 // true, restores focus to the view tracked by the focus tracker before doing | 179 // true, restores focus to the view tracked by the focus tracker before doing |
| 161 // so. | 180 // so. |
| 162 void DestroyFocusTracker(bool restore_focus); | 181 void DestroyFocusTracker(bool restore_focus); |
| 163 | 182 |
| 164 // Deletes this object (called after a return to the message loop to allow | 183 // Deletes this object (called after a return to the message loop to allow |
| 165 // the stack in ViewHierarchyChanged to unwind). | 184 // the stack in ViewHierarchyChanged to unwind). |
| 166 void DeleteSelf(); | 185 void DeleteSelf(); |
| 167 | 186 |
| 168 // The InfoBar's container | 187 // The InfoBar's container |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 180 // The animation that runs when the InfoBar is opened or closed. | 199 // The animation that runs when the InfoBar is opened or closed. |
| 181 scoped_ptr<ui::SlideAnimation> animation_; | 200 scoped_ptr<ui::SlideAnimation> animation_; |
| 182 | 201 |
| 183 // Tracks and stores the last focused view which is not the InfoBar or any of | 202 // Tracks and stores the last focused view which is not the InfoBar or any of |
| 184 // its children. Used to restore focus once the InfoBar is closed. | 203 // its children. Used to restore focus once the InfoBar is closed. |
| 185 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; | 204 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; |
| 186 | 205 |
| 187 // Used to delete this object after a return to the message loop. | 206 // Used to delete this object after a return to the message loop. |
| 188 ScopedRunnableMethodFactory<InfoBarView> delete_factory_; | 207 ScopedRunnableMethodFactory<InfoBarView> delete_factory_; |
| 189 | 208 |
| 190 // The target height for the InfoBarView. | 209 // The target height for the bar portion of the InfoBarView. |
| 191 int target_height_; | 210 int target_height_; |
| 192 | 211 |
| 212 scoped_ptr<SkPath> fill_path_; | |
| 213 scoped_ptr<SkPath> stroke_path_; | |
| 214 | |
| 193 DISALLOW_COPY_AND_ASSIGN(InfoBarView); | 215 DISALLOW_COPY_AND_ASSIGN(InfoBarView); |
| 194 }; | 216 }; |
| 195 | 217 |
| 196 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 218 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
| OLD | NEW |