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

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

Issue 516943003: Add textfield internal padding from FocusableBorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore Insets const ref. Created 6 years, 3 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
« no previous file with comments | « ui/app_list/views/search_box_view.cc ('k') | ui/views/controls/focusable_border.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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,
415 Textfield::kTextPadding,
416 Textfield::kTextPadding,
417 Textfield::kTextPadding);
413 int total_width = std::max(kMinComboboxWidth, content_size_.width()) + 418 int total_width = std::max(kMinComboboxWidth, content_size_.width()) +
414 insets.width() + GetDisclosureArrowLeftPadding() + 419 insets.width() + GetDisclosureArrowLeftPadding() +
415 ArrowSize().width() + GetDisclosureArrowRightPadding(); 420 ArrowSize().width() + GetDisclosureArrowRightPadding();
416 return gfx::Size(total_width, content_size_.height() + insets.height()); 421 return gfx::Size(total_width, content_size_.height() + insets.height());
417 } 422 }
418 423
419 const char* Combobox::GetClassName() const { 424 const char* Combobox::GetClassName() const {
420 return kViewClassName; 425 return kViewClassName;
421 } 426 }
422 427
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if (style_ != STYLE_ACTION || i == selected_index_) 626 if (style_ != STYLE_ACTION || i == selected_index_)
622 width = std::max(width, gfx::GetStringWidth(text, font_list)); 627 width = std::max(width, gfx::GetStringWidth(text, font_list));
623 } 628 }
624 629
625 content_size_.SetSize(width, font_list.GetHeight()); 630 content_size_.SetSize(width, font_list.GetHeight());
626 } 631 }
627 632
628 void Combobox::UpdateBorder() { 633 void Combobox::UpdateBorder() {
629 scoped_ptr<FocusableBorder> border(new FocusableBorder()); 634 scoped_ptr<FocusableBorder> border(new FocusableBorder());
630 if (style_ == STYLE_ACTION) 635 if (style_ == STYLE_ACTION)
631 border->SetInsets(8, 13, 8, 13); 636 border->SetInsets(5, 10, 5, 10);
632 if (invalid_) 637 if (invalid_)
633 border->SetColor(kWarningColor); 638 border->SetColor(kWarningColor);
634 SetBorder(border.PassAs<Border>()); 639 SetBorder(border.PassAs<Border>());
635 } 640 }
636 641
637 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { 642 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
638 rect->set_x(GetMirroredXForRect(*rect)); 643 rect->set_x(GetMirroredXForRect(*rect));
639 } 644 }
640 645
641 void Combobox::PaintText(gfx::Canvas* canvas) { 646 void Combobox::PaintText(gfx::Canvas* canvas) {
642 gfx::Insets insets = GetInsets(); 647 gfx::Insets insets = GetInsets();
648 insets += gfx::Insets(0, Textfield::kTextPadding, 0, Textfield::kTextPadding);
643 649
644 gfx::ScopedCanvas scoped_canvas(canvas); 650 gfx::ScopedCanvas scoped_canvas(canvas);
645 canvas->ClipRect(GetContentsBounds()); 651 canvas->ClipRect(GetContentsBounds());
646 652
647 int x = insets.left(); 653 int x = insets.left();
648 int y = insets.top(); 654 int y = insets.top();
649 int text_height = height() - insets.height(); 655 int text_height = height() - insets.height();
650 SkColor text_color = GetNativeTheme()->GetSystemColor( 656 SkColor text_color = GetNativeTheme()->GetSystemColor(
651 ui::NativeTheme::kColorId_LabelEnabledColor); 657 ui::NativeTheme::kColorId_LabelEnabledColor);
652 658
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 const ui::NativeTheme* native_theme_for_arrow = GetNativeTheme(); 859 const ui::NativeTheme* native_theme_for_arrow = GetNativeTheme();
854 #endif 860 #endif
855 861
856 ui::NativeTheme::ExtraParams ignored; 862 ui::NativeTheme::ExtraParams ignored;
857 return native_theme_for_arrow->GetPartSize(ui::NativeTheme::kComboboxArrow, 863 return native_theme_for_arrow->GetPartSize(ui::NativeTheme::kComboboxArrow,
858 ui::NativeTheme::kNormal, 864 ui::NativeTheme::kNormal,
859 ignored); 865 ignored);
860 } 866 }
861 867
862 } // namespace views 868 } // namespace views
OLDNEW
« no previous file with comments | « ui/app_list/views/search_box_view.cc ('k') | ui/views/controls/focusable_border.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698