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

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

Issue 2391393002: Harmony - Use FocusableBorder for comboboxes on Mac (Closed)
Patch Set: more Created 4 years, 2 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/views/BUILD.gn ('k') | ui/views/style/mac/combobox_background_mac.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 <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
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 void Combobox::OnEnabledChanged() { 537 void Combobox::OnEnabledChanged() {
544 View::OnEnabledChanged(); 538 View::OnEnabledChanged();
545 if (!UseMd()) 539 if (!UseMd())
546 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style_); 540 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style_);
547 } 541 }
548 542
549 void Combobox::OnNativeThemeChanged(const ui::NativeTheme* theme) { 543 void Combobox::OnNativeThemeChanged(const ui::NativeTheme* theme) {
550 if (!UseMd()) 544 if (!UseMd())
551 return; 545 return;
552 546
553 set_background(Background::CreateBackgroundPainter( 547 set_background(Background::CreateBackgroundPainter(
Evan Stade 2016/10/06 15:56:37 ah, look --- the bg was being overridden anyway
554 true, Painter::CreateSolidRoundRectPainter( 548 true, Painter::CreateSolidRoundRectPainter(
555 theme->GetSystemColor( 549 theme->GetSystemColor(
556 ui::NativeTheme::kColorId_TextfieldDefaultBackground), 550 ui::NativeTheme::kColorId_TextfieldDefaultBackground),
557 FocusableBorder::kCornerRadiusDp))); 551 FocusableBorder::kCornerRadiusDp)));
558 } 552 }
559 553
560 int Combobox::GetRowCount() { 554 int Combobox::GetRowCount() {
561 return model()->GetItemCount(); 555 return model()->GetItemCount();
562 } 556 }
563 557
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 =
771 PlatformStyle::CreateComboboxBorder()); 765 PlatformStyle::CreateComboboxBorder();
766 if (UseMd())
767 border.reset(new FocusableBorder());
772 if (style_ == STYLE_ACTION) 768 if (style_ == STYLE_ACTION)
773 border->SetInsets(5, 10, 5, 10); 769 border->SetInsets(5, 10, 5, 10);
774 if (invalid_) 770 if (invalid_)
775 border->SetColor(gfx::kGoogleRed700); 771 border->SetColor(gfx::kGoogleRed700);
776 SetBorder(std::move(border)); 772 SetBorder(std::move(border));
777 } 773 }
778 774
779 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { 775 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
780 rect->set_x(GetMirroredXForRect(*rect)); 776 rect->set_x(GetMirroredXForRect(*rect));
781 } 777 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 const int kMdPaddingWidth = 8; 993 const int kMdPaddingWidth = 8;
998 int arrow_pad = UseMd() ? kMdPaddingWidth 994 int arrow_pad = UseMd() ? kMdPaddingWidth
999 : PlatformStyle::kComboboxNormalArrowPadding; 995 : PlatformStyle::kComboboxNormalArrowPadding;
1000 int padding = style_ == STYLE_NORMAL 996 int padding = style_ == STYLE_NORMAL
1001 ? arrow_pad * 2 997 ? arrow_pad * 2
1002 : kActionLeftPadding + kActionRightPadding; 998 : kActionLeftPadding + kActionRightPadding;
1003 return ArrowSize().width() + padding; 999 return ArrowSize().width() + padding;
1004 } 1000 }
1005 1001
1006 } // namespace views 1002 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/BUILD.gn ('k') | ui/views/style/mac/combobox_background_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698