| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 Button::STATE_HOVERED, | 421 Button::STATE_HOVERED, |
| 422 Button::STATE_PRESSED, | 422 Button::STATE_PRESSED, |
| 423 }; | 423 }; |
| 424 for (int i = 0; i < 2; i++) { | 424 for (int i = 0; i < 2; i++) { |
| 425 for (size_t state_index = 0; state_index < arraysize(button_states); | 425 for (size_t state_index = 0; state_index < arraysize(button_states); |
| 426 state_index++) { | 426 state_index++) { |
| 427 Button::ButtonState state = button_states[state_index]; | 427 Button::ButtonState state = button_states[state_index]; |
| 428 size_t num; | 428 size_t num; |
| 429 bool focused = !!i; | 429 bool focused = !!i; |
| 430 const int* ids = GetBodyButtonImageIds(focused, state, &num); | 430 const int* ids = GetBodyButtonImageIds(focused, state, &num); |
| 431 body_button_painters_[focused][state].reset( | 431 body_button_painters_[focused][state] = |
| 432 Painter::CreateImageGridPainter(ids)); | 432 Painter::CreateImageGridPainter(ids); |
| 433 menu_button_images_[focused][state] = GetMenuButtonImages(focused, state); | 433 menu_button_images_[focused][state] = GetMenuButtonImages(focused, state); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 | 436 |
| 437 text_button_->SetVisible(true); | 437 text_button_->SetVisible(true); |
| 438 arrow_button_->SetVisible(true); | 438 arrow_button_->SetVisible(true); |
| 439 AddChildView(text_button_); | 439 AddChildView(text_button_); |
| 440 AddChildView(arrow_button_); | 440 AddChildView(arrow_button_); |
| 441 | 441 |
| 442 // A layer is applied to make sure that canvas bounds are snapped to pixel | 442 // A layer is applied to make sure that canvas bounds are snapped to pixel |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 void Combobox::OnEnabledChanged() { | 546 void Combobox::OnEnabledChanged() { |
| 547 View::OnEnabledChanged(); | 547 View::OnEnabledChanged(); |
| 548 if (!UseMd()) | 548 if (!UseMd()) |
| 549 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style_); | 549 arrow_image_ = PlatformStyle::CreateComboboxArrow(enabled(), style_); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void Combobox::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 552 void Combobox::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 553 if (!UseMd()) | 553 if (!UseMd()) |
| 554 return; | 554 return; |
| 555 | 555 |
| 556 set_background(Background::CreateBackgroundPainter( | 556 set_background( |
| 557 true, Painter::CreateSolidRoundRectPainter( | 557 Background::CreateBackgroundPainter(Painter::CreateSolidRoundRectPainter( |
| 558 theme->GetSystemColor( | 558 theme->GetSystemColor( |
| 559 ui::NativeTheme::kColorId_TextfieldDefaultBackground), | 559 ui::NativeTheme::kColorId_TextfieldDefaultBackground), |
| 560 FocusableBorder::kCornerRadiusDp))); | 560 FocusableBorder::kCornerRadiusDp))); |
| 561 } | 561 } |
| 562 | 562 |
| 563 int Combobox::GetRowCount() { | 563 int Combobox::GetRowCount() { |
| 564 return model()->GetItemCount(); | 564 return model()->GetItemCount(); |
| 565 } | 565 } |
| 566 | 566 |
| 567 int Combobox::GetSelectedRow() { | 567 int Combobox::GetSelectedRow() { |
| 568 return selected_index_; | 568 return selected_index_; |
| 569 } | 569 } |
| 570 | 570 |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 const int kMdPaddingWidth = 8; | 1009 const int kMdPaddingWidth = 8; |
| 1010 int arrow_pad = UseMd() ? kMdPaddingWidth | 1010 int arrow_pad = UseMd() ? kMdPaddingWidth |
| 1011 : PlatformStyle::kComboboxNormalArrowPadding; | 1011 : PlatformStyle::kComboboxNormalArrowPadding; |
| 1012 int padding = style_ == STYLE_NORMAL | 1012 int padding = style_ == STYLE_NORMAL |
| 1013 ? arrow_pad * 2 | 1013 ? arrow_pad * 2 |
| 1014 : kActionLeftPadding + kActionRightPadding; | 1014 : kActionLeftPadding + kActionRightPadding; |
| 1015 return ArrowSize().width() + padding; | 1015 return ArrowSize().width() + padding; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 } // namespace views | 1018 } // namespace views |
| OLD | NEW |