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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "ui/views/color_constants.h" | 25 #include "ui/views/color_constants.h" |
26 #include "ui/views/controls/button/custom_button.h" | 26 #include "ui/views/controls/button/custom_button.h" |
27 #include "ui/views/controls/button/label_button.h" | 27 #include "ui/views/controls/button/label_button.h" |
28 #include "ui/views/controls/combobox/combobox_listener.h" | 28 #include "ui/views/controls/combobox/combobox_listener.h" |
29 #include "ui/views/controls/focusable_border.h" | 29 #include "ui/views/controls/focusable_border.h" |
30 #include "ui/views/controls/menu/menu_item_view.h" | 30 #include "ui/views/controls/menu/menu_item_view.h" |
31 #include "ui/views/controls/menu/menu_runner.h" | 31 #include "ui/views/controls/menu/menu_runner.h" |
32 #include "ui/views/controls/menu/menu_runner_handler.h" | 32 #include "ui/views/controls/menu/menu_runner_handler.h" |
33 #include "ui/views/controls/menu/submenu_view.h" | 33 #include "ui/views/controls/menu/submenu_view.h" |
34 #include "ui/views/controls/prefix_selector.h" | 34 #include "ui/views/controls/prefix_selector.h" |
35 #include "ui/views/controls/textfield/textfield.h" | |
35 #include "ui/views/ime/input_method.h" | 36 #include "ui/views/ime/input_method.h" |
36 #include "ui/views/mouse_constants.h" | 37 #include "ui/views/mouse_constants.h" |
37 #include "ui/views/painter.h" | 38 #include "ui/views/painter.h" |
38 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
39 | 40 |
40 namespace views { | 41 namespace views { |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
44 // Menu border widths | 45 // Menu border widths |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 model()->GetItemAt(row); | 404 model()->GetItemAt(row); |
404 } | 405 } |
405 | 406 |
406 //////////////////////////////////////////////////////////////////////////////// | 407 //////////////////////////////////////////////////////////////////////////////// |
407 // Combobox, View overrides: | 408 // Combobox, View overrides: |
408 | 409 |
409 gfx::Size Combobox::GetPreferredSize() const { | 410 gfx::Size Combobox::GetPreferredSize() const { |
410 // The preferred size will drive the local bounds which in turn is used to set | 411 // The preferred size will drive the local bounds which in turn is used to set |
411 // the minimum width for the dropdown list. | 412 // the minimum width for the dropdown list. |
412 gfx::Insets insets = GetInsets(); | 413 gfx::Insets insets = GetInsets(); |
414 insets += gfx::Insets(Textfield::kTextPadding, Textfield::kTextPadding, | |
415 Textfield::kTextPadding, Textfield::kTextPadding); | |
413 int total_width = std::max(kMinComboboxWidth, content_size_.width()) + | 416 int total_width = std::max(kMinComboboxWidth, content_size_.width()) + |
414 insets.width() + GetDisclosureArrowLeftPadding() + | 417 insets.width() + GetDisclosureArrowLeftPadding() + |
415 ArrowSize().width() + GetDisclosureArrowRightPadding(); | 418 ArrowSize().width() + GetDisclosureArrowRightPadding(); |
416 return gfx::Size(total_width, content_size_.height() + insets.height()); | 419 return gfx::Size(total_width, content_size_.height() + insets.height()); |
417 } | 420 } |
418 | 421 |
419 const char* Combobox::GetClassName() const { | 422 const char* Combobox::GetClassName() const { |
420 return kViewClassName; | 423 return kViewClassName; |
421 } | 424 } |
422 | 425 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 if (style_ != STYLE_ACTION || i == selected_index_) | 624 if (style_ != STYLE_ACTION || i == selected_index_) |
622 width = std::max(width, gfx::GetStringWidth(text, font_list)); | 625 width = std::max(width, gfx::GetStringWidth(text, font_list)); |
623 } | 626 } |
624 | 627 |
625 content_size_.SetSize(width, font_list.GetHeight()); | 628 content_size_.SetSize(width, font_list.GetHeight()); |
626 } | 629 } |
627 | 630 |
628 void Combobox::UpdateBorder() { | 631 void Combobox::UpdateBorder() { |
629 scoped_ptr<FocusableBorder> border(new FocusableBorder()); | 632 scoped_ptr<FocusableBorder> border(new FocusableBorder()); |
630 if (style_ == STYLE_ACTION) | 633 if (style_ == STYLE_ACTION) |
631 border->SetInsets(8, 13, 8, 13); | 634 border->SetInsets(5, 10, 5, 10); |
Peter Kasting
2014/08/29 21:09:11
Should we be doing something like "8 - Textfield::
msw
2014/08/30 00:17:48
I don't think the intent is clear, so I figured I
| |
632 if (invalid_) | 635 if (invalid_) |
633 border->SetColor(kWarningColor); | 636 border->SetColor(kWarningColor); |
634 SetBorder(border.PassAs<Border>()); | 637 SetBorder(border.PassAs<Border>()); |
635 } | 638 } |
636 | 639 |
637 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { | 640 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { |
638 rect->set_x(GetMirroredXForRect(*rect)); | 641 rect->set_x(GetMirroredXForRect(*rect)); |
639 } | 642 } |
640 | 643 |
641 void Combobox::PaintText(gfx::Canvas* canvas) { | 644 void Combobox::PaintText(gfx::Canvas* canvas) { |
642 gfx::Insets insets = GetInsets(); | 645 gfx::Insets insets = GetInsets(); |
646 insets += gfx::Insets(0, Textfield::kTextPadding, 0, Textfield::kTextPadding); | |
643 | 647 |
644 gfx::ScopedCanvas scoped_canvas(canvas); | 648 gfx::ScopedCanvas scoped_canvas(canvas); |
645 canvas->ClipRect(GetContentsBounds()); | 649 canvas->ClipRect(GetContentsBounds()); |
646 | 650 |
647 int x = insets.left(); | 651 int x = insets.left(); |
648 int y = insets.top(); | 652 int y = insets.top(); |
649 int text_height = height() - insets.height(); | 653 int text_height = height() - insets.height(); |
650 SkColor text_color = GetNativeTheme()->GetSystemColor( | 654 SkColor text_color = GetNativeTheme()->GetSystemColor( |
651 ui::NativeTheme::kColorId_LabelEnabledColor); | 655 ui::NativeTheme::kColorId_LabelEnabledColor); |
652 | 656 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
853 const ui::NativeTheme* native_theme_for_arrow = GetNativeTheme(); | 857 const ui::NativeTheme* native_theme_for_arrow = GetNativeTheme(); |
854 #endif | 858 #endif |
855 | 859 |
856 ui::NativeTheme::ExtraParams ignored; | 860 ui::NativeTheme::ExtraParams ignored; |
857 return native_theme_for_arrow->GetPartSize(ui::NativeTheme::kComboboxArrow, | 861 return native_theme_for_arrow->GetPartSize(ui::NativeTheme::kComboboxArrow, |
858 ui::NativeTheme::kNormal, | 862 ui::NativeTheme::kNormal, |
859 ignored); | 863 ignored); |
860 } | 864 } |
861 | 865 |
862 } // namespace views | 866 } // namespace views |
OLD | NEW |