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

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 10384178: ash: Make sure all the sub-popups retain the same height as the main popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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 | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('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 #include "ash/system/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell/panel_window.h" 8 #include "ash/shell/panel_window.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/audio/tray_volume.h" 10 #include "ash/system/audio/tray_volume.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (tray_item) { 243 if (tray_item) {
244 tray_container_->AddChildViewAt(tray_item, 0); 244 tray_container_->AddChildViewAt(tray_item, 0);
245 PreferredSizeChanged(); 245 PreferredSizeChanged();
246 } 246 }
247 } 247 }
248 248
249 void SystemTray::RemoveTrayItem(SystemTrayItem* item) { 249 void SystemTray::RemoveTrayItem(SystemTrayItem* item) {
250 NOTIMPLEMENTED(); 250 NOTIMPLEMENTED();
251 } 251 }
252 252
253 void SystemTray::ShowDefaultView() { 253 void SystemTray::ShowDefaultView(BubbleCreationType creation_type) {
254 ShowItems(items_.get(), false, true); 254 ShowItems(items_.get(), false, true, creation_type);
255 } 255 }
256 256
257 void SystemTray::ShowDetailedView(SystemTrayItem* item, 257 void SystemTray::ShowDetailedView(SystemTrayItem* item,
258 int close_delay, 258 int close_delay,
259 bool activate) { 259 bool activate,
260 BubbleCreationType creation_type) {
260 std::vector<SystemTrayItem*> items; 261 std::vector<SystemTrayItem*> items;
261 items.push_back(item); 262 items.push_back(item);
262 ShowItems(items, true, activate); 263 ShowItems(items, true, activate, creation_type);
263 bubble_->StartAutoCloseTimer(close_delay); 264 bubble_->StartAutoCloseTimer(close_delay);
264 } 265 }
265 266
266 void SystemTray::ShowNotificationView(SystemTrayItem* item) { 267 void SystemTray::ShowNotificationView(SystemTrayItem* item) {
267 if (std::find(notification_items_.begin(), notification_items_.end(), item) 268 if (std::find(notification_items_.begin(), notification_items_.end(), item)
268 != notification_items_.end()) 269 != notification_items_.end())
269 return; 270 return;
270 notification_items_.push_back(item); 271 notification_items_.push_back(item);
271 UpdateNotificationBubble(); 272 UpdateNotificationBubble();
272 } 273 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 330 }
330 331
331 void SystemTray::SetPaintsBackground( 332 void SystemTray::SetPaintsBackground(
332 bool value, 333 bool value,
333 internal::BackgroundAnimator::ChangeType change_type) { 334 internal::BackgroundAnimator::ChangeType change_type) {
334 hide_background_animator_.SetPaintsBackground(value, change_type); 335 hide_background_animator_.SetPaintsBackground(value, change_type);
335 } 336 }
336 337
337 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, 338 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
338 bool detailed, 339 bool detailed,
339 bool can_activate) { 340 bool can_activate,
341 BubbleCreationType creation_type) {
340 // Destroy any existing bubble and create a new one. 342 // Destroy any existing bubble and create a new one.
341 SystemTrayBubble::BubbleType bubble_type = detailed ? 343 SystemTrayBubble::BubbleType bubble_type = detailed ?
342 SystemTrayBubble::BUBBLE_TYPE_DETAILED : 344 SystemTrayBubble::BUBBLE_TYPE_DETAILED :
343 SystemTrayBubble::BUBBLE_TYPE_DEFAULT; 345 SystemTrayBubble::BUBBLE_TYPE_DEFAULT;
344 bubble_.reset(new SystemTrayBubble(this, items, bubble_type)); 346 if (bubble_.get() && creation_type == BUBBLE_USE_EXISTING) {
345 ash::SystemTrayDelegate* delegate = 347 bubble_->UpdateView(items, bubble_type);
346 ash::Shell::GetInstance()->tray_delegate(); 348 } else {
347 views::View* anchor = tray_container_; 349 bubble_.reset(new SystemTrayBubble(this, items, bubble_type));
348 bubble_->InitView(anchor, SystemTrayBubble::ANCHOR_TYPE_TRAY, 350 ash::SystemTrayDelegate* delegate =
349 can_activate, delegate->GetUserLoginStatus()); 351 ash::Shell::GetInstance()->tray_delegate();
352 bubble_->InitView(tray_container_, SystemTrayBubble::ANCHOR_TYPE_TRAY,
353 can_activate, delegate->GetUserLoginStatus());
354 }
350 // If we have focus the shelf should be visible and we need to continue 355 // If we have focus the shelf should be visible and we need to continue
351 // showing the shelf when the popup is shown. 356 // showing the shelf when the popup is shown.
352 if (GetWidget()->IsActive()) 357 if (GetWidget()->IsActive())
353 should_show_launcher_ = true; 358 should_show_launcher_ = true;
354 UpdateNotificationBubble(); // State changed, re-create notifications. 359 UpdateNotificationBubble(); // State changed, re-create notifications.
355 } 360 }
356 361
357 void SystemTray::UpdateNotificationBubble() { 362 void SystemTray::UpdateNotificationBubble() {
358 // Only show the notification buble if we have notifications and we are not 363 // Only show the notification buble if we have notifications and we are not
359 // showing the default bubble. 364 // showing the default bubble.
(...skipping 29 matching lines...) Expand all
389 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); 394 notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
390 } 395 }
391 396
392 bool SystemTray::PerformAction(const views::Event& event) { 397 bool SystemTray::PerformAction(const views::Event& event) {
393 // If we're already showing the default view, hide it; otherwise, show it 398 // If we're already showing the default view, hide it; otherwise, show it
394 // (and hide any popup that's currently shown). 399 // (and hide any popup that's currently shown).
395 if (bubble_.get() && 400 if (bubble_.get() &&
396 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) { 401 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) {
397 bubble_->Close(); 402 bubble_->Close();
398 } else { 403 } else {
399 ShowDefaultView(); 404 ShowDefaultView(BUBBLE_CREATE_NEW);
400 } 405 }
401 return true; 406 return true;
402 } 407 }
403 408
404 void SystemTray::OnMouseEntered(const views::MouseEvent& event) { 409 void SystemTray::OnMouseEntered(const views::MouseEvent& event) {
405 should_show_launcher_ = true; 410 should_show_launcher_ = true;
406 hover_background_animator_.SetPaintsBackground(true, 411 hover_background_animator_.SetPaintsBackground(true,
407 internal::BackgroundAnimator::CHANGE_ANIMATE); 412 internal::BackgroundAnimator::CHANGE_ANIMATE);
408 } 413 }
409 414
(...skipping 25 matching lines...) Expand all
435 canvas->DrawFocusRect(tray_container_->bounds()); 440 canvas->DrawFocusRect(tray_container_->bounds());
436 } 441 }
437 442
438 void SystemTray::UpdateBackground(int alpha) { 443 void SystemTray::UpdateBackground(int alpha) {
439 background_->set_alpha(hide_background_animator_.alpha() + 444 background_->set_alpha(hide_background_animator_.alpha() +
440 hover_background_animator_.alpha()); 445 hover_background_animator_.alpha());
441 SchedulePaint(); 446 SchedulePaint();
442 } 447 }
443 448
444 } // namespace ash 449 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698