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 "ash/wm/maximize_bubble_controller.h" | 5 #include "ash/wm/maximize_bubble_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/wm/window_animations.h" | 9 #include "ash/wm/window_animations.h" |
10 #include "ash/wm/workspace/frame_maximize_button.h" | 10 #include "ash/wm/workspace/frame_maximize_button.h" |
11 #include "base/timer.h" | 11 #include "base/timer.h" |
12 #include "grit/ash_strings.h" | 12 #include "grit/ash_strings.h" |
13 #include "grit/ui_resources.h" | 13 #include "grit/ui_resources.h" |
| 14 #include "third_party/skia/include/core/SkPath.h" |
14 #include "ui/aura/event.h" | 15 #include "ui/aura/event.h" |
15 #include "ui/aura/focus_manager.h" | 16 #include "ui/aura/focus_manager.h" |
16 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
| 18 #include "ui/base/animation/animation.h" |
17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/path.h" |
20 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
21 #include "ui/views/bubble/bubble_delegate.h" | 24 #include "ui/views/bubble/bubble_delegate.h" |
22 #include "ui/views/bubble/bubble_frame_view.h" | 25 #include "ui/views/bubble/bubble_frame_view.h" |
23 #include "ui/views/controls/button/button.h" | 26 #include "ui/views/controls/button/button.h" |
24 #include "ui/views/controls/button/image_button.h" | 27 #include "ui/views/controls/button/image_button.h" |
25 #include "ui/views/controls/label.h" | 28 #include "ui/views/controls/label.h" |
26 #include "ui/views/events/event.h" | 29 #include "ui/views/events/event.h" |
27 #include "ui/views/layout/box_layout.h" | 30 #include "ui/views/layout/box_layout.h" |
28 #include "ui/views/mouse_watcher.h" | 31 #include "ui/views/mouse_watcher.h" |
29 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
30 | 33 |
31 namespace { | 34 namespace { |
32 | 35 |
33 // The spacing between two buttons. | 36 // The spacing between two buttons. |
34 const int kLayoutSpacing = -1; | 37 const int kLayoutSpacing = -1; |
35 | 38 |
36 // The background color. | 39 // The background color. |
37 const SkColor kBubbleBackgroundColor = 0xc8141414; | 40 const SkColor kBubbleBackgroundColor = 0xc8141414; |
38 | 41 |
39 // The text color within the bubble. | 42 // The text color within the bubble. |
40 const SkColor kBubbleTextColor = SK_ColorWHITE; | 43 const SkColor kBubbleTextColor = SK_ColorWHITE; |
41 | 44 |
42 // The line width of the bubble. | 45 // The line width of the bubble. |
43 const int kLineWidth = 1; | 46 const int kLineWidth = 1; |
44 | 47 |
| 48 // The spacing for the top and bottom of the info label. |
| 49 const int kLabelSpacing = 4; |
| 50 |
45 // The pixel dimensions of the arrow. | 51 // The pixel dimensions of the arrow. |
46 const int kArrowHeight = 10; | 52 const int kArrowHeight = 10; |
47 const int kArrowWidth = 20; | 53 const int kArrowWidth = 20; |
48 | 54 |
49 // The delay of the bubble appearance. | 55 // The delay of the bubble appearance. |
50 const int kBubbleAppearanceDelayMS = 200; | 56 const int kBubbleAppearanceDelayMS = 200; |
51 const int kAnimationDurationForPopupMS = 200; | 57 |
| 58 // The animation offset in y for the bubble when appearing. |
| 59 const int kBubbleAnimationOffsetY = 5; |
52 | 60 |
53 class MaximizeBubbleBorder : public views::BubbleBorder { | 61 class MaximizeBubbleBorder : public views::BubbleBorder { |
54 public: | 62 public: |
55 MaximizeBubbleBorder(views::View* content_view, views::View* anchor); | 63 MaximizeBubbleBorder(views::View* content_view, views::View* anchor); |
56 | 64 |
57 virtual ~MaximizeBubbleBorder() {} | 65 virtual ~MaximizeBubbleBorder() {} |
58 | 66 |
| 67 // Get the mouse active area of the window. |
| 68 void GetMask(gfx::Path* mask); |
| 69 |
59 // Overridden from views::BubbleBorder to match the design specs. | 70 // Overridden from views::BubbleBorder to match the design specs. |
60 virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to, | 71 virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to, |
61 const gfx::Size& contents_size) const OVERRIDE; | 72 const gfx::Size& contents_size) const OVERRIDE; |
62 | 73 |
63 // Overridden from views::Border. | 74 // Overridden from views::Border. |
64 virtual void Paint(const views::View& view, | 75 virtual void Paint(const views::View& view, |
65 gfx::Canvas* canvas) const OVERRIDE; | 76 gfx::Canvas* canvas) const OVERRIDE; |
| 77 |
66 private: | 78 private: |
67 views::View* anchor_; | 79 views::View* anchor_; |
68 views::View* content_view_; | 80 views::View* content_view_; |
69 | 81 |
70 DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleBorder); | 82 DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleBorder); |
71 }; | 83 }; |
72 | 84 |
73 MaximizeBubbleBorder::MaximizeBubbleBorder(views::View* content_view, | 85 MaximizeBubbleBorder::MaximizeBubbleBorder(views::View* content_view, |
74 views::View* anchor) | 86 views::View* anchor) |
75 : views::BubbleBorder(views::BubbleBorder::TOP_RIGHT, | 87 : views::BubbleBorder(views::BubbleBorder::TOP_RIGHT, |
76 views::BubbleBorder::NO_SHADOW), | 88 views::BubbleBorder::NO_SHADOW), |
77 anchor_(anchor), | 89 anchor_(anchor), |
78 content_view_(content_view) { | 90 content_view_(content_view) { |
79 set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 91 set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
80 } | 92 } |
81 | 93 |
| 94 void MaximizeBubbleBorder::GetMask(gfx::Path* mask) { |
| 95 gfx::Insets inset; |
| 96 GetInsets(&inset); |
| 97 // Note: Even though the tip could be added as activatable, it is left out |
| 98 // since it would not change the action behavior in any way plus it makes |
| 99 // more sense to keep the focus on the underlying button for clicks. |
| 100 int left = inset.left() - kLineWidth; |
| 101 int right = inset.left() + content_view_->width() + kLineWidth; |
| 102 int top = inset.top() - kLineWidth; |
| 103 int bottom = inset.top() + content_view_->height() + kLineWidth; |
| 104 mask->moveTo(left, top); |
| 105 mask->lineTo(right, top); |
| 106 mask->lineTo(right, bottom); |
| 107 mask->lineTo(left, bottom); |
| 108 mask->lineTo(left, top); |
| 109 mask->close(); |
| 110 } |
| 111 |
82 gfx::Rect MaximizeBubbleBorder::GetBounds( | 112 gfx::Rect MaximizeBubbleBorder::GetBounds( |
83 const gfx::Rect& position_relative_to, | 113 const gfx::Rect& position_relative_to, |
84 const gfx::Size& contents_size) const { | 114 const gfx::Size& contents_size) const { |
85 gfx::Size border_size(contents_size); | 115 gfx::Size border_size(contents_size); |
86 gfx::Insets insets; | 116 gfx::Insets insets; |
87 GetInsets(&insets); | 117 GetInsets(&insets); |
88 border_size.Enlarge(insets.width(), insets.height()); | 118 border_size.Enlarge(insets.width(), insets.height()); |
89 | 119 |
90 // Position the bubble to center the box on the anchor. | 120 // Position the bubble to center the box on the anchor. |
91 int x = (-border_size.width() + anchor_->width()) / 2; | 121 int x = (-border_size.width() + anchor_->width()) / 2; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 public views::MouseWatcherListener { | 214 public views::MouseWatcherListener { |
185 public: | 215 public: |
186 explicit Bubble(MaximizeBubbleController* owner); | 216 explicit Bubble(MaximizeBubbleController* owner); |
187 virtual ~Bubble() {} | 217 virtual ~Bubble() {} |
188 | 218 |
189 // The window of the menu under which the SnapSizer will get created. | 219 // The window of the menu under which the SnapSizer will get created. |
190 aura::Window* GetBubbleWindow(); | 220 aura::Window* GetBubbleWindow(); |
191 | 221 |
192 // Overridden from views::BubbleDelegateView. | 222 // Overridden from views::BubbleDelegateView. |
193 virtual gfx::Rect GetAnchorRect() OVERRIDE; | 223 virtual gfx::Rect GetAnchorRect() OVERRIDE; |
| 224 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 225 |
| 226 // Overridden from views::WidgetDelegateView. |
| 227 virtual bool HasHitTestMask() const OVERRIDE; |
| 228 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE; |
194 | 229 |
195 // Implementation of MouseWatcherListener. | 230 // Implementation of MouseWatcherListener. |
196 virtual void MouseMovedOutOfHost(); | 231 virtual void MouseMovedOutOfHost(); |
197 | 232 |
198 // Implementation of MouseWatcherHost. | 233 // Implementation of MouseWatcherHost. |
199 virtual bool Contains(const gfx::Point& screen_point, | 234 virtual bool Contains(const gfx::Point& screen_point, |
200 views::MouseWatcherHost::MouseEventType type); | 235 views::MouseWatcherHost::MouseEventType type); |
201 | 236 |
202 // Overridden from views::View. | 237 // Overridden from views::View. |
203 virtual gfx::Size GetPreferredSize() OVERRIDE; | 238 virtual gfx::Size GetPreferredSize() OVERRIDE; |
(...skipping 19 matching lines...) Expand all Loading... |
223 | 258 |
224 // Our owning class. | 259 // Our owning class. |
225 MaximizeBubbleController* owner_; | 260 MaximizeBubbleController* owner_; |
226 | 261 |
227 // The widget which contains our menu and the bubble border. | 262 // The widget which contains our menu and the bubble border. |
228 views::Widget* bubble_widget_; | 263 views::Widget* bubble_widget_; |
229 | 264 |
230 // The content accessor of the menu. | 265 // The content accessor of the menu. |
231 BubbleContentsView* contents_view_; | 266 BubbleContentsView* contents_view_; |
232 | 267 |
| 268 // The bubble border. |
| 269 MaximizeBubbleBorder* bubble_border_; |
| 270 |
| 271 // The rectangle before the animation starts. |
| 272 gfx::Rect initial_position_; |
| 273 |
233 // The mouse watcher which takes care of out of window hover events. | 274 // The mouse watcher which takes care of out of window hover events. |
234 scoped_ptr<views::MouseWatcher> mouse_watcher_; | 275 scoped_ptr<views::MouseWatcher> mouse_watcher_; |
235 | 276 |
236 DISALLOW_COPY_AND_ASSIGN(Bubble); | 277 DISALLOW_COPY_AND_ASSIGN(Bubble); |
237 }; | 278 }; |
238 | 279 |
239 // A class that creates all buttons and put them into a view. | 280 // A class that creates all buttons and put them into a view. |
240 class BubbleContentsButtonRow : public views::View, | 281 class BubbleContentsButtonRow : public views::View, |
241 public views::ButtonListener { | 282 public views::ButtonListener { |
242 public: | 283 public: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 350 |
310 DISALLOW_COPY_AND_ASSIGN(BubbleDialogButton); | 351 DISALLOW_COPY_AND_ASSIGN(BubbleDialogButton); |
311 }; | 352 }; |
312 | 353 |
313 MaximizeBubbleController::Bubble::Bubble(MaximizeBubbleController* owner) | 354 MaximizeBubbleController::Bubble::Bubble(MaximizeBubbleController* owner) |
314 : views::BubbleDelegateView(owner->frame_maximize_button(), | 355 : views::BubbleDelegateView(owner->frame_maximize_button(), |
315 views::BubbleBorder::TOP_RIGHT), | 356 views::BubbleBorder::TOP_RIGHT), |
316 shutting_down_(false), | 357 shutting_down_(false), |
317 owner_(owner), | 358 owner_(owner), |
318 bubble_widget_(NULL), | 359 bubble_widget_(NULL), |
319 contents_view_(NULL) { | 360 contents_view_(NULL), |
| 361 bubble_border_(NULL) { |
320 set_margins(gfx::Insets()); | 362 set_margins(gfx::Insets()); |
321 | 363 |
322 // The window needs to be owned by the root so that the SnapSizer does not | 364 // The window needs to be owned by the root so that the SnapSizer does not |
323 // cover it upon animation. | 365 // cover it upon animation. |
324 aura::Window* parent = Shell::GetContainer( | 366 aura::Window* parent = Shell::GetContainer( |
325 Shell::GetActiveRootWindow(), | 367 Shell::GetActiveRootWindow(), |
326 internal::kShellWindowId_LauncherContainer); | 368 internal::kShellWindowId_LauncherContainer); |
327 set_parent_window(parent); | 369 set_parent_window(parent); |
328 | 370 |
329 set_notify_enter_exit_on_child(true); | 371 set_notify_enter_exit_on_child(true); |
(...skipping 11 matching lines...) Expand all Loading... |
341 contents_view_ = new BubbleContentsView(this); | 383 contents_view_ = new BubbleContentsView(this); |
342 AddChildView(contents_view_); | 384 AddChildView(contents_view_); |
343 | 385 |
344 // Note that the returned widget has an observer which points to our | 386 // Note that the returned widget has an observer which points to our |
345 // functions. | 387 // functions. |
346 bubble_widget_ = views::BubbleDelegateView::CreateBubble(this); | 388 bubble_widget_ = views::BubbleDelegateView::CreateBubble(this); |
347 | 389 |
348 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 390 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
349 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); | 391 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); |
350 | 392 |
351 MaximizeBubbleBorder* bubble_border = new MaximizeBubbleBorder( | 393 bubble_border_ = new MaximizeBubbleBorder(this, anchor_view()); |
352 this, | 394 GetBubbleFrameView()->SetBubbleBorder(bubble_border_); |
353 anchor_view()); | |
354 GetBubbleFrameView()->SetBubbleBorder(bubble_border); | |
355 GetBubbleFrameView()->set_background(NULL); | 395 GetBubbleFrameView()->set_background(NULL); |
356 | 396 |
357 // Recalculate size with new border. | 397 // Recalculate size with new border. |
358 SizeToContents(); | 398 SizeToContents(); |
359 | 399 |
360 // Setup animation. | 400 StartFade(true); |
361 ash::SetWindowVisibilityAnimationType( | |
362 bubble_widget_->GetNativeWindow(), | |
363 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | |
364 ash::SetWindowVisibilityAnimationTransition( | |
365 bubble_widget_->GetNativeWindow(), | |
366 ash::ANIMATE_BOTH); | |
367 ash::SetWindowVisibilityAnimationDuration( | |
368 bubble_widget_->GetNativeWindow(), | |
369 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); | |
370 | 401 |
371 Show(); | |
372 // We don't want to lose the focus on our parent window because the button | |
373 // would otherwise lose the highlight when the "helper bubble" is shown. | |
374 views::Widget* widget = | |
375 owner_->frame_maximize_button()->parent()->GetWidget(); | |
376 if (widget) { | |
377 aura::Window* parent_window = widget->GetNativeWindow(); | |
378 parent_window->GetFocusManager()->SetFocusedWindow(parent_window, NULL); | |
379 } | |
380 mouse_watcher_.reset(new views::MouseWatcher( | 402 mouse_watcher_.reset(new views::MouseWatcher( |
381 new BubbleMouseWatcherHost(this), | 403 new BubbleMouseWatcherHost(this), |
382 this)); | 404 this)); |
383 mouse_watcher_->Start(); | 405 mouse_watcher_->Start(); |
384 } | 406 } |
385 | 407 |
386 bool BubbleMouseWatcherHost::Contains( | 408 bool BubbleMouseWatcherHost::Contains( |
387 const gfx::Point& screen_point, | 409 const gfx::Point& screen_point, |
388 views::MouseWatcherHost::MouseEventType type) { | 410 views::MouseWatcherHost::MouseEventType type) { |
389 return bubble_->Contains(screen_point, type); | 411 return bubble_->Contains(screen_point, type); |
390 } | 412 } |
391 | 413 |
392 aura::Window* MaximizeBubbleController::Bubble::GetBubbleWindow() { | 414 aura::Window* MaximizeBubbleController::Bubble::GetBubbleWindow() { |
393 return bubble_widget_ ? bubble_widget_->GetNativeWindow() : NULL; | 415 return bubble_widget_ ? bubble_widget_->GetNativeWindow() : NULL; |
394 } | 416 } |
395 | 417 |
396 gfx::Rect MaximizeBubbleController::Bubble::GetAnchorRect() { | 418 gfx::Rect MaximizeBubbleController::Bubble::GetAnchorRect() { |
397 if (!owner_) | 419 if (!owner_) |
398 return gfx::Rect(); | 420 return gfx::Rect(); |
399 | 421 |
400 gfx::Rect anchor_rect = | 422 gfx::Rect anchor_rect = |
401 owner_->frame_maximize_button()->GetBoundsInScreen(); | 423 owner_->frame_maximize_button()->GetBoundsInScreen(); |
402 return anchor_rect; | 424 return anchor_rect; |
403 } | 425 } |
404 | 426 |
| 427 void MaximizeBubbleController::Bubble::AnimationProgressed( |
| 428 const ui::Animation* animation) { |
| 429 // First do everything needed for the fade by calling the base function. |
| 430 BubbleDelegateView::AnimationProgressed(animation); |
| 431 // When fading in we are done. |
| 432 if (!shutting_down_) |
| 433 return; |
| 434 // Upon fade out an additional shift is required. |
| 435 int shift = animation->CurrentValueBetween(kBubbleAnimationOffsetY, 0); |
| 436 gfx::Rect rect = initial_position_; |
| 437 |
| 438 rect.set_y(rect.y() + shift); |
| 439 bubble_widget_->GetNativeWindow()->SetBounds(rect); |
| 440 } |
| 441 |
| 442 bool MaximizeBubbleController::Bubble::HasHitTestMask() const { |
| 443 return bubble_border_ != NULL; |
| 444 } |
| 445 |
| 446 void MaximizeBubbleController::Bubble::GetHitTestMask(gfx::Path* mask) const { |
| 447 DCHECK(mask); |
| 448 DCHECK(bubble_border_); |
| 449 bubble_border_->GetMask(mask); |
| 450 } |
| 451 |
405 void MaximizeBubbleController::Bubble::MouseMovedOutOfHost() { | 452 void MaximizeBubbleController::Bubble::MouseMovedOutOfHost() { |
406 if (!owner_ || shutting_down_) | 453 if (!owner_ || shutting_down_) |
407 return; | 454 return; |
408 // When we leave the bubble, we might be still be in gesture mode or over | 455 // When we leave the bubble, we might be still be in gesture mode or over |
409 // the maximize button. So only close if none of the other cases apply. | 456 // the maximize button. So only close if none of the other cases apply. |
410 if (!owner_->frame_maximize_button()->is_snap_enabled()) { | 457 if (!owner_->frame_maximize_button()->is_snap_enabled()) { |
411 gfx::Point screen_location = gfx::Screen::GetCursorScreenPoint(); | 458 gfx::Point screen_location = gfx::Screen::GetCursorScreenPoint(); |
412 if (!owner_->frame_maximize_button()->GetBoundsInScreen().Contains( | 459 if (!owner_->frame_maximize_button()->GetBoundsInScreen().Contains( |
413 screen_location)) { | 460 screen_location)) { |
414 owner_->RequestDestructionThroughOwner(); | 461 owner_->RequestDestructionThroughOwner(); |
415 } | 462 } |
416 } | 463 } |
417 } | 464 } |
418 | 465 |
419 bool MaximizeBubbleController::Bubble::Contains( | 466 bool MaximizeBubbleController::Bubble::Contains( |
420 const gfx::Point& screen_point, | 467 const gfx::Point& screen_point, |
421 views::MouseWatcherHost::MouseEventType type) { | 468 views::MouseWatcherHost::MouseEventType type) { |
422 if (!owner_ || shutting_down_) | 469 if (!owner_ || shutting_down_) |
423 return false; | 470 return false; |
| 471 bool inside_button = |
| 472 owner_->frame_maximize_button()->GetBoundsInScreen().Contains( |
| 473 screen_point); |
| 474 if (!owner_->frame_maximize_button()->is_snap_enabled() && inside_button) { |
| 475 SetSnapType(controller()->is_maximized() ? SNAP_RESTORE : SNAP_MAXIMIZE); |
| 476 return true; |
| 477 } |
424 // Check if either a gesture is taking place (=> bubble stays no matter what | 478 // Check if either a gesture is taking place (=> bubble stays no matter what |
425 // the mouse does) or the mouse is over the maximize button or the bubble | 479 // the mouse does) or the mouse is over the maximize button or the bubble |
426 // content. | 480 // content. |
427 return (owner_->frame_maximize_button()->is_snap_enabled() || | 481 return (owner_->frame_maximize_button()->is_snap_enabled() || |
428 owner_->frame_maximize_button()->GetBoundsInScreen().Contains( | 482 inside_button || |
429 screen_point) || | |
430 contents_view_->GetBoundsInScreen().Contains(screen_point)); | 483 contents_view_->GetBoundsInScreen().Contains(screen_point)); |
431 } | 484 } |
432 | 485 |
433 gfx::Size MaximizeBubbleController::Bubble::GetPreferredSize() { | 486 gfx::Size MaximizeBubbleController::Bubble::GetPreferredSize() { |
434 return contents_view_->GetPreferredSize(); | 487 return contents_view_->GetPreferredSize(); |
435 } | 488 } |
436 | 489 |
437 void MaximizeBubbleController::Bubble::OnWidgetClosing(views::Widget* widget) { | 490 void MaximizeBubbleController::Bubble::OnWidgetClosing(views::Widget* widget) { |
438 if (bubble_widget_ != widget) | 491 if (bubble_widget_ != widget) |
439 return; | 492 return; |
(...skipping 12 matching lines...) Expand all Loading... |
452 anchor_widget()->RemoveObserver(this); | 505 anchor_widget()->RemoveObserver(this); |
453 } | 506 } |
454 | 507 |
455 void MaximizeBubbleController::Bubble::ControllerRequestsCloseAndDelete() { | 508 void MaximizeBubbleController::Bubble::ControllerRequestsCloseAndDelete() { |
456 // This only gets called from the owning base class once it is deleted. | 509 // This only gets called from the owning base class once it is deleted. |
457 if (shutting_down_) | 510 if (shutting_down_) |
458 return; | 511 return; |
459 shutting_down_ = true; | 512 shutting_down_ = true; |
460 owner_ = NULL; | 513 owner_ = NULL; |
461 | 514 |
462 // Close the widget asynchronously. | 515 // Close the widget asynchronously after the hide animation is finished. |
463 bubble_widget_->Close(); | 516 initial_position_ = bubble_widget_->GetNativeWindow()->bounds(); |
| 517 StartFade(false); |
464 } | 518 } |
465 | 519 |
466 void MaximizeBubbleController::Bubble::SetSnapType(SnapType snap_type) { | 520 void MaximizeBubbleController::Bubble::SetSnapType(SnapType snap_type) { |
467 if (contents_view_) | 521 if (contents_view_) |
468 contents_view_->SetSnapType(snap_type); | 522 contents_view_->SetSnapType(snap_type); |
469 } | 523 } |
470 | 524 |
471 BubbleContentsButtonRow::BubbleContentsButtonRow( | 525 BubbleContentsButtonRow::BubbleContentsButtonRow( |
472 MaximizeBubbleController::Bubble* bubble) | 526 MaximizeBubbleController::Bubble* bubble) |
473 : bubble_(bubble), | 527 : bubble_(bubble), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 views::Background::CreateSolidBackground(kBubbleBackgroundColor)); | 592 views::Background::CreateSolidBackground(kBubbleBackgroundColor)); |
539 | 593 |
540 buttons_view_ = new BubbleContentsButtonRow(bubble); | 594 buttons_view_ = new BubbleContentsButtonRow(bubble); |
541 AddChildView(buttons_view_); | 595 AddChildView(buttons_view_); |
542 | 596 |
543 label_view_ = new views::Label(); | 597 label_view_ = new views::Label(); |
544 SetSnapType(SNAP_NONE); | 598 SetSnapType(SNAP_NONE); |
545 label_view_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); | 599 label_view_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); |
546 label_view_->SetBackgroundColor(kBubbleBackgroundColor); | 600 label_view_->SetBackgroundColor(kBubbleBackgroundColor); |
547 label_view_->SetEnabledColor(kBubbleTextColor); | 601 label_view_->SetEnabledColor(kBubbleTextColor); |
| 602 label_view_->set_border(views::Border::CreateEmptyBorder( |
| 603 kLabelSpacing, 0, kLabelSpacing, 0)); |
548 AddChildView(label_view_); | 604 AddChildView(label_view_); |
549 } | 605 } |
550 | 606 |
551 // Set the label content to reflect the currently selected |snap_type|. | 607 // Set the label content to reflect the currently selected |snap_type|. |
552 // This function can be executed through the frame maximize button as well as | 608 // This function can be executed through the frame maximize button as well as |
553 // through hover operations. | 609 // through hover operations. |
554 void BubbleContentsView::SetSnapType(SnapType snap_type) { | 610 void BubbleContentsView::SetSnapType(SnapType snap_type) { |
555 if (!bubble_->controller()) | 611 if (!bubble_->controller()) |
556 return; | 612 return; |
557 | 613 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 button_row_->ButtonHovered(this); | 729 button_row_->ButtonHovered(this); |
674 views::ImageButton::OnMouseEntered(event); | 730 views::ImageButton::OnMouseEntered(event); |
675 } | 731 } |
676 | 732 |
677 void BubbleDialogButton::OnMouseExited(const views::MouseEvent& event) { | 733 void BubbleDialogButton::OnMouseExited(const views::MouseEvent& event) { |
678 button_row_->ButtonHovered(NULL); | 734 button_row_->ButtonHovered(NULL); |
679 views::ImageButton::OnMouseExited(event); | 735 views::ImageButton::OnMouseExited(event); |
680 } | 736 } |
681 | 737 |
682 } // namespace ash | 738 } // namespace ash |
OLD | NEW |