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

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

Issue 556383002: Status Panel Touch Feedback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/system/tray/tray_popup_item_container.h"
6
7 #include "ash/ash_switches.h"
8 #include "ash/system/tray/tray_constants.h"
9 #include "base/command_line.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/views/border.h"
12 #include "ui/views/layout/box_layout.h"
13
14 namespace ash {
15
16 TrayPopupItemContainer::TrayPopupItemContainer(views::View* view,
17 bool change_background,
18 bool draw_border)
19 : active_(false),
20 change_background_(change_background),
21 touch_feedback_enabled_(false) {
22 set_notify_enter_exit_on_child(true);
23 if (draw_border) {
24 SetBorder(
25 views::Border::CreateSolidSidedBorder(0, 0, 1, 0, kBorderLightColor));
26 }
27 views::BoxLayout* layout = new views::BoxLayout(
28 views::BoxLayout::kVertical, 0, 0, 0);
29 layout->SetDefaultFlex(1);
30 SetLayoutManager(layout);
31 SetPaintToLayer(view->layer() != NULL);
32 if (view->layer())
33 SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
34 AddChildView(view);
35 SetVisible(view->visible());
36
37 if (CommandLine::ForCurrentProcess()->
38 HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) {
39 touch_feedback_enabled_ = true;
40 }
41 }
42
43 TrayPopupItemContainer::~TrayPopupItemContainer() {
44 }
45
46 void TrayPopupItemContainer::SetActive(bool active) {
47 if (active_ == active)
48 return;
49 active_ = active;
50 SchedulePaint();
51 }
52
53 void TrayPopupItemContainer::ChildVisibilityChanged(View* child) {
54 if (visible() == child->visible())
55 return;
56 SetVisible(child->visible());
57 PreferredSizeChanged();
58 }
59
60 void TrayPopupItemContainer::ChildPreferredSizeChanged(View* child) {
61 PreferredSizeChanged();
62 }
63
64 void TrayPopupItemContainer::OnMouseEntered(const ui::MouseEvent& event) {
65 SetActive(true);
66 }
67
68 void TrayPopupItemContainer::OnMouseExited(const ui::MouseEvent& event) {
69 SetActive(false);
70 }
71
72 void TrayPopupItemContainer::OnGestureEvent(ui::GestureEvent* event) {
73 if (!touch_feedback_enabled_)
74 return;
75
76 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
77 SetActive(true);
78 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||
79 event->type() == ui::ET_GESTURE_TAP_CANCEL ||
80 event->type() == ui::ET_GESTURE_TAP ||
81 event->type() == ui::ET_GESTURE_END) {
flackr 2014/09/10 22:54:31 END and SCROLL_BEGIN shouldn't be necessary as far
jonross 2014/09/11 15:53:23 Done.
82 SetActive(false);
83 }
84 }
85
86 void TrayPopupItemContainer::OnPaintBackground(gfx::Canvas* canvas) {
87 if (child_count() == 0)
88 return;
89
90 views::View* view = child_at(0);
91 if (!view->background()) {
92 canvas->FillRect(gfx::Rect(size()), (active_ && change_background_) ?
93 kHoverBackgroundColor : kBackgroundColor);
94 }
95 }
96
97 } // namespace ash
OLDNEW
« ash/system/tray/tray_popup_item_container.h ('K') | « ash/system/tray/tray_popup_item_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698