summaryrefslogtreecommitdiffstats
path: root/app/menus/simple_menu_model.cc
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 21:34:04 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 21:34:04 +0000
commit9c8f1501112092eba0e1c411c2c196487eb61b00 (patch)
tree38a5b7452b7bb9d9a5334eb3740f4cdc1fe8da51 /app/menus/simple_menu_model.cc
parent66761b95332549f825999e482c17c94675275f49 (diff)
downloadchromium_src-9c8f1501112092eba0e1c411c2c196487eb61b00.zip
chromium_src-9c8f1501112092eba0e1c411c2c196487eb61b00.tar.gz
chromium_src-9c8f1501112092eba0e1c411c2c196487eb61b00.tar.bz2
Reapply r50859 with chromeos fixes.
GTK: First draft of the unified cut/copy/paste and +/-/Fullscreen menu items. Adds special menu item types that allow shoving buttons into them, along with tracking which button is selected. We now are halfway to the mocks that the chrome-ui-leads sent out. Review URL: http://codereview.chromium.org/2800015 BUG=45757 TEST=none Review URL: http://codereview.chromium.org/2879002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/menus/simple_menu_model.cc')
-rw-r--r--app/menus/simple_menu_model.cc33
1 files changed, 23 insertions, 10 deletions
diff --git a/app/menus/simple_menu_model.cc b/app/menus/simple_menu_model.cc
index 8631666..3e51986 100644
--- a/app/menus/simple_menu_model.cc
+++ b/app/menus/simple_menu_model.cc
@@ -20,7 +20,7 @@ SimpleMenuModel::~SimpleMenuModel() {
}
void SimpleMenuModel::AddItem(int command_id, const string16& label) {
- Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL, NULL };
AppendItem(item);
}
@@ -30,7 +30,7 @@ void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) {
void SimpleMenuModel::AddSeparator() {
Item item = { kSeparatorId, string16(), SkBitmap(), TYPE_SEPARATOR, -1,
- NULL };
+ NULL, NULL };
AppendItem(item);
}
@@ -45,7 +45,8 @@ void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) {
void SimpleMenuModel::AddRadioItem(int command_id, const string16& label,
int group_id) {
- Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL,
+ NULL };
AppendItem(item);
}
@@ -54,9 +55,15 @@ void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id,
AddRadioItem(command_id, l10n_util::GetStringUTF16(string_id), group_id);
}
+void SimpleMenuModel::AddButtonItem(int command_id,
+ ButtonMenuItemModel* model) {
+ Item item = { 0, string16(), SkBitmap(), TYPE_BUTTON_ITEM, -1, NULL, model };
+ AppendItem(item);
+}
+
void SimpleMenuModel::AddSubMenu(int command_id, const string16& label,
MenuModel* model) {
- Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model };
+ Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model, NULL };
AppendItem(item);
}
@@ -67,7 +74,7 @@ void SimpleMenuModel::AddSubMenuWithStringId(int command_id,
void SimpleMenuModel::InsertItemAt(
int index, int command_id, const string16& label) {
- Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL, NULL };
InsertItemAtIndex(item, index);
}
@@ -78,13 +85,13 @@ void SimpleMenuModel::InsertItemWithStringIdAt(
void SimpleMenuModel::InsertSeparatorAt(int index) {
Item item = { kSeparatorId, string16(), SkBitmap(), TYPE_SEPARATOR, -1,
- NULL };
+ NULL, NULL };
InsertItemAtIndex(item, index);
}
void SimpleMenuModel::InsertCheckItemAt(
int index, int command_id, const string16& label) {
- Item item = { command_id, label, SkBitmap(), TYPE_CHECK, -1, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_CHECK, -1, NULL, NULL };
InsertItemAtIndex(item, index);
}
@@ -96,7 +103,8 @@ void SimpleMenuModel::InsertCheckItemWithStringIdAt(
void SimpleMenuModel::InsertRadioItemAt(
int index, int command_id, const string16& label, int group_id) {
- Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL,
+ NULL };
InsertItemAtIndex(item, index);
}
@@ -108,7 +116,7 @@ void SimpleMenuModel::InsertRadioItemWithStringIdAt(
void SimpleMenuModel::InsertSubMenuAt(
int index, int command_id, const string16& label, MenuModel* model) {
- Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model };
+ Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model, NULL };
InsertItemAtIndex(item, index);
}
@@ -199,9 +207,14 @@ bool SimpleMenuModel::GetIconAt(int index, SkBitmap* icon) const {
return true;
}
+ButtonMenuItemModel* SimpleMenuModel::GetButtonMenuItemAt(int index) const {
+ return items_.at(FlipIndex(index)).button_model;
+}
+
bool SimpleMenuModel::IsEnabledAt(int index) const {
int command_id = GetCommandIdAt(index);
- if (!delegate_ || command_id == kSeparatorId)
+ if (!delegate_ || command_id == kSeparatorId ||
+ items_.at(FlipIndex(index)).button_model)
return true;
return delegate_->IsCommandIdEnabled(command_id);
}