OLD | NEW |
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_alignment_menu.h" | 5 #include "ash/launcher/launcher_alignment_menu.h" |
6 | 6 |
7 #include "ash/shelf_types.h" | 7 #include "ash/shelf_types.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/shelf_layout_manager.h" |
9 #include "grit/ash_strings.h" | 10 #include "grit/ash_strings.h" |
| 11 #include "ui/aura/root_window.h" |
10 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
11 | 13 |
12 namespace ash { | 14 namespace ash { |
13 | 15 |
14 LauncherAlignmentMenu::LauncherAlignmentMenu( | 16 LauncherAlignmentMenu::LauncherAlignmentMenu( |
15 aura::RootWindow* root) | 17 aura::RootWindow* root) |
16 : ui::SimpleMenuModel(NULL), | 18 : ui::SimpleMenuModel(NULL), |
17 root_window_(root) { | 19 root_window_(root) { |
18 DCHECK(root_window_); | 20 DCHECK(root_window_); |
19 int align_group_id = 1; | 21 int align_group_id = 1; |
20 set_delegate(this); | 22 set_delegate(this); |
21 AddRadioItemWithStringId(MENU_ALIGN_LEFT, | 23 AddRadioItemWithStringId(MENU_ALIGN_LEFT, |
22 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_LEFT, | 24 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_LEFT, |
23 align_group_id); | 25 align_group_id); |
24 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, | 26 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, |
25 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_BOTTOM, | 27 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_BOTTOM, |
26 align_group_id); | 28 align_group_id); |
27 AddRadioItemWithStringId(MENU_ALIGN_RIGHT, | 29 AddRadioItemWithStringId(MENU_ALIGN_RIGHT, |
28 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_RIGHT, | 30 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_RIGHT, |
29 align_group_id); | 31 align_group_id); |
30 } | 32 } |
31 | 33 |
32 LauncherAlignmentMenu::~LauncherAlignmentMenu() { | 34 LauncherAlignmentMenu::~LauncherAlignmentMenu() { |
33 } | 35 } |
34 | 36 |
35 bool LauncherAlignmentMenu::IsCommandIdChecked(int command_id) const { | 37 bool LauncherAlignmentMenu::IsCommandIdChecked(int command_id) const { |
36 switch (command_id) { | 38 return internal::ShelfLayoutManager::ForLauncher(root_window_)-> |
37 case MENU_ALIGN_LEFT: | 39 SelectValueForShelfAlignment( |
38 return Shell::GetInstance()->GetShelfAlignment(root_window_) == | 40 MENU_ALIGN_BOTTOM == command_id, |
39 SHELF_ALIGNMENT_LEFT; | 41 MENU_ALIGN_LEFT == command_id, |
40 case MENU_ALIGN_BOTTOM: | 42 MENU_ALIGN_RIGHT == command_id); |
41 return Shell::GetInstance()->GetShelfAlignment(root_window_) == | |
42 SHELF_ALIGNMENT_BOTTOM; | |
43 case MENU_ALIGN_RIGHT: | |
44 return Shell::GetInstance()->GetShelfAlignment(root_window_) == | |
45 SHELF_ALIGNMENT_RIGHT; | |
46 default: | |
47 return false; | |
48 } | |
49 } | 43 } |
50 | 44 |
51 bool LauncherAlignmentMenu::IsCommandIdEnabled(int command_id) const { | 45 bool LauncherAlignmentMenu::IsCommandIdEnabled(int command_id) const { |
52 return true; | 46 return true; |
53 } | 47 } |
54 | 48 |
55 bool LauncherAlignmentMenu::GetAcceleratorForCommandId( | 49 bool LauncherAlignmentMenu::GetAcceleratorForCommandId( |
56 int command_id, | 50 int command_id, |
57 ui::Accelerator* accelerator) { | 51 ui::Accelerator* accelerator) { |
58 return false; | 52 return false; |
(...skipping 10 matching lines...) Expand all Loading... |
69 root_window_); | 63 root_window_); |
70 break; | 64 break; |
71 case MENU_ALIGN_RIGHT: | 65 case MENU_ALIGN_RIGHT: |
72 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, | 66 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT, |
73 root_window_); | 67 root_window_); |
74 break; | 68 break; |
75 } | 69 } |
76 } | 70 } |
77 | 71 |
78 } // namespace ash | 72 } // namespace ash |
OLD | NEW |