| OLD | NEW |
| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 size_to_largest_label_(style_ == STYLE_NORMAL), | 402 size_to_largest_label_(style_ == STYLE_NORMAL), |
| 403 weak_ptr_factory_(this) { | 403 weak_ptr_factory_(this) { |
| 404 ModelChanged(); | 404 ModelChanged(); |
| 405 #if defined(OS_MACOSX) | 405 #if defined(OS_MACOSX) |
| 406 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 406 SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 407 #else | 407 #else |
| 408 SetFocusBehavior(FocusBehavior::ALWAYS); | 408 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 409 #endif | 409 #endif |
| 410 | 410 |
| 411 UpdateBorder(); | 411 UpdateBorder(); |
| 412 if (UseMd()) { | |
| 413 // set_background() takes ownership but takes a raw pointer. | |
| 414 std::unique_ptr<Background> b = | |
| 415 PlatformStyle::CreateComboboxBackground(GetArrowContainerWidth()); | |
| 416 set_background(b.release()); | |
| 417 } | |
| 418 | 412 |
| 419 // Initialize the button images. | 413 // Initialize the button images. |
| 420 Button::ButtonState button_states[] = { | 414 Button::ButtonState button_states[] = { |
| 421 Button::STATE_DISABLED, | 415 Button::STATE_DISABLED, |
| 422 Button::STATE_NORMAL, | 416 Button::STATE_NORMAL, |
| 423 Button::STATE_HOVERED, | 417 Button::STATE_HOVERED, |
| 424 Button::STATE_PRESSED, | 418 Button::STATE_PRESSED, |
| 425 }; | 419 }; |
| 426 for (int i = 0; i < 2; i++) { | 420 for (int i = 0; i < 2; i++) { |
| 427 for (size_t state_index = 0; state_index < arraysize(button_states); | 421 for (size_t state_index = 0; state_index < arraysize(button_states); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE; | 754 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE; |
| 761 if (event.IsKeyEvent()) | 755 if (event.IsKeyEvent()) |
| 762 source_type = ui::MENU_SOURCE_KEYBOARD; | 756 source_type = ui::MENU_SOURCE_KEYBOARD; |
| 763 else if (event.IsGestureEvent() || event.IsTouchEvent()) | 757 else if (event.IsGestureEvent() || event.IsTouchEvent()) |
| 764 source_type = ui::MENU_SOURCE_TOUCH; | 758 source_type = ui::MENU_SOURCE_TOUCH; |
| 765 ShowDropDownMenu(source_type); | 759 ShowDropDownMenu(source_type); |
| 766 } | 760 } |
| 767 } | 761 } |
| 768 | 762 |
| 769 void Combobox::UpdateBorder() { | 763 void Combobox::UpdateBorder() { |
| 770 std::unique_ptr<FocusableBorder> border( | 764 std::unique_ptr<FocusableBorder> border(new FocusableBorder()); |
| 771 PlatformStyle::CreateComboboxBorder()); | |
| 772 if (style_ == STYLE_ACTION) | 765 if (style_ == STYLE_ACTION) |
| 773 border->SetInsets(5, 10, 5, 10); | 766 border->SetInsets(5, 10, 5, 10); |
| 774 if (invalid_) | 767 if (invalid_) |
| 775 border->SetColor(gfx::kGoogleRed700); | 768 border->SetColor(gfx::kGoogleRed700); |
| 776 SetBorder(std::move(border)); | 769 SetBorder(std::move(border)); |
| 777 } | 770 } |
| 778 | 771 |
| 779 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { | 772 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { |
| 780 rect->set_x(GetMirroredXForRect(*rect)); | 773 rect->set_x(GetMirroredXForRect(*rect)); |
| 781 } | 774 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 const int kMdPaddingWidth = 8; | 990 const int kMdPaddingWidth = 8; |
| 998 int arrow_pad = UseMd() ? kMdPaddingWidth | 991 int arrow_pad = UseMd() ? kMdPaddingWidth |
| 999 : PlatformStyle::kComboboxNormalArrowPadding; | 992 : PlatformStyle::kComboboxNormalArrowPadding; |
| 1000 int padding = style_ == STYLE_NORMAL | 993 int padding = style_ == STYLE_NORMAL |
| 1001 ? arrow_pad * 2 | 994 ? arrow_pad * 2 |
| 1002 : kActionLeftPadding + kActionRightPadding; | 995 : kActionLeftPadding + kActionRightPadding; |
| 1003 return ArrowSize().width() + padding; | 996 return ArrowSize().width() + padding; |
| 1004 } | 997 } |
| 1005 | 998 |
| 1006 } // namespace views | 999 } // namespace views |
| OLD | NEW |