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

Side by Side Diff: ui/views/bubble/tray_bubble_view.cc

Issue 2092473002: Convert TrayBubbleView to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@traybubblewrapper
Patch Set: review feedback Created 4 years, 6 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
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 arrow(BubbleBorder::NONE), 286 arrow(BubbleBorder::NONE),
287 arrow_offset(kArrowDefaultOffset), 287 arrow_offset(kArrowDefaultOffset),
288 arrow_paint_type(BubbleBorder::PAINT_NORMAL), 288 arrow_paint_type(BubbleBorder::PAINT_NORMAL),
289 shadow(BubbleBorder::BIG_SHADOW), 289 shadow(BubbleBorder::BIG_SHADOW),
290 arrow_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE) { 290 arrow_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE) {
291 } 291 }
292 292
293 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; 293 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default;
294 294
295 // static 295 // static
296 TrayBubbleView* TrayBubbleView::Create(gfx::NativeView parent_window, 296 TrayBubbleView* TrayBubbleView::Create(View* anchor,
297 View* anchor,
298 Delegate* delegate, 297 Delegate* delegate,
299 InitParams* init_params) { 298 InitParams* init_params) {
299 DCHECK(anchor);
300 // Set arrow here so that it can be passed to the BubbleView constructor. 300 // Set arrow here so that it can be passed to the BubbleView constructor.
301 if (init_params->anchor_type == ANCHOR_TYPE_TRAY) { 301 if (init_params->anchor_type == ANCHOR_TYPE_TRAY) {
302 if (init_params->anchor_alignment == ANCHOR_ALIGNMENT_BOTTOM) { 302 if (init_params->anchor_alignment == ANCHOR_ALIGNMENT_BOTTOM) {
303 init_params->arrow = base::i18n::IsRTL() ? 303 init_params->arrow = base::i18n::IsRTL() ?
304 BubbleBorder::BOTTOM_LEFT : BubbleBorder::BOTTOM_RIGHT; 304 BubbleBorder::BOTTOM_LEFT : BubbleBorder::BOTTOM_RIGHT;
305 } else if (init_params->anchor_alignment == ANCHOR_ALIGNMENT_TOP) { 305 } else if (init_params->anchor_alignment == ANCHOR_ALIGNMENT_TOP) {
306 init_params->arrow = BubbleBorder::TOP_LEFT; 306 init_params->arrow = BubbleBorder::TOP_LEFT;
307 } else if (init_params->anchor_alignment == ANCHOR_ALIGNMENT_LEFT) { 307 } else if (init_params->anchor_alignment == ANCHOR_ALIGNMENT_LEFT) {
308 init_params->arrow = BubbleBorder::LEFT_BOTTOM; 308 init_params->arrow = BubbleBorder::LEFT_BOTTOM;
309 } else { 309 } else {
310 init_params->arrow = BubbleBorder::RIGHT_BOTTOM; 310 init_params->arrow = BubbleBorder::RIGHT_BOTTOM;
311 } 311 }
312 } else { 312 } else {
313 init_params->arrow = BubbleBorder::NONE; 313 init_params->arrow = BubbleBorder::NONE;
314 } 314 }
315 315
316 return new TrayBubbleView(parent_window, anchor, delegate, *init_params); 316 return new TrayBubbleView(anchor, delegate, *init_params);
317 } 317 }
318 318
319 TrayBubbleView::TrayBubbleView(gfx::NativeView parent_window, 319 TrayBubbleView::TrayBubbleView(View* anchor,
320 View* anchor,
321 Delegate* delegate, 320 Delegate* delegate,
322 const InitParams& init_params) 321 const InitParams& init_params)
323 : BubbleDialogDelegateView(anchor, init_params.arrow), 322 : BubbleDialogDelegateView(anchor, init_params.arrow),
324 params_(init_params), 323 params_(init_params),
325 delegate_(delegate), 324 delegate_(delegate),
326 preferred_width_(init_params.min_width), 325 preferred_width_(init_params.min_width),
327 bubble_border_(new TrayBubbleBorder(this, GetAnchorView(), init_params)), 326 bubble_border_(new TrayBubbleBorder(this, GetAnchorView(), init_params)),
328 owned_bubble_border_(bubble_border_), 327 owned_bubble_border_(bubble_border_),
329 is_gesture_dragging_(false), 328 is_gesture_dragging_(false),
330 mouse_actively_entered_(false) { 329 mouse_actively_entered_(false) {
331 set_parent_window(parent_window); 330 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
332 set_notify_enter_exit_on_child(true); 331 set_notify_enter_exit_on_child(true);
333 set_close_on_deactivate(init_params.close_on_deactivate); 332 set_close_on_deactivate(init_params.close_on_deactivate);
334 set_margins(gfx::Insets()); 333 set_margins(gfx::Insets());
335 SetPaintToLayer(true); 334 SetPaintToLayer(true);
336 335
337 bubble_content_mask_.reset( 336 bubble_content_mask_.reset(
338 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); 337 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius()));
339 } 338 }
340 339
341 TrayBubbleView::~TrayBubbleView() { 340 TrayBubbleView::~TrayBubbleView() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 401 }
403 402
404 gfx::Rect TrayBubbleView::GetAnchorRect() const { 403 gfx::Rect TrayBubbleView::GetAnchorRect() const {
405 if (!delegate_) 404 if (!delegate_)
406 return gfx::Rect(); 405 return gfx::Rect();
407 return delegate_->GetAnchorRect(anchor_widget(), 406 return delegate_->GetAnchorRect(anchor_widget(),
408 params_.anchor_type, 407 params_.anchor_type,
409 params_.anchor_alignment); 408 params_.anchor_alignment);
410 } 409 }
411 410
411 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params,
412 Widget* bubble_widget) const {
413 if (delegate_)
414 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params);
415 }
416
412 bool TrayBubbleView::CanActivate() const { 417 bool TrayBubbleView::CanActivate() const {
413 return params_.can_activate; 418 return params_.can_activate;
414 } 419 }
415 420
416 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) { 421 NonClientFrameView* TrayBubbleView::CreateNonClientFrameView(Widget* widget) {
417 BubbleFrameView* frame = static_cast<BubbleFrameView*>( 422 BubbleFrameView* frame = static_cast<BubbleFrameView*>(
418 BubbleDialogDelegateView::CreateNonClientFrameView(widget)); 423 BubbleDialogDelegateView::CreateNonClientFrameView(widget));
419 frame->SetBubbleBorder(std::move(owned_bubble_border_)); 424 frame->SetBubbleBorder(std::move(owned_bubble_border_));
420 return frame; 425 return frame;
421 } 426 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 513
509 void TrayBubbleView::ViewHierarchyChanged( 514 void TrayBubbleView::ViewHierarchyChanged(
510 const ViewHierarchyChangedDetails& details) { 515 const ViewHierarchyChangedDetails& details) {
511 if (details.is_add && details.child == this) { 516 if (details.is_add && details.child == this) {
512 details.parent->SetPaintToLayer(true); 517 details.parent->SetPaintToLayer(true);
513 details.parent->layer()->SetMasksToBounds(true); 518 details.parent->layer()->SetMasksToBounds(true);
514 } 519 }
515 } 520 }
516 521
517 } // namespace views 522 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698