| 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/bubble/tray_bubble_view.h" | 5 #include "ui/views/bubble/tray_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 Delegate* delegate, | 321 Delegate* delegate, |
| 322 const InitParams& init_params) | 322 const InitParams& init_params) |
| 323 : BubbleDialogDelegateView(anchor, init_params.arrow), | 323 : BubbleDialogDelegateView(anchor, init_params.arrow), |
| 324 params_(init_params), | 324 params_(init_params), |
| 325 delegate_(delegate), | 325 delegate_(delegate), |
| 326 preferred_width_(init_params.min_width), | 326 preferred_width_(init_params.min_width), |
| 327 bubble_border_(new TrayBubbleBorder(this, GetAnchorView(), init_params)), | 327 bubble_border_(new TrayBubbleBorder(this, GetAnchorView(), init_params)), |
| 328 owned_bubble_border_(bubble_border_), | 328 owned_bubble_border_(bubble_border_), |
| 329 is_gesture_dragging_(false), | 329 is_gesture_dragging_(false), |
| 330 mouse_actively_entered_(false) { | 330 mouse_actively_entered_(false) { |
| 331 set_can_activate(params_.can_activate); |
| 331 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). | 332 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). |
| 332 set_notify_enter_exit_on_child(true); | 333 set_notify_enter_exit_on_child(true); |
| 333 set_close_on_deactivate(init_params.close_on_deactivate); | 334 set_close_on_deactivate(init_params.close_on_deactivate); |
| 334 set_margins(gfx::Insets()); | 335 set_margins(gfx::Insets()); |
| 335 SetPaintToLayer(true); | 336 SetPaintToLayer(true); |
| 336 | 337 |
| 337 bubble_content_mask_.reset( | 338 bubble_content_mask_.reset( |
| 338 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); | 339 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); |
| 339 } | 340 } |
| 340 | 341 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 params_.anchor_type, | 409 params_.anchor_type, |
| 409 params_.anchor_alignment); | 410 params_.anchor_alignment); |
| 410 } | 411 } |
| 411 | 412 |
| 412 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, | 413 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, |
| 413 Widget* bubble_widget) const { | 414 Widget* bubble_widget) const { |
| 414 if (delegate_) | 415 if (delegate_) |
| 415 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params); | 416 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params); |
| 416 } | 417 } |
| 417 | 418 |
| 418 bool TrayBubbleView::CanActivate() const { | |
| 419 return params_.can_activate; | |
| 420 } | |
| 421 | |
| 422 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { | 419 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { |
| 423 BubbleFrameView* frame = static_cast<BubbleFrameView*>( | 420 BubbleFrameView* frame = static_cast<BubbleFrameView*>( |
| 424 BubbleDialogDelegateView::CreateNonClientFrameView(widget)); | 421 BubbleDialogDelegateView::CreateNonClientFrameView(widget)); |
| 425 frame->SetBubbleBorder(std::move(owned_bubble_border_)); | 422 frame->SetBubbleBorder(std::move(owned_bubble_border_)); |
| 426 return frame; | 423 return frame; |
| 427 } | 424 } |
| 428 | 425 |
| 429 bool TrayBubbleView::WidgetHasHitTestMask() const { | 426 bool TrayBubbleView::WidgetHasHitTestMask() const { |
| 430 return true; | 427 return true; |
| 431 } | 428 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 void TrayBubbleView::OnMouseExited(const ui::MouseEvent& event) { | 483 void TrayBubbleView::OnMouseExited(const ui::MouseEvent& event) { |
| 487 // If there was a mouse watcher waiting for mouse movements we disable it | 484 // If there was a mouse watcher waiting for mouse movements we disable it |
| 488 // immediately since we now leave the bubble. | 485 // immediately since we now leave the bubble. |
| 489 mouse_watcher_.reset(); | 486 mouse_watcher_.reset(); |
| 490 // Do not notify the delegate of an exit if we never told it that we entered. | 487 // Do not notify the delegate of an exit if we never told it that we entered. |
| 491 if (delegate_ && mouse_actively_entered_) | 488 if (delegate_ && mouse_actively_entered_) |
| 492 delegate_->OnMouseExitedView(); | 489 delegate_->OnMouseExitedView(); |
| 493 } | 490 } |
| 494 | 491 |
| 495 void TrayBubbleView::GetAccessibleState(ui::AXViewState* state) { | 492 void TrayBubbleView::GetAccessibleState(ui::AXViewState* state) { |
| 496 if (delegate_ && params_.can_activate) { | 493 if (delegate_ && CanActivate()) { |
| 497 state->role = ui::AX_ROLE_WINDOW; | 494 state->role = ui::AX_ROLE_WINDOW; |
| 498 state->name = delegate_->GetAccessibleNameForBubble(); | 495 state->name = delegate_->GetAccessibleNameForBubble(); |
| 499 } | 496 } |
| 500 } | 497 } |
| 501 | 498 |
| 502 void TrayBubbleView::MouseMovedOutOfHost() { | 499 void TrayBubbleView::MouseMovedOutOfHost() { |
| 503 // The mouse was accidentally over the bubble when it opened and the AutoClose | 500 // The mouse was accidentally over the bubble when it opened and the AutoClose |
| 504 // logic was not activated. Now that the user did move the mouse we tell the | 501 // logic was not activated. Now that the user did move the mouse we tell the |
| 505 // delegate to disable AutoClose. | 502 // delegate to disable AutoClose. |
| 506 delegate_->OnMouseEnteredView(); | 503 delegate_->OnMouseEnteredView(); |
| 507 mouse_actively_entered_ = true; | 504 mouse_actively_entered_ = true; |
| 508 mouse_watcher_->Stop(); | 505 mouse_watcher_->Stop(); |
| 509 } | 506 } |
| 510 | 507 |
| 511 void TrayBubbleView::ChildPreferredSizeChanged(View* child) { | 508 void TrayBubbleView::ChildPreferredSizeChanged(View* child) { |
| 512 SizeToContents(); | 509 SizeToContents(); |
| 513 } | 510 } |
| 514 | 511 |
| 515 void TrayBubbleView::ViewHierarchyChanged( | 512 void TrayBubbleView::ViewHierarchyChanged( |
| 516 const ViewHierarchyChangedDetails& details) { | 513 const ViewHierarchyChangedDetails& details) { |
| 517 if (details.is_add && details.child == this) { | 514 if (details.is_add && details.child == this) { |
| 518 details.parent->SetPaintToLayer(true); | 515 details.parent->SetPaintToLayer(true); |
| 519 details.parent->layer()->SetMasksToBounds(true); | 516 details.parent->layer()->SetMasksToBounds(true); |
| 520 } | 517 } |
| 521 } | 518 } |
| 522 | 519 |
| 523 } // namespace views | 520 } // namespace views |
| OLD | NEW |