Chromium Code Reviews| 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/button/custom_button.h" | 5 #include "ui/views/controls/button/custom_button.h" |
| 6 | 6 |
| 7 #include "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| 11 #include "ui/gfx/animation/throb_animation.h" | 11 #include "ui/gfx/animation/throb_animation.h" |
| 12 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
| 13 #include "ui/views/animation/ink_drop_delegate.h" | |
| 13 #include "ui/views/controls/button/blue_button.h" | 14 #include "ui/views/controls/button/blue_button.h" |
| 14 #include "ui/views/controls/button/checkbox.h" | 15 #include "ui/views/controls/button/checkbox.h" |
| 15 #include "ui/views/controls/button/image_button.h" | 16 #include "ui/views/controls/button/image_button.h" |
| 16 #include "ui/views/controls/button/label_button.h" | 17 #include "ui/views/controls/button/label_button.h" |
| 17 #include "ui/views/controls/button/menu_button.h" | 18 #include "ui/views/controls/button/menu_button.h" |
| 18 #include "ui/views/controls/button/radio_button.h" | 19 #include "ui/views/controls/button/radio_button.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 | 21 |
| 21 #if defined(USE_AURA) | 22 #if defined(USE_AURA) |
| 22 #include "ui/aura/client/capture_client.h" | 23 #include "ui/aura/client/capture_client.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 if (state_ != STATE_DISABLED) | 278 if (state_ != STATE_DISABLED) |
| 278 SetState(STATE_NORMAL); | 279 SetState(STATE_NORMAL); |
| 279 View::ShowContextMenu(p, source_type); | 280 View::ShowContextMenu(p, source_type); |
| 280 } | 281 } |
| 281 | 282 |
| 282 void CustomButton::OnDragDone() { | 283 void CustomButton::OnDragDone() { |
| 283 // Only reset the state to normal if the button isn't currently disabled | 284 // Only reset the state to normal if the button isn't currently disabled |
| 284 // (since disabled buttons may still be able to be dragged). | 285 // (since disabled buttons may still be able to be dragged). |
| 285 if (state_ != STATE_DISABLED) | 286 if (state_ != STATE_DISABLED) |
| 286 SetState(STATE_NORMAL); | 287 SetState(STATE_NORMAL); |
| 288 if (ink_drop_delegate_) | |
| 289 ink_drop_delegate_->OnAction(InkDropState::HIDDEN); | |
| 287 } | 290 } |
| 288 | 291 |
| 289 void CustomButton::GetAccessibleState(ui::AXViewState* state) { | 292 void CustomButton::GetAccessibleState(ui::AXViewState* state) { |
| 290 Button::GetAccessibleState(state); | 293 Button::GetAccessibleState(state); |
| 291 switch (state_) { | 294 switch (state_) { |
| 292 case STATE_HOVERED: | 295 case STATE_HOVERED: |
| 293 state->AddStateFlag(ui::AX_STATE_HOVERED); | 296 state->AddStateFlag(ui::AX_STATE_HOVERED); |
| 294 break; | 297 break; |
| 295 case STATE_PRESSED: | 298 case STATE_PRESSED: |
| 296 state->AddStateFlag(ui::AX_STATE_PRESSED); | 299 state->AddStateFlag(ui::AX_STATE_PRESSED); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 aura::client::GetCaptureClient(root_window); | 367 aura::client::GetCaptureClient(root_window); |
| 365 aura::Window* capture_window = | 368 aura::Window* capture_window = |
| 366 capture_client ? capture_client->GetGlobalCaptureWindow() : nullptr; | 369 capture_client ? capture_client->GetGlobalCaptureWindow() : nullptr; |
| 367 check_mouse_position = !capture_window || capture_window == root_window; | 370 check_mouse_position = !capture_window || capture_window == root_window; |
| 368 } | 371 } |
| 369 #endif | 372 #endif |
| 370 | 373 |
| 371 return check_mouse_position && IsMouseHovered(); | 374 return check_mouse_position && IsMouseHovered(); |
| 372 } | 375 } |
| 373 | 376 |
| 377 void CustomButton::set_ink_drop_delegate(InkDropDelegate* ink_drop_delegate) { | |
| 378 ink_drop_delegate_.reset(ink_drop_delegate); | |
| 379 } | |
| 380 | |
| 374 //////////////////////////////////////////////////////////////////////////////// | 381 //////////////////////////////////////////////////////////////////////////////// |
| 375 // CustomButton, View overrides (protected): | 382 // CustomButton, View overrides (protected): |
| 376 | 383 |
| 384 void CustomButton::OnBoundsChanged(const gfx::Rect& previous_bounds) { | |
| 385 if (ink_drop_delegate_) | |
|
bruthig
2015/11/26 21:27:33
Correct me if I'm wrong but the intent here was to
varkha
2015/11/26 22:12:40
I have restored override of Layout(). Can you see
| |
| 386 ink_drop_delegate_->OnBoundsChanged(); | |
| 387 } | |
| 388 | |
| 377 void CustomButton::ViewHierarchyChanged( | 389 void CustomButton::ViewHierarchyChanged( |
| 378 const ViewHierarchyChangedDetails& details) { | 390 const ViewHierarchyChangedDetails& details) { |
| 379 if (!details.is_add && state_ != STATE_DISABLED) | 391 if (!details.is_add && state_ != STATE_DISABLED) |
| 380 SetState(STATE_NORMAL); | 392 SetState(STATE_NORMAL); |
| 381 } | 393 } |
| 382 | 394 |
| 383 void CustomButton::OnBlur() { | 395 void CustomButton::OnBlur() { |
| 384 if (IsHotTracked()) | 396 if (IsHotTracked()) |
| 385 SetState(STATE_NORMAL); | 397 SetState(STATE_NORMAL); |
| 386 } | 398 } |
| 387 | 399 |
| 388 bool CustomButton::IsChildWidget() const { | 400 bool CustomButton::IsChildWidget() const { |
| 389 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); | 401 return GetWidget() && GetWidget()->GetTopLevelWidget() != GetWidget(); |
| 390 } | 402 } |
| 391 | 403 |
| 392 bool CustomButton::FocusInChildWidget() const { | 404 bool CustomButton::FocusInChildWidget() const { |
| 393 return GetWidget() && | 405 return GetWidget() && |
| 394 GetWidget()->GetRootView()->Contains( | 406 GetWidget()->GetRootView()->Contains( |
| 395 GetFocusManager()->GetFocusedView()); | 407 GetFocusManager()->GetFocusedView()); |
| 396 } | 408 } |
| 397 | 409 |
| 398 } // namespace views | 410 } // namespace views |
| OLD | NEW |