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

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

Issue 10668009: UI refinement for left/right ash tray and bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 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
« no previous file with comments | « ash/system/status_area_widget_delegate.cc ('k') | ash/system/tray/system_tray_bubble.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 #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 30 matching lines...) Expand all
41 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
42 #include "ui/compositor/layer.h" 42 #include "ui/compositor/layer.h"
43 #include "ui/gfx/canvas.h" 43 #include "ui/gfx/canvas.h"
44 #include "ui/gfx/skia_util.h" 44 #include "ui/gfx/skia_util.h"
45 #include "ui/views/border.h" 45 #include "ui/views/border.h"
46 #include "ui/views/controls/label.h" 46 #include "ui/views/controls/label.h"
47 #include "ui/views/layout/box_layout.h" 47 #include "ui/views/layout/box_layout.h"
48 #include "ui/views/layout/fill_layout.h" 48 #include "ui/views/layout/fill_layout.h"
49 #include "ui/views/view.h" 49 #include "ui/views/view.h"
50 50
51 namespace {
52
53 // Adjust the size of SystemTrayContainer with additional padding.
54 const int kTrayContainerVerticalPaddingBottomAlignment = 1;
55 const int kTrayContainerHorizontalPaddingBottomAlignment = 1;
56 const int kTrayContainerVerticalPaddingVerticalAlignment = 1;
57 const int kTrayContainerHorizontalPaddingVerticalAlignment = 2;
58
59 } // namespace
60
51 namespace ash { 61 namespace ash {
52 62
53 namespace internal { 63 namespace internal {
54 64
55 // Container for all the items in the tray. The container auto-resizes the 65 // Container for all the items in the tray. The container auto-resizes the
56 // widget when necessary. 66 // widget when necessary.
57 class SystemTrayContainer : public views::View { 67 class SystemTrayContainer : public views::View {
58 public: 68 public:
59 SystemTrayContainer() {} 69 SystemTrayContainer() {}
60 virtual ~SystemTrayContainer() {} 70 virtual ~SystemTrayContainer() {}
61 71
62 void SetLayoutManager(views::LayoutManager* layout_manager) { 72 void UpdateLayout(ShelfAlignment alignment) {
63 views::View::SetLayoutManager(layout_manager); 73 // Adjust the size of status tray dark background by adding additional
74 // empty border.
75 if (alignment == SHELF_ALIGNMENT_BOTTOM) {
76 set_border(views::Border::CreateEmptyBorder(
77 kTrayContainerVerticalPaddingBottomAlignment,
78 kTrayContainerHorizontalPaddingBottomAlignment,
79 kTrayContainerVerticalPaddingBottomAlignment,
80 kTrayContainerHorizontalPaddingBottomAlignment));
81 views::View::SetLayoutManager(new views::BoxLayout(
82 views::BoxLayout::kHorizontal, 0, 0, 0));
83 } else {
84 set_border(views::Border::CreateEmptyBorder(
85 kTrayContainerVerticalPaddingVerticalAlignment,
86 kTrayContainerHorizontalPaddingVerticalAlignment,
87 kTrayContainerVerticalPaddingVerticalAlignment,
88 kTrayContainerHorizontalPaddingVerticalAlignment));
89 views::View::SetLayoutManager(new views::BoxLayout(
90 views::BoxLayout::kVertical, 0, 0, 0));
91 }
64 PreferredSizeChanged(); 92 PreferredSizeChanged();
65 } 93 }
66 94
67 private: 95 private:
68 // Overridden from views::View. 96 // Overridden from views::View.
69 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE { 97 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE {
70 PreferredSizeChanged(); 98 PreferredSizeChanged();
71 } 99 }
72 100
73 virtual void ChildVisibilityChanged(View* child) OVERRIDE { 101 virtual void ChildVisibilityChanged(View* child) OVERRIDE {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 drive_observer_(NULL), 155 drive_observer_(NULL),
128 ime_observer_(NULL), 156 ime_observer_(NULL),
129 locale_observer_(NULL), 157 locale_observer_(NULL),
130 network_observer_(NULL), 158 network_observer_(NULL),
131 update_observer_(NULL), 159 update_observer_(NULL),
132 user_observer_(NULL), 160 user_observer_(NULL),
133 should_show_launcher_(false), 161 should_show_launcher_(false),
134 default_bubble_height_(0), 162 default_bubble_height_(0),
135 hide_notifications_(false) { 163 hide_notifications_(false) {
136 tray_container_ = new internal::SystemTrayContainer; 164 tray_container_ = new internal::SystemTrayContainer;
137 tray_container_->SetLayoutManager(new views::BoxLayout( 165 tray_container_->UpdateLayout(shelf_alignment());
138 views::BoxLayout::kHorizontal, 0, 0, 0));
139 tray_container_->set_border(
140 views::Border::CreateEmptyBorder(1, 1, 1, 1));
141 SetContents(tray_container_); 166 SetContents(tray_container_);
142 SetBorder(); 167 SetBorder();
143 } 168 }
144 169
145 SystemTray::~SystemTray() { 170 SystemTray::~SystemTray() {
146 bubble_.reset(); 171 bubble_.reset();
147 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 172 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
148 it != items_.end(); 173 it != items_.end();
149 ++it) { 174 ++it) {
150 (*it)->DestroyTrayView(); 175 (*it)->DestroyTrayView();
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 505 }
481 506
482 void SystemTray::SetBorder() { 507 void SystemTray::SetBorder() {
483 // Change the border padding for different shelf alignment. 508 // Change the border padding for different shelf alignment.
484 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { 509 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
485 set_border(views::Border::CreateEmptyBorder(0, 0, 510 set_border(views::Border::CreateEmptyBorder(0, 0,
486 kPaddingFromBottomOfScreenBottomAlignment, 511 kPaddingFromBottomOfScreenBottomAlignment,
487 kPaddingFromRightEdgeOfScreenBottomAlignment)); 512 kPaddingFromRightEdgeOfScreenBottomAlignment));
488 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { 513 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
489 set_border(views::Border::CreateEmptyBorder(0, 514 set_border(views::Border::CreateEmptyBorder(0,
490 kPaddingFromEdgeOfScreenVerticalAlignment, 515 kPaddingFromOuterEdgeOfLauncherVerticalAlignment,
491 kPaddingFromBottomOfScreenVerticalAlignment, 516 kPaddingFromBottomOfScreenVerticalAlignment,
492 kPaddingFromEdgeOfLauncherVerticalAlignment)); 517 kPaddingFromInnerEdgeOfLauncherVerticalAlignment));
493 } else { 518 } else {
494 set_border(views::Border::CreateEmptyBorder(0, 519 set_border(views::Border::CreateEmptyBorder(0,
495 kPaddingFromEdgeOfLauncherVerticalAlignment, 520 kPaddingFromInnerEdgeOfLauncherVerticalAlignment,
496 kPaddingFromBottomOfScreenVerticalAlignment, 521 kPaddingFromBottomOfScreenVerticalAlignment,
497 kPaddingFromEdgeOfScreenVerticalAlignment)); 522 kPaddingFromOuterEdgeOfLauncherVerticalAlignment));
498 } 523 }
499 } 524 }
500 525
501 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 526 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
502 if (alignment == shelf_alignment()) 527 if (alignment == shelf_alignment())
503 return; 528 return;
504 internal::TrayBackgroundView::SetShelfAlignment(alignment); 529 internal::TrayBackgroundView::SetShelfAlignment(alignment);
505 UpdateAfterShelfAlignmentChange(alignment); 530 UpdateAfterShelfAlignmentChange(alignment);
506 SetBorder(); 531 SetBorder();
507 tray_container_->SetLayoutManager(new views::BoxLayout( 532 tray_container_->UpdateLayout(alignment);
508 alignment == SHELF_ALIGNMENT_BOTTOM ?
509 views::BoxLayout::kHorizontal : views::BoxLayout::kVertical,
510 0, 0, 0));
511 } 533 }
512 534
513 bool SystemTray::PerformAction(const views::Event& event) { 535 bool SystemTray::PerformAction(const views::Event& event) {
514 // If we're already showing the default view, hide it; otherwise, show it 536 // If we're already showing the default view, hide it; otherwise, show it
515 // (and hide any popup that's currently shown). 537 // (and hide any popup that's currently shown).
516 if (bubble_.get() && 538 if (bubble_.get() &&
517 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) { 539 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT) {
518 bubble_->Close(); 540 bubble_->Close();
519 } else { 541 } else {
520 int arrow_offset = -1; 542 int arrow_offset = -1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 578
557 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) { 579 void SystemTray::OnPaintFocusBorder(gfx::Canvas* canvas) {
558 // The tray itself expands to the right and bottom edge of the screen to make 580 // The tray itself expands to the right and bottom edge of the screen to make
559 // sure clicking on the edges brings up the popup. However, the focus border 581 // sure clicking on the edges brings up the popup. However, the focus border
560 // should be only around the container. 582 // should be only around the container.
561 if (GetWidget() && GetWidget()->IsActive()) 583 if (GetWidget() && GetWidget()->IsActive())
562 canvas->DrawFocusRect(tray_container_->bounds()); 584 canvas->DrawFocusRect(tray_container_->bounds());
563 } 585 }
564 586
565 } // namespace ash 587 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget_delegate.cc ('k') | ash/system/tray/system_tray_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698