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 "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 : views::BubbleDelegateView(anchor, init_params.arrow_location), | 268 : views::BubbleDelegateView(anchor, init_params.arrow_location), |
269 params_(init_params), | 269 params_(init_params), |
270 delegate_(delegate), | 270 delegate_(delegate), |
271 preferred_width_(init_params.min_width), | 271 preferred_width_(init_params.min_width), |
272 bubble_border_(NULL), | 272 bubble_border_(NULL), |
273 is_gesture_dragging_(false) { | 273 is_gesture_dragging_(false) { |
274 set_parent_window(parent_window); | 274 set_parent_window(parent_window); |
275 set_notify_enter_exit_on_child(true); | 275 set_notify_enter_exit_on_child(true); |
276 set_close_on_deactivate(init_params.close_on_deactivate); | 276 set_close_on_deactivate(init_params.close_on_deactivate); |
277 set_margins(gfx::Insets()); | 277 set_margins(gfx::Insets()); |
278 SetPaintToLayer(true); | 278 bubble_border_ = new TrayBubbleBorder(this, anchor_view(), params_); |
279 SetFillsBoundsOpaquely(true); | 279 if (get_use_acceleration_when_possible()) { |
| 280 SetPaintToLayer(true); |
| 281 SetFillsBoundsOpaquely(true); |
280 | 282 |
281 bubble_border_ = new TrayBubbleBorder(this, anchor_view(), params_); | 283 bubble_content_mask_.reset( |
282 | 284 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius() - 1)); |
283 bubble_content_mask_.reset( | 285 } |
284 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius() - 1)); | |
285 } | 286 } |
286 | 287 |
287 TrayBubbleView::~TrayBubbleView() { | 288 TrayBubbleView::~TrayBubbleView() { |
288 // Inform host items (models) that their views are being destroyed. | 289 // Inform host items (models) that their views are being destroyed. |
289 if (delegate_) | 290 if (delegate_) |
290 delegate_->BubbleViewDestroyed(); | 291 delegate_->BubbleViewDestroyed(); |
291 } | 292 } |
292 | 293 |
293 void TrayBubbleView::InitializeAndShowBubble() { | 294 void TrayBubbleView::InitializeAndShowBubble() { |
294 // Must occur after call to BubbleDelegateView::CreateBubble(). | 295 // Must occur after call to BubbleDelegateView::CreateBubble(). |
295 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 296 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
296 bubble_border_->UpdateArrowOffset(); | 297 bubble_border_->UpdateArrowOffset(); |
297 | 298 |
298 layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); | 299 if (get_use_acceleration_when_possible()) |
| 300 layer()->parent()->SetMaskLayer(bubble_content_mask_->layer()); |
299 | 301 |
300 Show(); | 302 Show(); |
301 UpdateBubble(); | 303 UpdateBubble(); |
302 } | 304 } |
303 | 305 |
304 void TrayBubbleView::UpdateBubble() { | 306 void TrayBubbleView::UpdateBubble() { |
305 SizeToContents(); | 307 SizeToContents(); |
306 bubble_content_mask_->layer()->SetBounds(layer()->bounds()); | 308 if (get_use_acceleration_when_possible()) |
| 309 bubble_content_mask_->layer()->SetBounds(layer()->bounds()); |
307 GetWidget()->GetRootView()->SchedulePaint(); | 310 GetWidget()->GetRootView()->SchedulePaint(); |
308 } | 311 } |
309 | 312 |
310 void TrayBubbleView::SetMaxHeight(int height) { | 313 void TrayBubbleView::SetMaxHeight(int height) { |
311 params_.max_height = height; | 314 params_.max_height = height; |
312 if (GetWidget()) | 315 if (GetWidget()) |
313 SizeToContents(); | 316 SizeToContents(); |
314 } | 317 } |
315 | 318 |
316 void TrayBubbleView::SetWidth(int width) { | 319 void TrayBubbleView::SetWidth(int width) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 399 } |
397 } | 400 } |
398 | 401 |
399 void TrayBubbleView::ChildPreferredSizeChanged(View* child) { | 402 void TrayBubbleView::ChildPreferredSizeChanged(View* child) { |
400 SizeToContents(); | 403 SizeToContents(); |
401 } | 404 } |
402 | 405 |
403 void TrayBubbleView::ViewHierarchyChanged(bool is_add, | 406 void TrayBubbleView::ViewHierarchyChanged(bool is_add, |
404 views::View* parent, | 407 views::View* parent, |
405 views::View* child) { | 408 views::View* child) { |
406 if (is_add && child == this) { | 409 if (get_use_acceleration_when_possible() && is_add && child == this) { |
407 parent->SetPaintToLayer(true); | 410 parent->SetPaintToLayer(true); |
408 parent->SetFillsBoundsOpaquely(true); | 411 parent->SetFillsBoundsOpaquely(true); |
409 parent->layer()->SetMasksToBounds(true); | 412 parent->layer()->SetMasksToBounds(true); |
410 } | 413 } |
411 } | 414 } |
412 | 415 |
413 } // namespace views | 416 } // namespace views |
OLD | NEW |