forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the option of aligning the launcher to the left or right. There
is a ton of rough edges after this patch, but I don't want this patch to get any bigger. BUG=121962 TEST=covered by tests. R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10388036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136312 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
sky@chromium.org
committed
May 10, 2012
1 parent
b0055b9
commit 5544450
Showing
36 changed files
with
691 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/launcher/launcher_alignment_menu.h" | ||
|
||
#include "ash/shell.h" | ||
#include "ash/wm/shelf_auto_hide_behavior.h" | ||
#include "grit/ash_strings.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
namespace ash { | ||
|
||
LauncherAlignmentMenu::LauncherAlignmentMenu() : ui::SimpleMenuModel(NULL) { | ||
int align_group_id = 1; | ||
set_delegate(this); | ||
AddRadioItemWithStringId(MENU_ALIGN_LEFT, | ||
IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_LEFT, | ||
align_group_id); | ||
AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, | ||
IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_BOTTOM, | ||
align_group_id); | ||
AddRadioItemWithStringId(MENU_ALIGN_RIGHT, | ||
IDS_AURA_LAUNCHER_CONTEXT_MENU_ALIGN_RIGHT, | ||
align_group_id); | ||
} | ||
|
||
LauncherAlignmentMenu::~LauncherAlignmentMenu() { | ||
} | ||
|
||
bool LauncherAlignmentMenu::IsCommandIdChecked(int command_id) const { | ||
switch (command_id) { | ||
case MENU_ALIGN_LEFT: | ||
return ash::Shell::GetInstance()->GetShelfAlignment() == | ||
SHELF_ALIGNMENT_LEFT; | ||
case MENU_ALIGN_BOTTOM: | ||
return ash::Shell::GetInstance()->GetShelfAlignment() == | ||
SHELF_ALIGNMENT_BOTTOM; | ||
case MENU_ALIGN_RIGHT: | ||
return ash::Shell::GetInstance()->GetShelfAlignment() == | ||
SHELF_ALIGNMENT_RIGHT; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
bool LauncherAlignmentMenu::IsCommandIdEnabled(int command_id) const { | ||
return true; | ||
} | ||
|
||
bool LauncherAlignmentMenu::GetAcceleratorForCommandId( | ||
int command_id, | ||
ui::Accelerator* accelerator) { | ||
return false; | ||
} | ||
|
||
void LauncherAlignmentMenu::ExecuteCommand(int command_id) { | ||
switch (static_cast<MenuItem>(command_id)) { | ||
case MENU_ALIGN_LEFT: | ||
ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT); | ||
break; | ||
case MENU_ALIGN_BOTTOM: | ||
ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM); | ||
break; | ||
case MENU_ALIGN_RIGHT: | ||
ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT); | ||
break; | ||
} | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ASH_WM_LAUNCHER_LAUNCHER_ALIGNMENT_MENU_H_ | ||
#define ASH_WM_LAUNCHER_LAUNCHER_ALIGNMENT_MENU_H_ | ||
#pragma once | ||
|
||
#include "ash/ash_export.h" | ||
#include "base/basictypes.h" | ||
#include "ui/base/models/simple_menu_model.h" | ||
|
||
namespace ash { | ||
|
||
// Submenu for choosing the alignment of the launcher. | ||
class ASH_EXPORT LauncherAlignmentMenu : public ui::SimpleMenuModel, | ||
public ui::SimpleMenuModel::Delegate { | ||
public: | ||
LauncherAlignmentMenu(); | ||
virtual ~LauncherAlignmentMenu(); | ||
|
||
// ui::SimpleMenuModel::Delegate overrides: | ||
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; | ||
virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; | ||
virtual bool GetAcceleratorForCommandId( | ||
int command_id, | ||
ui::Accelerator* accelerator) OVERRIDE; | ||
virtual void ExecuteCommand(int command_id) OVERRIDE; | ||
|
||
private: | ||
enum MenuItem { | ||
// Offset so as not to interfere with other menus. | ||
MENU_ALIGN_LEFT = 500, | ||
MENU_ALIGN_RIGHT, | ||
MENU_ALIGN_BOTTOM, | ||
}; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(LauncherAlignmentMenu); | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_WM_LAUNCHER_LAUNCHER_ALIGNMENT_MENU_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.