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

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

Issue 10546147: ash: Fix the border colors in the uber-tray popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge-tot Created 8 years, 6 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 | « no previous file | ash/system/tray/tray_bubble_view.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_bubble.h" 5 #include "ash/system/tray/system_tray_bubble.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/system_tray_item.h" 10 #include "ash/system/tray/system_tray_item.h"
(...skipping 15 matching lines...) Expand all
26 26
27 const int kAnimationDurationForPopupMS = 200; 27 const int kAnimationDurationForPopupMS = 200;
28 28
29 // Normally a detailed view is the same size as the default view. However, 29 // Normally a detailed view is the same size as the default view. However,
30 // when showing a detailed view directly (e.g. clicking on a notification), 30 // when showing a detailed view directly (e.g. clicking on a notification),
31 // we may not know the height of the default view, or the default view may 31 // we may not know the height of the default view, or the default view may
32 // be too short, so we use this as a default and minimum height for any 32 // be too short, so we use this as a default and minimum height for any
33 // detailed view. 33 // detailed view.
34 const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5; 34 const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5;
35 35
36 class TrayPopupItemBorder : public views::Border {
37 public:
38 explicit TrayPopupItemBorder(views::View* owner) : owner_(owner) {}
39 virtual ~TrayPopupItemBorder() {}
40
41 private:
42 // Overridden from views::Border.
43 virtual void Paint(const views::View& view,
44 gfx::Canvas* canvas) const OVERRIDE {
45 const views::View* parent = view.parent();
46 int index = parent->GetIndexOf(&view);
47
48 // Draw a dark top-border for the first item.
49 if (index == 0)
50 canvas->FillRect(gfx::Rect(0, 0, view.width(), 1), kBorderDarkColor);
51
52 // Bottom border.
53 if (index != parent->child_count() - 1) {
54 canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1),
55 kBorderLightColor);
56 }
57
58 // Left and right borders.
59 canvas->FillRect(gfx::Rect(0, 0, 1, view.height()), kBorderDarkColor);
60 canvas->FillRect(gfx::Rect(view.width() - 1, 0, 1, view.height()),
61 kBorderDarkColor);
62 }
63
64 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
65 const views::View* parent = owner_->parent();
66 int index = parent->GetIndexOf(owner_);
67 insets->Set(index == 0, 1, index != parent->child_count() - 1, 1);
68 }
69
70 views::View* owner_;
71
72 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder);
73 };
74
36 // A view with some special behaviour for tray items in the popup: 75 // A view with some special behaviour for tray items in the popup:
37 // - changes background color on hover. 76 // - changes background color on hover.
38 class TrayPopupItemContainer : public views::View { 77 class TrayPopupItemContainer : public views::View {
39 public: 78 public:
40 explicit TrayPopupItemContainer(views::View* view) : hover_(false) { 79 explicit TrayPopupItemContainer(views::View* view) : hover_(false) {
41 set_notify_enter_exit_on_child(true); 80 set_notify_enter_exit_on_child(true);
42 set_border(view->border() ? views::Border::CreateEmptyBorder(0, 0, 0, 0) : 81 set_border(new TrayPopupItemBorder(this));
43 views::Border::CreateSolidSidedBorder(1, 1, 0, 1, kBorderDarkColor));
44 views::BoxLayout* layout = new views::BoxLayout( 82 views::BoxLayout* layout = new views::BoxLayout(
45 views::BoxLayout::kVertical, 0, 0, 0); 83 views::BoxLayout::kVertical, 0, 0, 0);
46 layout->set_spread_blank_space(true); 84 layout->set_spread_blank_space(true);
47 SetLayoutManager(layout); 85 SetLayoutManager(layout);
48 SetPaintToLayer(view->layer() != NULL); 86 SetPaintToLayer(view->layer() != NULL);
49 if (view->layer()) 87 if (view->layer())
50 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); 88 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
51 AddChildView(view); 89 AddChildView(view);
52 SetVisible(view->visible()); 90 SetVisible(view->visible());
53 } 91 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 488 }
451 489
452 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) { 490 void SystemTrayBubble::OnWidgetClosing(views::Widget* widget) {
453 CHECK_EQ(bubble_widget_, widget); 491 CHECK_EQ(bubble_widget_, widget);
454 bubble_widget_ = NULL; 492 bubble_widget_ = NULL;
455 tray_->RemoveBubble(this); 493 tray_->RemoveBubble(this);
456 } 494 }
457 495
458 } // namespace internal 496 } // namespace internal
459 } // namespace ash 497 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/tray_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698