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

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

Issue 1690543004: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Make patch smaller temporarily. Created 4 years, 9 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const int kFocusedPressedMenuButtonImages[] = 85 const int kFocusedPressedMenuButtonImages[] =
86 MENU_IMAGE_GRID(IDR_COMBOBOX_BUTTON_F_P); 86 MENU_IMAGE_GRID(IDR_COMBOBOX_BUTTON_F_P);
87 87
88 #undef MENU_IMAGE_GRID 88 #undef MENU_IMAGE_GRID
89 89
90 // The transparent button which holds a button state but is not rendered. 90 // The transparent button which holds a button state but is not rendered.
91 class TransparentButton : public CustomButton { 91 class TransparentButton : public CustomButton {
92 public: 92 public:
93 TransparentButton(ButtonListener* listener) 93 TransparentButton(ButtonListener* listener)
94 : CustomButton(listener) { 94 : CustomButton(listener) {
95 SetFocusBehavior(NEVER);
95 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs); 96 SetAnimationDuration(LabelButton::kHoverAnimationDurationMs);
96 } 97 }
97 ~TransparentButton() override {} 98 ~TransparentButton() override {}
98 99
99 bool OnMousePressed(const ui::MouseEvent& mouse_event) override { 100 bool OnMousePressed(const ui::MouseEvent& mouse_event) override {
100 parent()->RequestFocus(); 101 parent()->RequestFocus();
101 return true; 102 return true;
102 } 103 }
103 104
104 double GetAnimationValue() const { 105 double GetAnimationValue() const {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 : model_(model), 345 : model_(model),
345 style_(STYLE_NORMAL), 346 style_(STYLE_NORMAL),
346 listener_(NULL), 347 listener_(NULL),
347 selected_index_(model_->GetDefaultIndex()), 348 selected_index_(model_->GetDefaultIndex()),
348 invalid_(false), 349 invalid_(false),
349 menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)), 350 menu_model_adapter_(new ComboboxMenuModelAdapter(this, model)),
350 text_button_(new TransparentButton(this)), 351 text_button_(new TransparentButton(this)),
351 arrow_button_(new TransparentButton(this)), 352 arrow_button_(new TransparentButton(this)),
352 weak_ptr_factory_(this) { 353 weak_ptr_factory_(this) {
353 ModelChanged(); 354 ModelChanged();
354 SetFocusable(true); 355 SetFocusBehavior(CONTROL);
355 UpdateBorder(); 356 UpdateBorder();
356 357
357 // Initialize the button images. 358 // Initialize the button images.
358 Button::ButtonState button_states[] = { 359 Button::ButtonState button_states[] = {
359 Button::STATE_DISABLED, 360 Button::STATE_DISABLED,
360 Button::STATE_NORMAL, 361 Button::STATE_NORMAL,
361 Button::STATE_HOVERED, 362 Button::STATE_HOVERED,
362 Button::STATE_PRESSED, 363 Button::STATE_PRESSED,
363 }; 364 };
364 for (int i = 0; i < 2; i++) { 365 for (int i = 0; i < 2; i++) {
365 for (size_t state_index = 0; state_index < arraysize(button_states); 366 for (size_t state_index = 0; state_index < arraysize(button_states);
366 state_index++) { 367 state_index++) {
367 Button::ButtonState state = button_states[state_index]; 368 Button::ButtonState state = button_states[state_index];
368 size_t num; 369 size_t num;
369 bool focused = !!i; 370 bool focused = !!i;
370 const int* ids = GetBodyButtonImageIds(focused, state, &num); 371 const int* ids = GetBodyButtonImageIds(focused, state, &num);
371 body_button_painters_[focused][state].reset( 372 body_button_painters_[focused][state].reset(
372 Painter::CreateImageGridPainter(ids)); 373 Painter::CreateImageGridPainter(ids));
373 menu_button_images_[focused][state] = GetMenuButtonImages(focused, state); 374 menu_button_images_[focused][state] = GetMenuButtonImages(focused, state);
374 } 375 }
375 } 376 }
376 377
377 text_button_->SetVisible(true); 378 text_button_->SetVisible(true);
378 arrow_button_->SetVisible(true); 379 arrow_button_->SetVisible(true);
379 text_button_->SetFocusable(false);
380 arrow_button_->SetFocusable(false);
381 AddChildView(text_button_); 380 AddChildView(text_button_);
382 AddChildView(arrow_button_); 381 AddChildView(arrow_button_);
383 } 382 }
384 383
385 Combobox::~Combobox() { 384 Combobox::~Combobox() {
386 if (GetInputMethod() && selector_.get()) { 385 if (GetInputMethod() && selector_.get()) {
387 // Combobox should have been blurred before destroy. 386 // Combobox should have been blurred before destroy.
388 DCHECK(selector_.get() != GetInputMethod()->GetTextInputClient()); 387 DCHECK(selector_.get() != GetInputMethod()->GetTextInputClient());
389 } 388 }
390 } 389 }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 return gfx::Size(width, font_list.GetHeight()); 926 return gfx::Size(width, font_list.GetHeight());
928 } 927 }
929 928
930 PrefixSelector* Combobox::GetPrefixSelector() { 929 PrefixSelector* Combobox::GetPrefixSelector() {
931 if (!selector_) 930 if (!selector_)
932 selector_.reset(new PrefixSelector(this)); 931 selector_.reset(new PrefixSelector(this));
933 return selector_.get(); 932 return selector_.get();
934 } 933 }
935 934
936 } // namespace views 935 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698