OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ash/launcher/launcher_alignment_menu.h" |
| 6 |
| 7 #include "ash/shell.h" |
| 8 #include "ash/wm/shelf_auto_hide_behavior.h" |
| 9 #include "grit/ash_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" |
| 11 |
| 12 namespace ash { |
| 13 |
| 14 LauncherAlignmentMenu::LauncherAlignmentMenu() : ui::SimpleMenuModel(NULL) { |
| 15 int align_group_id = 1; |
| 16 set_delegate(this); |
| 17 AddRadioItemWithStringId(MENU_ALIGN_LEFT, |
| 18 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_LEFT, |
| 19 align_group_id); |
| 20 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, |
| 21 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_BOTTOM, |
| 22 align_group_id); |
| 23 AddRadioItemWithStringId(MENU_ALIGN_RIGHT, |
| 24 IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_RIGHT, |
| 25 align_group_id); |
| 26 } |
| 27 |
| 28 LauncherAlignmentMenu::~LauncherAlignmentMenu() { |
| 29 } |
| 30 |
| 31 bool LauncherAlignmentMenu::IsCommandIdChecked(int command_id) const { |
| 32 switch (command_id) { |
| 33 case MENU_ALIGN_LEFT: |
| 34 return ash::Shell::GetInstance()->GetShelfAlignment() == |
| 35 SHELF_ALIGNMENT_LEFT; |
| 36 case MENU_ALIGN_BOTTOM: |
| 37 return ash::Shell::GetInstance()->GetShelfAlignment() == |
| 38 SHELF_ALIGNMENT_BOTTOM; |
| 39 case MENU_ALIGN_RIGHT: |
| 40 return ash::Shell::GetInstance()->GetShelfAlignment() == |
| 41 SHELF_ALIGNMENT_RIGHT; |
| 42 default: |
| 43 return false; |
| 44 } |
| 45 } |
| 46 |
| 47 bool LauncherAlignmentMenu::IsCommandIdEnabled(int command_id) const { |
| 48 return true; |
| 49 } |
| 50 |
| 51 bool LauncherAlignmentMenu::GetAcceleratorForCommandId( |
| 52 int command_id, |
| 53 ui::Accelerator* accelerator) { |
| 54 return false; |
| 55 } |
| 56 |
| 57 void LauncherAlignmentMenu::ExecuteCommand(int command_id) { |
| 58 switch (static_cast<MenuItem>(command_id)) { |
| 59 case MENU_ALIGN_LEFT: |
| 60 ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT); |
| 61 break; |
| 62 case MENU_ALIGN_BOTTOM: |
| 63 ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 64 break; |
| 65 case MENU_ALIGN_RIGHT: |
| 66 ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT); |
| 67 break; |
| 68 } |
| 69 } |
| 70 |
| 71 } // namespace ash |
OLD | NEW |