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

Side by Side Diff: ash/launcher/launcher_view.cc

Issue 9295049: Allow focus to be sent between browser window and launcher/status window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
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/launcher/launcher_view.h" 5 #include "ash/launcher/launcher_view.h"
6 6
7 #include "ash/launcher/app_launcher_button.h" 7 #include "ash/launcher/app_launcher_button.h"
8 #include "ash/launcher/launcher_model.h" 8 #include "ash/launcher/launcher_model.h"
9 #include "ash/launcher/launcher_window_cycler.h" 9 #include "ash/launcher/launcher_window_cycler.h"
10 #include "ash/launcher/tabbed_launcher_button.h" 10 #include "ash/launcher/tabbed_launcher_button.h"
11 #include "ash/launcher/view_model.h" 11 #include "ash/launcher/view_model.h"
12 #include "ash/launcher/view_model_utils.h" 12 #include "ash/launcher/view_model_utils.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_delegate.h" 14 #include "ash/shell_delegate.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "grit/ui_resources.h" 16 #include "grit/ui_resources.h"
17 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/base/animation/animation.h" 18 #include "ui/base/animation/animation.h"
19 #include "ui/base/animation/throb_animation.h" 19 #include "ui/base/animation/throb_animation.h"
20 #include "ui/base/models/simple_menu_model.h" 20 #include "ui/base/models/simple_menu_model.h"
21 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/compositor/layer.h" 22 #include "ui/gfx/compositor/layer.h"
23 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
24 #include "ui/views/animation/bounds_animator.h" 24 #include "ui/views/animation/bounds_animator.h"
25 #include "ui/views/controls/button/image_button.h" 25 #include "ui/views/controls/button/image_button.h"
26 #include "ui/views/controls/menu/menu_model_adapter.h" 26 #include "ui/views/controls/menu/menu_model_adapter.h"
27 #include "ui/views/controls/menu/menu_runner.h" 27 #include "ui/views/controls/menu/menu_runner.h"
28 #include "ui/views/focus/focus_manager.h"
28 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
29 30
30 using ui::Animation; 31 using ui::Animation;
31 using views::View; 32 using views::View;
32 33
33 namespace ash { 34 namespace ash {
34 namespace internal { 35 namespace internal {
35 36
36 // Amount content is inset on the left edge. 37 // Amount content is inset on the left edge.
37 static const int kLeadingInset = 8; 38 static const int kLeadingInset = 8;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); 182 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate);
182 }; 183 };
183 184
184 LauncherView::LauncherView(LauncherModel* model) 185 LauncherView::LauncherView(LauncherModel* model)
185 : model_(model), 186 : model_(model),
186 view_model_(new ViewModel), 187 view_model_(new ViewModel),
187 overflow_button_(NULL), 188 overflow_button_(NULL),
188 dragging_(NULL), 189 dragging_(NULL),
189 drag_view_(NULL), 190 drag_view_(NULL),
190 drag_offset_(0), 191 drag_offset_(0),
191 start_drag_index_(-1) { 192 start_drag_index_(-1),
193 ctrl_forward_key_(ui::VKEY_F2, false, true, false),
194 ctrl_back_key_(ui::VKEY_F1, false, true, false) {
192 DCHECK(model_); 195 DCHECK(model_);
193 bounds_animator_.reset(new views::BoundsAnimator(this)); 196 bounds_animator_.reset(new views::BoundsAnimator(this));
197 AddAccelerator(ctrl_forward_key_);
198 AddAccelerator(ctrl_back_key_);
194 } 199 }
195 200
196 LauncherView::~LauncherView() { 201 LauncherView::~LauncherView() {
197 model_->RemoveObserver(this); 202 model_->RemoveObserver(this);
198 } 203 }
199 204
200 void LauncherView::Init() { 205 void LauncherView::Init() {
201 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 206 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
202 model_->AddObserver(this); 207 model_->AddObserver(this);
203 208
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 return gfx::Size(view_model_->ideal_bounds(1).right() + kLeadingInset, 491 return gfx::Size(view_model_->ideal_bounds(1).right() + kLeadingInset,
487 kPreferredHeight); 492 kPreferredHeight);
488 } 493 }
489 return gfx::Size(kButtonWidth * 2 + kLeadingInset * 2, kPreferredHeight); 494 return gfx::Size(kButtonWidth * 2 + kLeadingInset * 2, kPreferredHeight);
490 } 495 }
491 496
492 void LauncherView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 497 void LauncherView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
493 LayoutToIdealBounds(); 498 LayoutToIdealBounds();
494 } 499 }
495 500
501 bool LauncherView::AcceleratorPressed(const ui::Accelerator& accelerator) {
502 views::FocusManager* focus_manager = GetFocusManager();
503 const views::View* focused_view = focus_manager->GetFocusedView();
504 if (!Contains(focused_view))
505 return false;
506
507 ShellDelegate* delegate = Shell::GetInstance()->delegate();
508 if (!delegate)
509 return false;
510
511 switch (accelerator.key_code()) {
512 case ui::VKEY_F1:
513 delegate->RotateFocus(true);
514 return true;
515 case ui::VKEY_F2:
516 delegate->RotateFocus(false);
517 return true;
518 default:
519 return false;
520 }
521 }
522
496 void LauncherView::LauncherItemAdded(int model_index) { 523 void LauncherView::LauncherItemAdded(int model_index) {
497 CancelDrag(NULL); 524 CancelDrag(NULL);
498 525
499 views::View* view = CreateViewForItem(model_->items()[model_index]); 526 views::View* view = CreateViewForItem(model_->items()[model_index]);
500 AddChildView(view); 527 AddChildView(view);
501 // Hide the view, it'll be made visible when the animation is done. 528 // Hide the view, it'll be made visible when the animation is done.
502 view->SetVisible(false); 529 view->SetVisible(false);
503 view_model_->Add(view, model_index); 530 view_model_->Add(view, model_index);
504 531
505 // The first animation moves all the views to their target position. |view| is 532 // The first animation moves all the views to their target position. |view| is
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 cycler_->Cycle(); 665 cycler_->Cycle();
639 break; 666 break;
640 667
641 default: 668 default:
642 NOTREACHED(); 669 NOTREACHED();
643 } 670 }
644 } 671 }
645 672
646 } // namespace internal 673 } // namespace internal
647 } // namespace ash 674 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698