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

Side by Side Diff: ash/common/system/tray/tray_popup_item_container.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/system/tray/tray_popup_item_container.h"
6
7 #include "ash/common/system/tray/tray_constants.h"
8 #include "ui/gfx/canvas.h"
9 #include "ui/views/layout/box_layout.h"
10
11 namespace ash {
12
13 TrayPopupItemContainer::TrayPopupItemContainer(views::View* view,
14 bool change_background)
15 : active_(false), change_background_(change_background) {
16 set_notify_enter_exit_on_child(true);
17 views::BoxLayout* layout =
18 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
19 layout->SetDefaultFlex(1);
20 SetLayoutManager(layout);
21 if (view->layer()) {
22 SetPaintToLayer();
23 layer()->SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
24 }
25 AddChildView(view);
26 SetVisible(view->visible());
27 }
28
29 TrayPopupItemContainer::~TrayPopupItemContainer() {}
30
31 void TrayPopupItemContainer::SetActive(bool active) {
32 if (!change_background_ || active_ == active)
33 return;
34 active_ = active;
35 SchedulePaint();
36 }
37
38 void TrayPopupItemContainer::ChildVisibilityChanged(View* child) {
39 if (visible() == child->visible())
40 return;
41 SetVisible(child->visible());
42 PreferredSizeChanged();
43 }
44
45 void TrayPopupItemContainer::ChildPreferredSizeChanged(View* child) {
46 PreferredSizeChanged();
47 }
48
49 void TrayPopupItemContainer::OnMouseEntered(const ui::MouseEvent& event) {
50 SetActive(true);
51 }
52
53 void TrayPopupItemContainer::OnMouseExited(const ui::MouseEvent& event) {
54 SetActive(false);
55 }
56
57 void TrayPopupItemContainer::OnGestureEvent(ui::GestureEvent* event) {
58 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
59 SetActive(true);
60 } else if (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
61 event->type() == ui::ET_GESTURE_TAP) {
62 SetActive(false);
63 }
64 }
65
66 void TrayPopupItemContainer::OnPaintBackground(gfx::Canvas* canvas) {
67 if (child_count() == 0)
68 return;
69
70 views::View* view = child_at(0);
71 if (!view->background()) {
72 canvas->FillRect(gfx::Rect(size()),
73 (active_) ? kHoverBackgroundColor : kBackgroundColor);
74 }
75 }
76
77 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_item_container.h ('k') | ash/common/system/tray/tray_popup_item_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698