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 "chrome/browser/ui/views/infobars/infobar.h" | 10 #include "chrome/browser/ui/views/infobars/infobar.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 class InfoBarView : public InfoBar, | 28 class InfoBarView : public InfoBar, |
29 public views::View, | 29 public views::View, |
30 public views::ButtonListener, | 30 public views::ButtonListener, |
31 public views::FocusChangeListener { | 31 public views::FocusChangeListener { |
32 public: | 32 public: |
33 explicit InfoBarView(InfoBarDelegate* delegate); | 33 explicit InfoBarView(InfoBarDelegate* delegate); |
34 | 34 |
35 SkPath* fill_path() const { return fill_path_.get(); } | 35 SkPath* fill_path() const { return fill_path_.get(); } |
36 SkPath* stroke_path() const { return stroke_path_.get(); } | 36 SkPath* stroke_path() const { return stroke_path_.get(); } |
37 | 37 |
38 int AnimatedTabHeight() const; | 38 int tab_height() const { return tab_height_; } |
39 | 39 |
40 protected: | 40 protected: |
41 // The target height of the InfoBar, regardless of what its current height | 41 // The target height of the InfoBar, regardless of what its current height |
42 // is (due to animation). | 42 // is (due to animation). |
43 static const int kDefaultTargetHeight; | 43 static const int kDefaultTargetHeight; |
44 static const int kButtonButtonSpacing; | 44 static const int kButtonButtonSpacing; |
45 static const int kEndOfLabelSpacing; | 45 static const int kEndOfLabelSpacing; |
46 | 46 |
47 virtual ~InfoBarView(); | 47 virtual ~InfoBarView(); |
48 | 48 |
(...skipping 24 matching lines...) Expand all Loading... |
73 | 73 |
74 // views::ButtonListener: | 74 // views::ButtonListener: |
75 virtual void ButtonPressed(views::Button* sender, | 75 virtual void ButtonPressed(views::Button* sender, |
76 const views::Event& event) OVERRIDE; | 76 const views::Event& event) OVERRIDE; |
77 | 77 |
78 // Returns the minimum width the content (that is, everything between the icon | 78 // Returns the minimum width the content (that is, everything between the icon |
79 // and the close button) can be shrunk to. This is used to prevent the close | 79 // and the close button) can be shrunk to. This is used to prevent the close |
80 // button from overlapping views that cannot be shrunk any further. | 80 // button from overlapping views that cannot be shrunk any further. |
81 virtual int ContentMinimumWidth() const; | 81 virtual int ContentMinimumWidth() const; |
82 | 82 |
83 void set_target_height(int height) { target_height_ = height; } | 83 // Changes the target height of the main ("bar") portion of the infobar. |
| 84 void SetTargetHeight(int height); |
84 | 85 |
85 // These return x coordinates delimiting the usable area for subclasses to lay | 86 // These return x coordinates delimiting the usable area for subclasses to lay |
86 // out their controls. | 87 // out their controls. |
87 int StartX() const; | 88 int StartX() const; |
88 int EndX() const; | 89 int EndX() const; |
89 | 90 |
90 // Given a control with size |prefsize|, returns the centered y position | 91 // Given a control with size |prefsize|, returns the centered y position |
91 // within us, taking into account animation so the control "slides in" (or | 92 // within us, taking into account animation so the control "slides in" (or |
92 // out) as we animate open and closed. | 93 // out) as we animate open and closed. |
93 int OffsetY(const gfx::Size prefsize) const; | 94 int OffsetY(const gfx::Size prefsize) const; |
94 | 95 |
95 private: | 96 private: |
96 static const int kCurveWidth; | 97 static const int kCurveWidth; |
97 static const int kHorizontalPadding; | 98 static const int kHorizontalPadding; |
98 static const int kMaxIconWidth; | 99 static const int kMaxIconWidth; |
99 static const int kTabHeight; | 100 static const int kTabHeight; |
100 static const int kTabIconPadding; | 101 static const int kTabIconPadding; |
101 static const int kTabWidth; | 102 static const int kTabWidth; |
102 | 103 |
103 // InfoBar: | 104 // InfoBar: |
104 virtual void PlatformSpecificHide(bool animate) OVERRIDE; | 105 virtual void PlatformSpecificHide(bool animate) OVERRIDE; |
| 106 virtual void PlatformSpecificRecalculateHeight() OVERRIDE; |
105 | 107 |
106 // views::View: | 108 // views::View: |
107 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 109 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
108 virtual gfx::Size GetPreferredSize() OVERRIDE; | 110 virtual gfx::Size GetPreferredSize() OVERRIDE; |
109 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | |
110 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; | 111 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; |
111 | 112 |
112 // views::FocusChangeListener: | 113 // views::FocusChangeListener: |
113 virtual void FocusWillChange(View* focused_before, | 114 virtual void FocusWillChange(View* focused_before, |
114 View* focused_now) OVERRIDE; | 115 View* focused_now) OVERRIDE; |
115 | 116 |
116 // Returns a centered y-position of a control of height specified in | 117 // Returns a centered y-position of a control of height specified in |
117 // |prefsize| within the standard InfoBar height. Stable during an animation. | 118 // |prefsize| within the standard InfoBar height. Stable during an animation. |
118 int CenterY(const gfx::Size prefsize) const; | 119 int CenterY(const gfx::Size prefsize) const; |
119 | 120 |
120 int AnimatedBarHeight() const; | |
121 | |
122 // Destroys the external focus tracker, if present. If |restore_focus| is | 121 // Destroys the external focus tracker, if present. If |restore_focus| is |
123 // true, restores focus to the view tracked by the focus tracker before doing | 122 // true, restores focus to the view tracked by the focus tracker before doing |
124 // so. | 123 // so. |
125 void DestroyFocusTracker(bool restore_focus); | 124 void DestroyFocusTracker(bool restore_focus); |
126 | 125 |
127 // Deletes this object (called after a return to the message loop to allow | 126 // Deletes this object (called after a return to the message loop to allow |
128 // the stack in ViewHierarchyChanged to unwind). | 127 // the stack in ViewHierarchyChanged to unwind). |
129 void DeleteSelf(); | 128 void DeleteSelf(); |
130 | 129 |
131 // The optional icon at the left edge of the InfoBar. | 130 // The optional icon at the left edge of the InfoBar. |
132 views::ImageView* icon_; | 131 views::ImageView* icon_; |
133 | 132 |
134 // The close button at the right edge of the InfoBar. | 133 // The close button at the right edge of the InfoBar. |
135 views::ImageButton* close_button_; | 134 views::ImageButton* close_button_; |
136 | 135 |
137 // Tracks and stores the last focused view which is not the InfoBar or any of | 136 // Tracks and stores the last focused view which is not the InfoBar or any of |
138 // its children. Used to restore focus once the InfoBar is closed. | 137 // its children. Used to restore focus once the InfoBar is closed. |
139 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; | 138 scoped_ptr<views::ExternalFocusTracker> focus_tracker_; |
140 | 139 |
141 // Used to delete this object after a return to the message loop. | 140 // Used to delete this object after a return to the message loop. |
142 ScopedRunnableMethodFactory<InfoBarView> delete_factory_; | 141 ScopedRunnableMethodFactory<InfoBarView> delete_factory_; |
143 | 142 |
144 // The target height for the bar portion of the InfoBarView. | 143 // The target height for the bar portion of the InfoBarView. |
145 int target_height_; | 144 int target_height_; |
146 | 145 |
| 146 // The current heights of the tab and bar portions. |
| 147 int tab_height_; |
| 148 int bar_height_; |
| 149 |
| 150 // The paths for the InfoBarBackground to draw, sized according to the heights |
| 151 // above. |
147 scoped_ptr<SkPath> fill_path_; | 152 scoped_ptr<SkPath> fill_path_; |
148 scoped_ptr<SkPath> stroke_path_; | 153 scoped_ptr<SkPath> stroke_path_; |
149 | 154 |
150 DISALLOW_COPY_AND_ASSIGN(InfoBarView); | 155 DISALLOW_COPY_AND_ASSIGN(InfoBarView); |
151 }; | 156 }; |
152 | 157 |
153 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ | 158 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_INFOBAR_VIEW_H_ |
OLD | NEW |