Chromium Code Reviews| Index: ui/views/controls/combobox/combobox.cc |
| diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc |
| index af0caa6be92b60086508c9893db05a0bed266e65..5cfafacaf1cd7af858f1d0fc7cb6ef116b26e1d5 100644 |
| --- a/ui/views/controls/combobox/combobox.cc |
| +++ b/ui/views/controls/combobox/combobox.cc |
| @@ -54,12 +54,6 @@ const int kMenuBorderWidthRight = 1; |
| // Limit how small a combobox can be. |
| const int kMinComboboxWidth = 25; |
| -// Size of the combobox arrow margins |
| -const int kDisclosureArrowLeftPadding = 7; |
| -const int kDisclosureArrowRightPadding = 7; |
| -const int kDisclosureArrowButtonLeftPadding = 11; |
| -const int kDisclosureArrowButtonRightPadding = 12; |
| - |
| // Define the id of the first item in the menu (since it needs to be > 0) |
| const int kFirstMenuItemId = 1000; |
| @@ -462,9 +456,7 @@ void Combobox::SetInvalid(bool invalid) { |
| } |
| int Combobox::GetArrowButtonWidth() const { |
| - return GetDisclosureArrowLeftPadding() + |
| - ArrowSize().width() + |
| - GetDisclosureArrowRightPadding(); |
| + return PlatformStyle::GetComboboxArrowWidth(style_); |
|
tapted
2016/04/21 06:06:46
Maybe "ShoulderWidth"
Elly Fong-Jones
2016/04/21 15:30:26
Done.
|
| } |
| void Combobox::Layout() { |
| @@ -480,9 +472,7 @@ void Combobox::Layout() { |
| break; |
| } |
| case STYLE_ACTION: { |
| - arrow_button_width = GetDisclosureArrowLeftPadding() + |
| - ArrowSize().width() + |
| - GetDisclosureArrowRightPadding(); |
| + arrow_button_width = GetArrowButtonWidth(); |
| text_button_width = width() - arrow_button_width; |
| break; |
| } |
| @@ -525,8 +515,7 @@ gfx::Size Combobox::GetPreferredSize() const { |
| Textfield::kTextPadding, |
| Textfield::kTextPadding); |
| int total_width = std::max(kMinComboboxWidth, content_size_.width()) + |
| - insets.width() + GetDisclosureArrowLeftPadding() + |
| - ArrowSize().width() + GetDisclosureArrowRightPadding(); |
| + insets.width() + GetArrowButtonWidth(); |
| return gfx::Size(total_width, content_size_.height() + insets.height()); |
| } |
| @@ -733,9 +722,7 @@ void Combobox::PaintText(gfx::Canvas* canvas) { |
| selected_index_ = 0; |
| base::string16 text = model()->GetItemAt(selected_index_); |
| - gfx::Size arrow_size = ArrowSize(); |
| - int disclosure_arrow_offset = width() - arrow_size.width() - |
| - GetDisclosureArrowLeftPadding() - GetDisclosureArrowRightPadding(); |
| + int disclosure_arrow_offset = width() - GetArrowButtonWidth(); |
| const gfx::FontList& font_list = Combobox::GetFontList(); |
| int text_width = gfx::GetStringWidth(text, font_list); |
| @@ -746,15 +733,13 @@ void Combobox::PaintText(gfx::Canvas* canvas) { |
| AdjustBoundsForRTLUI(&text_bounds); |
| canvas->DrawStringRect(text, font_list, text_color, text_bounds); |
| - int arrow_x = disclosure_arrow_offset + GetDisclosureArrowLeftPadding(); |
| - gfx::Rect arrow_bounds(arrow_x, |
| - height() / 2 - arrow_size.height() / 2, |
| - arrow_size.width(), |
| - arrow_size.height()); |
| - AdjustBoundsForRTLUI(&arrow_bounds); |
| - |
| gfx::ImageSkia arrow_image = PlatformStyle::CreateComboboxArrow( |
| enabled(), style_); |
| + gfx::Rect arrow_bounds(disclosure_arrow_offset, 0, GetArrowButtonWidth(), |
| + height()); |
| + arrow_bounds.ClampToCenteredSize(ArrowSize()); |
| + AdjustBoundsForRTLUI(&arrow_bounds); |
| + |
| canvas->DrawImageInt(arrow_image, arrow_bounds.x(), arrow_bounds.y()); |
| } |
| @@ -873,28 +858,6 @@ void Combobox::OnPerformAction() { |
| selected_index_ = 0; |
| } |
| -int Combobox::GetDisclosureArrowLeftPadding() const { |
| - switch (style_) { |
| - case STYLE_NORMAL: |
| - return kDisclosureArrowLeftPadding; |
| - case STYLE_ACTION: |
| - return kDisclosureArrowButtonLeftPadding; |
| - } |
| - NOTREACHED(); |
| - return 0; |
| -} |
| - |
| -int Combobox::GetDisclosureArrowRightPadding() const { |
| - switch (style_) { |
| - case STYLE_NORMAL: |
| - return kDisclosureArrowRightPadding; |
| - case STYLE_ACTION: |
| - return kDisclosureArrowButtonRightPadding; |
| - } |
| - NOTREACHED(); |
| - return 0; |
| -} |
| - |
| gfx::Size Combobox::ArrowSize() const { |
| return PlatformStyle::CreateComboboxArrow(enabled(), style_).size(); |
| } |