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/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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 using internal::TrayBubbleContentMask; | 166 using internal::TrayBubbleContentMask; |
| 167 using internal::BottomAlignedBoxLayout; | 167 using internal::BottomAlignedBoxLayout; |
| 168 | 168 |
| 169 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, | 169 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, |
| 170 int min_width, | 170 int min_width, |
| 171 int max_width) | 171 int max_width) |
| 172 : anchor_alignment(anchor_alignment), | 172 : anchor_alignment(anchor_alignment), |
| 173 min_width(min_width), | 173 min_width(min_width), |
| 174 max_width(max_width), | 174 max_width(max_width), |
| 175 max_height(0), | 175 max_height(0), |
| 176 can_activate(false), | |
| 177 close_on_deactivate(true), | 176 close_on_deactivate(true), |
| 178 bg_color(gfx::kPlaceholderColor) {} | 177 bg_color(gfx::kPlaceholderColor) {} |
| 179 | 178 |
| 180 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; | 179 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; |
| 181 | 180 |
| 182 // static | 181 // static |
| 183 TrayBubbleView* TrayBubbleView::Create(View* anchor, | 182 TrayBubbleView* TrayBubbleView::Create(View* anchor, |
| 184 Delegate* delegate, | 183 Delegate* delegate, |
| 185 InitParams* init_params) { | 184 InitParams* init_params) { |
| 186 return new TrayBubbleView(anchor, delegate, *init_params); | 185 return new TrayBubbleView(anchor, delegate, *init_params); |
| 187 } | 186 } |
| 188 | 187 |
| 189 TrayBubbleView::TrayBubbleView(View* anchor, | 188 TrayBubbleView::TrayBubbleView(View* anchor, |
| 190 Delegate* delegate, | 189 Delegate* delegate, |
| 191 const InitParams& init_params) | 190 const InitParams& init_params) |
| 192 : BubbleDialogDelegateView(anchor, | 191 : BubbleDialogDelegateView(anchor, |
| 193 GetArrowAlignment(init_params.anchor_alignment)), | 192 GetArrowAlignment(init_params.anchor_alignment)), |
| 194 params_(init_params), | 193 params_(init_params), |
| 195 layout_(new BottomAlignedBoxLayout(this)), | 194 layout_(new BottomAlignedBoxLayout(this)), |
| 196 delegate_(delegate), | 195 delegate_(delegate), |
| 197 preferred_width_(init_params.min_width), | 196 preferred_width_(init_params.min_width), |
| 198 bubble_border_(new BubbleBorder(arrow(), | 197 bubble_border_(new BubbleBorder(arrow(), |
| 199 BubbleBorder::BIG_SHADOW, | 198 BubbleBorder::NO_ASSETS, |
| 200 init_params.bg_color)), | 199 init_params.bg_color)), |
| 201 owned_bubble_border_(bubble_border_), | 200 owned_bubble_border_(bubble_border_), |
| 202 is_gesture_dragging_(false), | 201 is_gesture_dragging_(false), |
| 203 mouse_actively_entered_(false) { | 202 mouse_actively_entered_(false) { |
| 204 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 203 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 205 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); | 204 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); |
| 206 set_can_activate(params_.can_activate); | 205 set_can_activate(true); |
|
msw
2016/12/08 22:09:46
nit: this is true by default; remove the explicit
| |
| 207 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). | 206 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). |
| 208 set_notify_enter_exit_on_child(true); | 207 set_notify_enter_exit_on_child(true); |
| 209 set_close_on_deactivate(init_params.close_on_deactivate); | 208 set_close_on_deactivate(init_params.close_on_deactivate); |
| 210 set_margins(gfx::Insets()); | 209 set_margins(gfx::Insets()); |
| 211 SetPaintToLayer(true); | 210 SetPaintToLayer(true); |
| 212 | 211 |
| 213 bubble_content_mask_.reset( | 212 bubble_content_mask_.reset( |
| 214 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); | 213 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); |
| 215 | 214 |
| 216 layout_->SetDefaultFlex(1); | 215 layout_->SetDefaultFlex(1); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 265 } | 264 } |
| 266 | 265 |
| 267 int TrayBubbleView::GetDialogButtons() const { | 266 int TrayBubbleView::GetDialogButtons() const { |
| 268 return ui::DIALOG_BUTTON_NONE; | 267 return ui::DIALOG_BUTTON_NONE; |
| 269 } | 268 } |
| 270 | 269 |
| 271 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, | 270 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, |
| 272 Widget* bubble_widget) const { | 271 Widget* bubble_widget) const { |
| 273 if (delegate_) | 272 if (delegate_) |
| 274 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params); | 273 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params); |
| 274 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP; | |
| 275 } | 275 } |
| 276 | 276 |
| 277 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { | 277 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { |
| 278 BubbleFrameView* frame = static_cast<BubbleFrameView*>( | 278 BubbleFrameView* frame = static_cast<BubbleFrameView*>( |
| 279 BubbleDialogDelegateView::CreateNonClientFrameView(widget)); | 279 BubbleDialogDelegateView::CreateNonClientFrameView(widget)); |
| 280 frame->SetBubbleBorder(std::move(owned_bubble_border_)); | 280 frame->SetBubbleBorder(std::move(owned_bubble_border_)); |
| 281 return frame; | 281 return frame; |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool TrayBubbleView::WidgetHasHitTestMask() const { | 284 bool TrayBubbleView::WidgetHasHitTestMask() const { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 | 373 |
| 374 void TrayBubbleView::ViewHierarchyChanged( | 374 void TrayBubbleView::ViewHierarchyChanged( |
| 375 const ViewHierarchyChangedDetails& details) { | 375 const ViewHierarchyChangedDetails& details) { |
| 376 if (details.is_add && details.child == this) { | 376 if (details.is_add && details.child == this) { |
| 377 details.parent->SetPaintToLayer(true); | 377 details.parent->SetPaintToLayer(true); |
| 378 details.parent->layer()->SetMasksToBounds(true); | 378 details.parent->layer()->SetMasksToBounds(true); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace views | 382 } // namespace views |
| OLD | NEW |