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

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 2069733002: MD - Use real comboboxes in website settings popup. Hide borders (but (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 Combobox::Combobox(ui::ComboboxModel* model, Style style) 360 Combobox::Combobox(ui::ComboboxModel* model, Style style)
361 : model_(model), 361 : model_(model),
362 style_(style), 362 style_(style),
363 listener_(NULL), 363 listener_(NULL),
364 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), 364 selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()),
365 invalid_(false), 365 invalid_(false),
366 menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)), 366 menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)),
367 text_button_(new TransparentButton(this)), 367 text_button_(new TransparentButton(this)),
368 arrow_button_(new TransparentButton(this)), 368 arrow_button_(new TransparentButton(this)),
369 size_to_largest_label_(style_ == STYLE_NORMAL),
369 weak_ptr_factory_(this) { 370 weak_ptr_factory_(this) {
370 ModelChanged(); 371 ModelChanged();
371 #if defined(OS_MACOSX) 372 #if defined(OS_MACOSX)
372 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); 373 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
373 #else 374 #else
374 SetFocusBehavior(FocusBehavior::ALWAYS); 375 SetFocusBehavior(FocusBehavior::ALWAYS);
375 #endif 376 #endif
376 377
377 UpdateBorder(); 378 UpdateBorder();
378 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style); 379 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 } 872 }
872 873
873 gfx::Size Combobox::GetContentSize() const { 874 gfx::Size Combobox::GetContentSize() const {
874 const gfx::FontList& font_list = GetFontList(); 875 const gfx::FontList& font_list = GetFontList();
875 876
876 int width = 0; 877 int width = 0;
877 for (int i = 0; i < model()->GetItemCount(); ++i) { 878 for (int i = 0; i < model()->GetItemCount(); ++i) {
878 if (model_->IsItemSeparatorAt(i)) 879 if (model_->IsItemSeparatorAt(i))
879 continue; 880 continue;
880 881
881 if (style_ != STYLE_ACTION || i == selected_index_) { 882 if (size_to_largest_label_ || i == selected_index_) {
882 width = std::max( 883 width = std::max(
883 width, 884 width,
884 gfx::GetStringWidth(menu_model_adapter_->GetLabelAt(i), font_list)); 885 gfx::GetStringWidth(menu_model_adapter_->GetLabelAt(i), font_list));
885 } 886 }
886 } 887 }
887 return gfx::Size(width, font_list.GetHeight()); 888 return gfx::Size(width, font_list.GetHeight());
888 } 889 }
889 890
890 PrefixSelector* Combobox::GetPrefixSelector() { 891 PrefixSelector* Combobox::GetPrefixSelector() {
891 if (!selector_) 892 if (!selector_)
892 selector_.reset(new PrefixSelector(this)); 893 selector_.reset(new PrefixSelector(this));
893 return selector_.get(); 894 return selector_.get();
894 } 895 }
895 896
896 int Combobox::GetArrowContainerWidth() const { 897 int Combobox::GetArrowContainerWidth() const {
897 int padding = style_ == STYLE_NORMAL 898 int padding = style_ == STYLE_NORMAL
898 ? PlatformStyle::kComboboxNormalArrowPadding * 2 899 ? PlatformStyle::kComboboxNormalArrowPadding * 2
899 : kActionLeftPadding + kActionRightPadding; 900 : kActionLeftPadding + kActionRightPadding;
900 return ArrowSize().width() + padding; 901 return ArrowSize().width() + padding;
901 } 902 }
902 903
903 } // namespace views 904 } // namespace views
OLDNEW
« ui/views/controls/combobox/combobox.h ('K') | « ui/views/controls/combobox/combobox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698