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

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

Issue 10815082: ash: Make sure the focus-border in the tray paints correctly, and tray-view should not be focusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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/tray/tray_views.h ('k') | no next file » | 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/tray_views.h" 5 #include "ash/system/tray/tray_views.h"
6 6
7 #include "ash/system/tray/tray_constants.h" 7 #include "ash/system/tray/tray_constants.h"
8 #include "ash/system/tray/tray_item_view.h" 8 #include "ash/system/tray/tray_item_view.h"
9 #include "grit/ash_strings.h" 9 #include "grit/ash_strings.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // ActionableView 102 // ActionableView
103 103
104 ActionableView::ActionableView() 104 ActionableView::ActionableView()
105 : has_capture_(false) { 105 : has_capture_(false) {
106 set_focusable(true); 106 set_focusable(true);
107 } 107 }
108 108
109 ActionableView::~ActionableView() { 109 ActionableView::~ActionableView() {
110 } 110 }
111 111
112 void ActionableView::DrawBorder(gfx::Canvas* canvas, const gfx::Rect& bounds) {
113 gfx::Rect rect = bounds;
114 rect.Inset(1, 1, 3, 3);
115 canvas->DrawRect(rect, kFocusBorderColor);
116 }
117
112 bool ActionableView::OnKeyPressed(const views::KeyEvent& event) { 118 bool ActionableView::OnKeyPressed(const views::KeyEvent& event) {
113 if (event.key_code() == ui::VKEY_SPACE || 119 if (event.key_code() == ui::VKEY_SPACE ||
114 event.key_code() == ui::VKEY_RETURN) { 120 event.key_code() == ui::VKEY_RETURN) {
115 return PerformAction(event); 121 return PerformAction(event);
116 } 122 }
117 return false; 123 return false;
118 } 124 }
119 125
120 bool ActionableView::OnMousePressed(const views::MouseEvent& event) { 126 bool ActionableView::OnMousePressed(const views::MouseEvent& event) {
121 // Return true so that this view starts capturing the events. 127 // Return true so that this view starts capturing the events.
122 has_capture_ = true; 128 has_capture_ = true;
123 return true; 129 return true;
124 } 130 }
125 131
126 void ActionableView::OnMouseReleased(const views::MouseEvent& event) { 132 void ActionableView::OnMouseReleased(const views::MouseEvent& event) {
127 if (has_capture_ && GetLocalBounds().Contains(event.location())) 133 if (has_capture_ && GetLocalBounds().Contains(event.location()))
128 PerformAction(event); 134 PerformAction(event);
129 } 135 }
130 136
131 void ActionableView::OnMouseCaptureLost() { 137 void ActionableView::OnMouseCaptureLost() {
132 has_capture_ = false; 138 has_capture_ = false;
133 } 139 }
134 140
135 void ActionableView::SetAccessibleName(const string16& name) { 141 void ActionableView::SetAccessibleName(const string16& name) {
136 accessible_name_ = name; 142 accessible_name_ = name;
137 } 143 }
138 144
139 void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) { 145 void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) {
140 if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { 146 if (HasFocus() && (focusable() || IsAccessibilityFocusable()))
141 canvas->DrawRect(gfx::Rect(1, 1, width() - 3, height() - 3), 147 DrawBorder(canvas, GetLocalBounds());
142 kFocusBorderColor);
143 }
144 } 148 }
145 149
146 ui::GestureStatus ActionableView::OnGestureEvent( 150 ui::GestureStatus ActionableView::OnGestureEvent(
147 const views::GestureEvent& event) { 151 const views::GestureEvent& event) {
148 if (event.type() == ui::ET_GESTURE_TAP) { 152 if (event.type() == ui::ET_GESTURE_TAP) {
149 return PerformAction(event) ? ui::GESTURE_STATUS_CONSUMED : 153 return PerformAction(event) ? ui::GESTURE_STATUS_CONSUMED :
150 ui::GESTURE_STATUS_UNKNOWN; 154 ui::GESTURE_STATUS_UNKNOWN;
151 } 155 }
152 return ui::GESTURE_STATUS_UNKNOWN; 156 return ui::GESTURE_STATUS_UNKNOWN;
153 } 157 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 tray_view->set_border(views::Border::CreateEmptyBorder( 646 tray_view->set_border(views::Border::CreateEmptyBorder(
643 kTrayLabelItemVerticalPaddingVeriticalAlignment, 647 kTrayLabelItemVerticalPaddingVeriticalAlignment,
644 horizontal_padding, 648 horizontal_padding,
645 kTrayLabelItemVerticalPaddingVeriticalAlignment, 649 kTrayLabelItemVerticalPaddingVeriticalAlignment,
646 horizontal_padding)); 650 horizontal_padding));
647 } 651 }
648 } 652 }
649 653
650 } // namespace internal 654 } // namespace internal
651 } // namespace ash 655 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698