diff options
Diffstat (limited to 'app')
-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_; |