| 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  | 
|    11 #include "base/logging.h" |    11 #include "base/logging.h" | 
|    12 #include "base/macros.h" |    12 #include "base/macros.h" | 
|    13 #include "build/build_config.h" |    13 #include "build/build_config.h" | 
|    14 #include "ui/accessibility/ax_node_data.h" |    14 #include "ui/accessibility/ax_node_data.h" | 
|    15 #include "ui/base/default_style.h" |    15 #include "ui/base/default_style.h" | 
|    16 #include "ui/base/ime/input_method.h" |    16 #include "ui/base/ime/input_method.h" | 
|    17 #include "ui/base/material_design/material_design_controller.h" |    17 #include "ui/base/material_design/material_design_controller.h" | 
|    18 #include "ui/base/models/combobox_model.h" |  | 
|    19 #include "ui/base/models/combobox_model_observer.h" |    18 #include "ui/base/models/combobox_model_observer.h" | 
|    20 #include "ui/base/resource/resource_bundle.h" |    19 #include "ui/base/resource/resource_bundle.h" | 
|    21 #include "ui/events/event.h" |    20 #include "ui/events/event.h" | 
|    22 #include "ui/gfx/animation/throb_animation.h" |    21 #include "ui/gfx/animation/throb_animation.h" | 
|    23 #include "ui/gfx/canvas.h" |    22 #include "ui/gfx/canvas.h" | 
|    24 #include "ui/gfx/color_palette.h" |    23 #include "ui/gfx/color_palette.h" | 
|    25 #include "ui/gfx/scoped_canvas.h" |    24 #include "ui/gfx/scoped_canvas.h" | 
|    26 #include "ui/gfx/text_utils.h" |    25 #include "ui/gfx/text_utils.h" | 
|    27 #include "ui/native_theme/common_theme.h" |    26 #include "ui/native_theme/common_theme.h" | 
|    28 #include "ui/native_theme/native_theme.h" |    27 #include "ui/native_theme/native_theme.h" | 
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   387  |   386  | 
|   388   Combobox* owner_;           // Weak. Owns this. |   387   Combobox* owner_;           // Weak. Owns this. | 
|   389   ui::ComboboxModel* model_;  // Weak. |   388   ui::ComboboxModel* model_;  // Weak. | 
|   390  |   389  | 
|   391   DISALLOW_COPY_AND_ASSIGN(ComboboxMenuModel); |   390   DISALLOW_COPY_AND_ASSIGN(ComboboxMenuModel); | 
|   392 }; |   391 }; | 
|   393  |   392  | 
|   394 //////////////////////////////////////////////////////////////////////////////// |   393 //////////////////////////////////////////////////////////////////////////////// | 
|   395 // Combobox, public: |   394 // Combobox, public: | 
|   396  |   395  | 
 |   396 Combobox::Combobox(std::unique_ptr<ui::ComboboxModel> model, Style style) | 
 |   397     : Combobox(model.get(), style) { | 
 |   398   owned_model_ = std::move(model); | 
 |   399 } | 
 |   400  | 
|   397 Combobox::Combobox(ui::ComboboxModel* model, Style style) |   401 Combobox::Combobox(ui::ComboboxModel* model, Style style) | 
|   398     : model_(model), |   402     : model_(model), | 
|   399       style_(style), |   403       style_(style), | 
|   400       listener_(nullptr), |   404       listener_(nullptr), | 
|   401       selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), |   405       selected_index_(style == STYLE_ACTION ? 0 : model_->GetDefaultIndex()), | 
|   402       invalid_(false), |   406       invalid_(false), | 
|   403       menu_model_(new ComboboxMenuModel(this, model)), |   407       menu_model_(new ComboboxMenuModel(this, model)), | 
|   404       text_button_(new TransparentButton(this, style_ == STYLE_ACTION)), |   408       text_button_(new TransparentButton(this, style_ == STYLE_ACTION)), | 
|   405       arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)), |   409       arrow_button_(new TransparentButton(this, style_ == STYLE_ACTION)), | 
|   406       size_to_largest_label_(style_ == STYLE_NORMAL), |   410       size_to_largest_label_(style_ == STYLE_NORMAL), | 
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1009   const int kMdPaddingWidth = 8; |  1013   const int kMdPaddingWidth = 8; | 
|  1010   int arrow_pad = UseMd() ? kMdPaddingWidth |  1014   int arrow_pad = UseMd() ? kMdPaddingWidth | 
|  1011                           : PlatformStyle::kComboboxNormalArrowPadding; |  1015                           : PlatformStyle::kComboboxNormalArrowPadding; | 
|  1012   int padding = style_ == STYLE_NORMAL |  1016   int padding = style_ == STYLE_NORMAL | 
|  1013                     ? arrow_pad * 2 |  1017                     ? arrow_pad * 2 | 
|  1014                     : kActionLeftPadding + kActionRightPadding; |  1018                     : kActionLeftPadding + kActionRightPadding; | 
|  1015   return ArrowSize().width() + padding; |  1019   return ArrowSize().width() + padding; | 
|  1016 } |  1020 } | 
|  1017  |  1021  | 
|  1018 }  // namespace views |  1022 }  // namespace views | 
| OLD | NEW |