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

Side by Side Diff: chrome/browser/chromeos/notifications/notification_panel.cc

Issue 7349021: Convert some more view methods to the ui/views style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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 // Draws the view for the balloons. 5 // Draws the view for the balloons.
6 6
7 #include "chrome/browser/chromeos/notifications/notification_panel.h" 7 #include "chrome/browser/chromeos/notifications/notification_panel.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // views::View overrides. 148 // views::View overrides.
149 virtual gfx::Size GetPreferredSize() { 149 virtual gfx::Size GetPreferredSize() {
150 return preferred_size_; 150 return preferred_size_;
151 } 151 }
152 152
153 virtual void Layout() { 153 virtual void Layout() {
154 // Layout bottom up 154 // Layout bottom up
155 int height = 0; 155 int height = 0;
156 for (int i = child_count() - 1; i >= 0; --i) { 156 for (int i = child_count() - 1; i >= 0; --i) {
157 views::View* child = GetChildViewAt(i); 157 views::View* child = child_at(i);
158 child->SetBounds(0, height, child->width(), child->height()); 158 child->SetBounds(0, height, child->width(), child->height());
159 height += child->height() + margin_; 159 height += child->height() + margin_;
160 } 160 }
161 SchedulePaint(); 161 SchedulePaint();
162 } 162 }
163 163
164 // Updates the bound so that it can show all balloons. 164 // Updates the bound so that it can show all balloons.
165 void UpdateBounds() { 165 void UpdateBounds() {
166 int height = 0; 166 int height = 0;
167 int max_width = 0; 167 int max_width = 0;
168 for (int i = child_count() - 1; i >= 0; --i) { 168 for (int i = child_count() - 1; i >= 0; --i) {
169 views::View* child = GetChildViewAt(i); 169 views::View* child = child_at(i);
170 height += child->height() + margin_; 170 height += child->height() + margin_;
171 max_width = std::max(max_width, child->width()); 171 max_width = std::max(max_width, child->width());
172 } 172 }
173 if (height > 0) 173 if (height > 0)
174 height -= margin_; 174 height -= margin_;
175 preferred_size_.set_width(max_width); 175 preferred_size_.set_width(max_width);
176 preferred_size_.set_height(height); 176 preferred_size_.set_height(height);
177 SizeToPreferredSize(); 177 SizeToPreferredSize();
178 } 178 }
179 179
180 // Returns the bounds that covers new notifications. 180 // Returns the bounds that covers new notifications.
181 gfx::Rect GetNewBounds() { 181 gfx::Rect GetNewBounds() {
182 gfx::Rect rect; 182 gfx::Rect rect;
183 for (int i = child_count() - 1; i >= 0; --i) { 183 for (int i = child_count() - 1; i >= 0; --i) {
184 BalloonViewImpl* view = 184 BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
185 static_cast<BalloonViewImpl*>(GetChildViewAt(i));
186 if (!view->stale()) { 185 if (!view->stale()) {
187 if (rect.IsEmpty()) { 186 if (rect.IsEmpty()) {
188 rect = view->bounds(); 187 rect = view->bounds();
189 } else { 188 } else {
190 rect = rect.Union(view->bounds()); 189 rect = rect.Union(view->bounds());
191 } 190 }
192 } 191 }
193 } 192 }
194 return gfx::Rect(x(), y(), rect.width(), rect.height()); 193 return gfx::Rect(x(), y(), rect.width(), rect.height());
195 } 194 }
196 195
197 // Returns # of new notifications. 196 // Returns # of new notifications.
198 int GetNewCount() { 197 int GetNewCount() {
199 int count = 0; 198 int count = 0;
200 for (int i = child_count() - 1; i >= 0; --i) { 199 for (int i = child_count() - 1; i >= 0; --i) {
201 BalloonViewImpl* view = 200 BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
202 static_cast<BalloonViewImpl*>(GetChildViewAt(i));
203 if (!view->stale()) 201 if (!view->stale())
204 count++; 202 count++;
205 } 203 }
206 return count; 204 return count;
207 } 205 }
208 206
209 // Make all notifications stale. 207 // Make all notifications stale.
210 void MakeAllStale() { 208 void MakeAllStale() {
211 for (int i = child_count() - 1; i >= 0; --i) { 209 for (int i = child_count() - 1; i >= 0; --i) {
212 BalloonViewImpl* view = 210 BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
213 static_cast<BalloonViewImpl*>(GetChildViewAt(i));
214 view->set_stale(); 211 view->set_stale();
215 } 212 }
216 } 213 }
217 214
218 void DismissAll() { 215 void DismissAll() {
219 for (int i = child_count() - 1; i >= 0; --i) { 216 for (int i = child_count() - 1; i >= 0; --i) {
220 BalloonViewImpl* view = 217 BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
221 static_cast<BalloonViewImpl*>(GetChildViewAt(i));
222 view->Close(true); 218 view->Close(true);
223 } 219 }
224 } 220 }
225 221
226 BalloonViewImpl* FindBalloonView(const Notification& notification) { 222 BalloonViewImpl* FindBalloonView(const Notification& notification) {
227 for (int i = child_count() - 1; i >= 0; --i) { 223 for (int i = child_count() - 1; i >= 0; --i) {
228 BalloonViewImpl* view = 224 BalloonViewImpl* view = static_cast<BalloonViewImpl*>(child_at(i));
229 static_cast<BalloonViewImpl*>(GetChildViewAt(i));
230 if (view->IsFor(notification)) { 225 if (view->IsFor(notification)) {
231 return view; 226 return view;
232 } 227 }
233 } 228 }
234 return NULL; 229 return NULL;
235 } 230 }
236 231
237 BalloonViewImpl* FindBalloonView(const gfx::Point point) { 232 BalloonViewImpl* FindBalloonView(const gfx::Point point) {
238 gfx::Point copy(point); 233 gfx::Point copy(point);
239 ConvertPointFromWidget(this, &copy); 234 ConvertPointFromWidget(this, &copy);
240 for (int i = child_count() - 1; i >= 0; --i) { 235 for (int i = child_count() - 1; i >= 0; --i) {
241 views::View* view = GetChildViewAt(i); 236 views::View* view = child_at(i);
242 if (view->bounds().Contains(copy)) 237 if (view->bounds().Contains(copy))
243 return static_cast<BalloonViewImpl*>(view); 238 return static_cast<BalloonViewImpl*>(view);
244 } 239 }
245 return NULL; 240 return NULL;
246 } 241 }
247 242
248 private: 243 private:
249 gfx::Size preferred_size_; 244 gfx::Size preferred_size_;
250 int margin_; 245 int margin_;
251 246
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 &origin); 862 &origin);
868 return rect.Contains(gfx::Rect(origin, view->size())); 863 return rect.Contains(gfx::Rect(origin, view->size()));
869 } 864 }
870 865
871 866
872 bool NotificationPanelTester::IsActive(const BalloonViewImpl* view) const { 867 bool NotificationPanelTester::IsActive(const BalloonViewImpl* view) const {
873 return panel_->active_ == view; 868 return panel_->active_ == view;
874 } 869 }
875 870
876 } // namespace chromeos 871 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/notifications/balloon_view.cc ('k') | chrome/browser/chromeos/status/status_area_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698