diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-09 17:16:01 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-09 17:16:01 +0000 |
commit | 65d903b23a639abd18cda24c50889be087fe909a (patch) | |
tree | efb2f9462f8fe59551919a9705b7916929890821 /app/menus | |
parent | d73e8619de330e8fb1fef6fb89f1d38c7a25b511 (diff) | |
download | chromium_src-65d903b23a639abd18cda24c50889be087fe909a.zip chromium_src-65d903b23a639abd18cda24c50889be087fe909a.tar.gz chromium_src-65d903b23a639abd18cda24c50889be087fe909a.tar.bz2 |
GTK: Grouped buttons should be equal sizes in new wrench menu.
This completes the linux implementation of the new wrench menu. Turning
on by default. Will watch how this goes.
BUG=45757
TEST=Look at the menu. The size of the "cut," "copy" and "paste" buttons
should be equal.
Review URL: http://codereview.chromium.org/2961001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/menus')
-rw-r--r-- | app/menus/button_menu_item_model.cc | 26 | ||||
-rw-r--r-- | app/menus/button_menu_item_model.h | 21 |
2 files changed, 15 insertions, 32 deletions
diff --git a/app/menus/button_menu_item_model.cc b/app/menus/button_menu_item_model.cc index fd19fc8..19cbdab3 100644 --- a/app/menus/button_menu_item_model.cc +++ b/app/menus/button_menu_item_model.cc @@ -15,33 +15,27 @@ ButtonMenuItemModel::ButtonMenuItemModel( delegate_(delegate) { } -void ButtonMenuItemModel::AddItemWithStringId(int command_id, int string_id) { +void ButtonMenuItemModel::AddGroupItemWithStringId( + int command_id, int string_id) { Item item = { command_id, TYPE_BUTTON, l10n_util::GetStringUTF16(string_id), - -1, -1}; - items_.push_back(item); -} - -void ButtonMenuItemModel::AddItemWithStringIdAndGroup( - int command_id, int string_id, int group) { - Item item = { command_id, TYPE_BUTTON, l10n_util::GetStringUTF16(string_id), - -1, group }; + -1, true }; items_.push_back(item); } void ButtonMenuItemModel::AddItemWithImage(int command_id, int icon_idr) { - Item item = { command_id, TYPE_BUTTON, string16(), icon_idr, -1 }; + Item item = { command_id, TYPE_BUTTON, string16(), icon_idr, false }; items_.push_back(item); } void ButtonMenuItemModel::AddButtonLabel(int command_id, int string_id) { Item item = { command_id, TYPE_BUTTON_LABEL, - l10n_util::GetStringUTF16(string_id), -1, -1 }; + l10n_util::GetStringUTF16(string_id), -1, false }; items_.push_back(item); } void ButtonMenuItemModel::AddSpace() { - Item item = { 0, TYPE_SPACE, string16(), -1, -1 }; + Item item = { 0, TYPE_SPACE, string16(), -1, false }; items_.push_back(item); } @@ -78,12 +72,8 @@ bool ButtonMenuItemModel::GetIconAt(int index, int* icon_idr) const { return true; } -bool ButtonMenuItemModel::GetGroupAt(int index, int* group) const { - if (items_[index].group == -1) - return false; - - *group = items_[index].group; - return true; +bool ButtonMenuItemModel::PartOfGroup(int index) const { + return items_[index].part_of_group; } void ButtonMenuItemModel::ActivatedCommand(int command_id) { diff --git a/app/menus/button_menu_item_model.h b/app/menus/button_menu_item_model.h index 46ad8a6..640642a 100644 --- a/app/menus/button_menu_item_model.h +++ b/app/menus/button_menu_item_model.h @@ -14,10 +14,6 @@ namespace menus { // A model representing the rows of buttons that should be inserted in a button // containing menu item. -// -// TODO(erg): There are still two major pieces missing from this model. It -// needs to be able to group buttons together so they all have the same -// width. class ButtonMenuItemModel { public: // Types of buttons. @@ -43,12 +39,9 @@ class ButtonMenuItemModel { ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate); - // Adds a button that will emit |command_id|. - void AddItemWithStringId(int command_id, int string_id); - - // Adds a button that will emit |command_id|. Sizes for all items with the - // same |group| id will be set to the largest item in the group. - void AddItemWithStringIdAndGroup(int command_id, int string_id, int group); + // Adds a button that will emit |command_id|. All buttons created through + // this method will have the same size, based on the largest button. + void AddGroupItemWithStringId(int command_id, int string_id); // Adds a button that has an icon instead of a label. void AddItemWithImage(int command_id, int icon_idr); @@ -80,9 +73,9 @@ class ButtonMenuItemModel { // sets the IDR |icon|. bool GetIconAt(int index, int* icon) const; - // If the button at |index| should have its size equalized as part of a - // group, returns true and sets the group number |group|. - bool GetGroupAt(int index, int* group) const; + // If the button at |index| should have its size equalized along with all + // other items that have their PartOfGroup bit set. + bool PartOfGroup(int index) const; // Called from implementations. void ActivatedCommand(int command_id); @@ -98,7 +91,7 @@ class ButtonMenuItemModel { ButtonType type; string16 label; int icon_idr; - int group; + bool part_of_group; }; std::vector<Item> items_; |