OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/common/system/tray/tray_popup_item_container.h" | 5 #include "ash/common/system/tray/tray_popup_item_container.h" |
6 | 6 |
7 #include "ash/common/system/tray/tray_constants.h" | 7 #include "ash/common/system/tray/tray_constants.h" |
8 #include "ui/base/ui_base_switches_util.h" | 8 #include "ui/base/ui_base_switches_util.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/views/border.h" | 10 #include "ui/views/border.h" |
11 #include "ui/views/layout/box_layout.h" | 11 #include "ui/views/layout/box_layout.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 TrayPopupItemContainer::TrayPopupItemContainer(views::View* view, | 15 TrayPopupItemContainer::TrayPopupItemContainer(views::View* view, |
16 bool change_background, | 16 bool change_background) |
17 bool draw_border) | |
18 : active_(false), change_background_(change_background) { | 17 : active_(false), change_background_(change_background) { |
19 set_notify_enter_exit_on_child(true); | 18 set_notify_enter_exit_on_child(true); |
20 if (draw_border) { | |
21 SetBorder( | |
22 views::Border::CreateSolidSidedBorder(0, 0, 1, 0, kBorderLightColor)); | |
23 } | |
24 views::BoxLayout* layout = | 19 views::BoxLayout* layout = |
25 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); | 20 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
26 layout->SetDefaultFlex(1); | 21 layout->SetDefaultFlex(1); |
27 SetLayoutManager(layout); | 22 SetLayoutManager(layout); |
28 if (view->layer()) { | 23 if (view->layer()) { |
29 SetPaintToLayer(true); | 24 SetPaintToLayer(true); |
30 layer()->SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); | 25 layer()->SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely()); |
31 } | 26 } |
32 AddChildView(view); | 27 AddChildView(view); |
33 SetVisible(view->visible()); | 28 SetVisible(view->visible()); |
34 } | 29 } |
35 | 30 |
36 TrayPopupItemContainer::~TrayPopupItemContainer() {} | 31 TrayPopupItemContainer::~TrayPopupItemContainer() {} |
37 | 32 |
| 33 void TrayPopupItemContainer::SetDrawBorder(bool draw_border) { |
| 34 SetBorder(draw_border ? views::Border::CreateSolidSidedBorder( |
| 35 0, 0, 1, 0, kBorderLightColor) |
| 36 : nullptr); |
| 37 } |
| 38 |
38 void TrayPopupItemContainer::SetActive(bool active) { | 39 void TrayPopupItemContainer::SetActive(bool active) { |
39 if (!change_background_ || active_ == active) | 40 if (!change_background_ || active_ == active) |
40 return; | 41 return; |
41 active_ = active; | 42 active_ = active; |
42 SchedulePaint(); | 43 SchedulePaint(); |
43 } | 44 } |
44 | 45 |
45 void TrayPopupItemContainer::ChildVisibilityChanged(View* child) { | 46 void TrayPopupItemContainer::ChildVisibilityChanged(View* child) { |
46 if (visible() == child->visible()) | 47 if (visible() == child->visible()) |
47 return; | 48 return; |
(...skipping 29 matching lines...) Expand all Loading... |
77 return; | 78 return; |
78 | 79 |
79 views::View* view = child_at(0); | 80 views::View* view = child_at(0); |
80 if (!view->background()) { | 81 if (!view->background()) { |
81 canvas->FillRect(gfx::Rect(size()), | 82 canvas->FillRect(gfx::Rect(size()), |
82 (active_) ? kHoverBackgroundColor : kBackgroundColor); | 83 (active_) ? kHoverBackgroundColor : kBackgroundColor); |
83 } | 84 } |
84 } | 85 } |
85 | 86 |
86 } // namespace ash | 87 } // namespace ash |
OLD | NEW |