Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: ui/views/controls/combobox/combobox.cc

Issue 141523005: Combobox: Rename styles to STYLE_NORMAL and STYLE_ACTION and modify behaviors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment and test Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/combobox/combobox.cc
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc
index 1f0b9fdbcc8a1b60270806c9594389401440181c..f24478f06d60fef2224ccc0b4122c7a2c59a54fd 100644
--- a/ui/views/controls/combobox/combobox.cc
+++ b/ui/views/controls/combobox/combobox.cc
@@ -278,6 +278,7 @@ void Combobox::SetStyle(Style style) {
style_ = style;
UpdateBorder();
+ UpdateFromModel();
PreferredSizeChanged();
}
@@ -358,6 +359,8 @@ bool Combobox::IsCommandEnabled(int id) const {
void Combobox::ExecuteCommand(int id) {
selected_index_ = MenuCommandToIndex(id);
OnSelectionChanged();
+ if (style_ == STYLE_NOTIFY_ON_CLICK)
+ HandleClickEvent();
}
bool Combobox::GetAccelerator(int id, ui::Accelerator* accel) {
@@ -565,7 +568,6 @@ void Combobox::ButtonPressed(Button* sender, const ui::Event& event) {
}
void Combobox::UpdateFromModel() {
- int max_width = 0;
const gfx::FontList& font_list = Combobox::GetFontList();
MenuItemView* menu = new MenuItemView(this);
@@ -573,6 +575,7 @@ void Combobox::UpdateFromModel() {
dropdown_list_menu_runner_.reset(new MenuRunner(menu));
int num_items = model()->GetItemCount();
+ int width = 0;
for (int i = 0; i < num_items; ++i) {
if (model()->IsItemSeparatorAt(i)) {
menu->AppendSeparator();
@@ -586,10 +589,11 @@ void Combobox::UpdateFromModel() {
base::i18n::AdjustStringForLocaleDirection(&text);
menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL);
- max_width = std::max(max_width, gfx::GetStringWidth(text, font_list));
+ if (style_ != STYLE_NOTIFY_ON_CLICK || i == 0)
sky 2014/01/22 16:04:07 I don't understand this part of the change. Should
sky 2014/01/23 01:11:23 Sorry, one question here. If you do this and the s
hajimehoshi 2014/01/23 02:16:32 For the current usage of Translate bubble, the bub
+ width = std::max(width, gfx::GetStringWidth(text, font_list));
}
- content_size_.SetSize(max_width, font_list.GetHeight());
+ content_size_.SetSize(width, font_list.GetHeight());
}
void Combobox::UpdateBorder() {

Powered by Google App Engine
This is Rietveld 408576698