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

Side by Side Diff: ash/app_list/app_list_item_view.cc

Issue 10161021: Revert 133408 - Add accessibility info to app list items and allow them to be focused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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/app_list/app_list_item_view.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/app_list/app_list_item_view.h" 5 #include "ash/app_list/app_list_item_view.h"
6 6
7 #include "ash/app_list/app_list_item_model.h" 7 #include "ash/app_list/app_list_item_model.h"
8 #include "ash/app_list/app_list_model_view.h" 8 #include "ash/app_list/app_list_model_view.h"
9 #include "ash/app_list/drop_shadow_label.h" 9 #include "ash/app_list/drop_shadow_label.h"
10 #include "ash/app_list/icon_cache.h" 10 #include "ash/app_list/icon_cache.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/synchronization/cancellation_flag.h" 13 #include "base/synchronization/cancellation_flag.h"
14 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "ui/base/accessibility/accessible_view_state.h"
17 #include "ui/base/animation/throb_animation.h" 16 #include "ui/base/animation/throb_animation.h"
18 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/font.h" 19 #include "ui/gfx/font.h"
21 #include "ui/gfx/shadow_value.h" 20 #include "ui/gfx/shadow_value.h"
22 #include "ui/gfx/skbitmap_operations.h" 21 #include "ui/gfx/skbitmap_operations.h"
23 #include "ui/views/controls/image_view.h" 22 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/menu/menu_item_view.h" 23 #include "ui/views/controls/menu/menu_item_view.h"
25 #include "ui/views/controls/menu/menu_model_adapter.h" 24 #include "ui/views/controls/menu/menu_model_adapter.h"
26 #include "ui/views/controls/menu/menu_runner.h" 25 #include "ui/views/controls/menu/menu_runner.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 196
198 AddChildView(icon_); 197 AddChildView(icon_);
199 AddChildView(title_); 198 AddChildView(title_);
200 199
201 ItemIconChanged(); 200 ItemIconChanged();
202 ItemTitleChanged(); 201 ItemTitleChanged();
203 model_->AddObserver(this); 202 model_->AddObserver(this);
204 203
205 set_context_menu_controller(this); 204 set_context_menu_controller(this);
206 set_request_focus_on_press(false); 205 set_request_focus_on_press(false);
207 set_focusable(true);
208 } 206 }
209 207
210 AppListItemView::~AppListItemView() { 208 AppListItemView::~AppListItemView() {
211 model_->RemoveObserver(this); 209 model_->RemoveObserver(this);
212 CancelPendingIconOperation(); 210 CancelPendingIconOperation();
213 } 211 }
214 212
215 // static 213 // static
216 gfx::Size AppListItemView::GetPreferredSizeForIconSize( 214 gfx::Size AppListItemView::GetPreferredSizeForIconSize(
217 const gfx::Size& icon_size) { 215 const gfx::Size& icon_size) {
(...skipping 28 matching lines...) Expand all
246 244
247 icon_size_ = size; 245 icon_size_ = size;
248 title_->SetFont(GetTitleFontForIconSize(size)); 246 title_->SetFont(GetTitleFontForIconSize(size));
249 UpdateIcon(); 247 UpdateIcon();
250 } 248 }
251 249
252 void AppListItemView::SetSelected(bool selected) { 250 void AppListItemView::SetSelected(bool selected) {
253 if (selected == selected_) 251 if (selected == selected_)
254 return; 252 return;
255 253
256 RequestFocus();
257 selected_ = selected; 254 selected_ = selected;
258 SchedulePaint(); 255 SchedulePaint();
259 } 256 }
260 257
261 void AppListItemView::UpdateIcon() { 258 void AppListItemView::UpdateIcon() {
262 // Skip if |icon_size_| has not been determined. 259 // Skip if |icon_size_| has not been determined.
263 if (icon_size_.IsEmpty()) 260 if (icon_size_.IsEmpty())
264 return; 261 return;
265 262
266 SkBitmap icon = model_->icon(); 263 SkBitmap icon = model_->icon();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 int alpha = SkColorGetA(kHoverAndPushedColor) * 353 int alpha = SkColorGetA(kHoverAndPushedColor) *
357 hover_animation_->GetCurrentValue(); 354 hover_animation_->GetCurrentValue();
358 canvas->FillRect(rect, SkColorSetA(kHoverAndPushedColor, alpha)); 355 canvas->FillRect(rect, SkColorSetA(kHoverAndPushedColor, alpha));
359 } else if (state() == BS_HOT || state() == BS_PUSHED) { 356 } else if (state() == BS_HOT || state() == BS_PUSHED) {
360 canvas->FillRect(rect, kHoverAndPushedColor); 357 canvas->FillRect(rect, kHoverAndPushedColor);
361 } else if (selected_) { 358 } else if (selected_) {
362 canvas->FillRect(rect, kSelectedColor); 359 canvas->FillRect(rect, kSelectedColor);
363 } 360 }
364 } 361 }
365 362
366 void AppListItemView::GetAccessibleState(ui::AccessibleViewState* state) {
367 state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
368 state->name = UTF8ToUTF16(model_->title());
369 }
370
371 void AppListItemView::ShowContextMenuForView(views::View* source, 363 void AppListItemView::ShowContextMenuForView(views::View* source,
372 const gfx::Point& point) { 364 const gfx::Point& point) {
373 ui::MenuModel* menu_model = model_->GetContextMenuModel(); 365 ui::MenuModel* menu_model = model_->GetContextMenuModel();
374 if (!menu_model) 366 if (!menu_model)
375 return; 367 return;
376 368
377 views::MenuModelAdapter menu_adapter(menu_model); 369 views::MenuModelAdapter menu_adapter(menu_model);
378 context_menu_runner_.reset( 370 context_menu_runner_.reset(
379 new views::MenuRunner(new views::MenuItemView(&menu_adapter))); 371 new views::MenuRunner(new views::MenuItemView(&menu_adapter)));
380 menu_adapter.BuildMenu(context_menu_runner_->GetMenu()); 372 menu_adapter.BuildMenu(context_menu_runner_->GetMenu());
381 if (context_menu_runner_->RunMenuAt( 373 if (context_menu_runner_->RunMenuAt(
382 GetWidget(), NULL, gfx::Rect(point, gfx::Size()), 374 GetWidget(), NULL, gfx::Rect(point, gfx::Size()),
383 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == 375 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
384 views::MenuRunner::MENU_DELETED) 376 views::MenuRunner::MENU_DELETED)
385 return; 377 return;
386 } 378 }
387 379
388 void AppListItemView::StateChanged() { 380 void AppListItemView::StateChanged() {
389 if (state() == BS_HOT || state() == BS_PUSHED) { 381 if (state() == BS_HOT || state() == BS_PUSHED) {
390 list_model_view_->SetSelectedItem(this); 382 list_model_view_->SetSelectedItem(this);
391 } else { 383 } else {
392 list_model_view_->ClearSelectedItem(this); 384 list_model_view_->ClearSelectedItem(this);
393 model_->SetHighlighted(false); 385 model_->SetHighlighted(false);
394 } 386 }
395 } 387 }
396 388
397 } // namespace ash 389 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/app_list_item_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698