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

Side by Side Diff: ash/wm/maximize_bubble_controller.cc

Issue 10825327: Adding unit tests for maximize menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 "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"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // The line width of the bubble. 44 // The line width of the bubble.
45 const int kLineWidth = 1; 45 const int kLineWidth = 1;
46 46
47 // The spacing for the top and bottom of the info label. 47 // The spacing for the top and bottom of the info label.
48 const int kLabelSpacing = 4; 48 const int kLabelSpacing = 4;
49 49
50 // The pixel dimensions of the arrow. 50 // The pixel dimensions of the arrow.
51 const int kArrowHeight = 10; 51 const int kArrowHeight = 10;
52 const int kArrowWidth = 20; 52 const int kArrowWidth = 20;
53 53
54 // The delay of the bubble appearance.
55 const int kBubbleAppearanceDelayMS = 200;
56
57 // The animation offset in y for the bubble when appearing. 54 // The animation offset in y for the bubble when appearing.
58 const int kBubbleAnimationOffsetY = 5; 55 const int kBubbleAnimationOffsetY = 5;
59 56
60 class MaximizeBubbleBorder : public views::BubbleBorder { 57 class MaximizeBubbleBorder : public views::BubbleBorder {
61 public: 58 public:
62 MaximizeBubbleBorder(views::View* content_view, views::View* anchor); 59 MaximizeBubbleBorder(views::View* content_view, views::View* anchor);
63 60
64 virtual ~MaximizeBubbleBorder() {} 61 virtual ~MaximizeBubbleBorder() {}
65 62
66 // Get the mouse active area of the window. 63 // Get the mouse active area of the window.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 }; 208 };
212 209
213 // The class which creates and manages the bubble menu element. 210 // The class which creates and manages the bubble menu element.
214 // It creates a 'bubble border' and the content accordingly. 211 // It creates a 'bubble border' and the content accordingly.
215 // Note: Since the SnapSizer will show animations on top of the maximize button 212 // Note: Since the SnapSizer will show animations on top of the maximize button
216 // this menu gets created as a separate window and the SnapSizer will be 213 // this menu gets created as a separate window and the SnapSizer will be
217 // created underneath this window. 214 // created underneath this window.
218 class MaximizeBubbleController::Bubble : public views::BubbleDelegateView, 215 class MaximizeBubbleController::Bubble : public views::BubbleDelegateView,
219 public views::MouseWatcherListener { 216 public views::MouseWatcherListener {
220 public: 217 public:
221 explicit Bubble(MaximizeBubbleController* owner); 218 explicit Bubble(MaximizeBubbleController* owner, int appearance_delay_ms_);
222 virtual ~Bubble() {} 219 virtual ~Bubble() {}
223 220
224 // The window of the menu under which the SnapSizer will get created. 221 // The window of the menu under which the SnapSizer will get created.
225 aura::Window* GetBubbleWindow(); 222 aura::Window* GetBubbleWindow();
226 223
227 // Overridden from views::BubbleDelegateView. 224 // Overridden from views::BubbleDelegateView.
228 virtual gfx::Rect GetAnchorRect() OVERRIDE; 225 virtual gfx::Rect GetAnchorRect() OVERRIDE;
229 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 226 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
230 227
231 // Overridden from views::WidgetDelegateView. 228 // Overridden from views::WidgetDelegateView.
(...skipping 18 matching lines...) Expand all
250 virtual void ControllerRequestsCloseAndDelete(); 247 virtual void ControllerRequestsCloseAndDelete();
251 248
252 // Called from the owning class to change the menu content to the given 249 // Called from the owning class to change the menu content to the given
253 // |snap_type| so that the user knows what is selected. 250 // |snap_type| so that the user knows what is selected.
254 void SetSnapType(SnapType snap_type); 251 void SetSnapType(SnapType snap_type);
255 252
256 // Get the owning MaximizeBubbleController. This might return NULL in case 253 // Get the owning MaximizeBubbleController. This might return NULL in case
257 // of an asynchronous shutdown. 254 // of an asynchronous shutdown.
258 MaximizeBubbleController* controller() const { return owner_; } 255 MaximizeBubbleController* controller() const { return owner_; }
259 256
257 // Added for unit test: Retrieve the button for an action.
258 // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
259 views::CustomButton* GetButtonForUnitTest(SnapType state);
260
260 private: 261 private:
261 // True if the shut down has been initiated. 262 // True if the shut down has been initiated.
262 bool shutting_down_; 263 bool shutting_down_;
263 264
264 // Our owning class. 265 // Our owning class.
265 MaximizeBubbleController* owner_; 266 MaximizeBubbleController* owner_;
266 267
267 // The widget which contains our menu and the bubble border. 268 // The widget which contains our menu and the bubble border.
268 views::Widget* bubble_widget_; 269 views::Widget* bubble_widget_;
269 270
270 // The content accessor of the menu. 271 // The content accessor of the menu.
271 BubbleContentsView* contents_view_; 272 BubbleContentsView* contents_view_;
272 273
273 // The bubble border. 274 // The bubble border.
274 MaximizeBubbleBorder* bubble_border_; 275 MaximizeBubbleBorder* bubble_border_;
275 276
276 // The rectangle before the animation starts. 277 // The rectangle before the animation starts.
277 gfx::Rect initial_position_; 278 gfx::Rect initial_position_;
278 279
279 // The mouse watcher which takes care of out of window hover events. 280 // The mouse watcher which takes care of out of window hover events.
280 scoped_ptr<views::MouseWatcher> mouse_watcher_; 281 scoped_ptr<views::MouseWatcher> mouse_watcher_;
281 282
283 // The fade delay - if 0 it will show / hide immediately.
284 const int appearance_delay_ms_;
285
282 DISALLOW_COPY_AND_ASSIGN(Bubble); 286 DISALLOW_COPY_AND_ASSIGN(Bubble);
283 }; 287 };
284 288
285 // A class that creates all buttons and put them into a view. 289 // A class that creates all buttons and put them into a view.
286 class BubbleContentsButtonRow : public views::View, 290 class BubbleContentsButtonRow : public views::View,
287 public views::ButtonListener { 291 public views::ButtonListener {
288 public: 292 public:
289 explicit BubbleContentsButtonRow(MaximizeBubbleController::Bubble* bubble); 293 explicit BubbleContentsButtonRow(MaximizeBubbleController::Bubble* bubble);
290 294
291 virtual ~BubbleContentsButtonRow() {} 295 virtual ~BubbleContentsButtonRow() {}
292 296
293 // Overridden from ButtonListener. 297 // Overridden from ButtonListener.
294 virtual void ButtonPressed(views::Button* sender, 298 virtual void ButtonPressed(views::Button* sender,
295 const ui::Event& event) OVERRIDE; 299 const ui::Event& event) OVERRIDE;
296 // Called from BubbleDialogButton. 300 // Called from BubbleDialogButton.
297 void ButtonHovered(BubbleDialogButton* sender); 301 void ButtonHovered(BubbleDialogButton* sender);
298 302
303 // Added for unit test: Retrieve the button for an action.
304 // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
305 views::CustomButton* GetButtonForUnitTest(SnapType state);
306
307 MaximizeBubbleController::Bubble* bubble() { return bubble_; }
308
299 private: 309 private:
300 // The owning object which gets notifications. 310 // The owning object which gets notifications.
301 MaximizeBubbleController::Bubble* bubble_; 311 MaximizeBubbleController::Bubble* bubble_;
302 312
303 // The created buttons for our menu. 313 // The created buttons for our menu.
304 BubbleDialogButton* left_button_; 314 BubbleDialogButton* left_button_;
305 BubbleDialogButton* minimize_button_; 315 BubbleDialogButton* minimize_button_;
306 BubbleDialogButton* right_button_; 316 BubbleDialogButton* right_button_;
307 317
308 DISALLOW_COPY_AND_ASSIGN(BubbleContentsButtonRow); 318 DISALLOW_COPY_AND_ASSIGN(BubbleContentsButtonRow);
309 }; 319 };
310 320
311 // A class which creates the content of the bubble: The buttons, and the label. 321 // A class which creates the content of the bubble: The buttons, and the label.
312 class BubbleContentsView : public views::View { 322 class BubbleContentsView : public views::View {
313 public: 323 public:
314 explicit BubbleContentsView(MaximizeBubbleController::Bubble* bubble); 324 explicit BubbleContentsView(MaximizeBubbleController::Bubble* bubble);
315 325
316 virtual ~BubbleContentsView() {} 326 virtual ~BubbleContentsView() {}
317 327
318 // Set the label content to reflect the currently selected |snap_type|. 328 // Set the label content to reflect the currently selected |snap_type|.
319 // This function can be executed through the frame maximize button as well as 329 // This function can be executed through the frame maximize button as well as
320 // through hover operations. 330 // through hover operations.
321 void SetSnapType(SnapType snap_type); 331 void SetSnapType(SnapType snap_type);
322 332
333 // Added for unit test: Retrieve the button for an action.
334 // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
335 views::CustomButton* GetButtonForUnitTest(SnapType state) {
336 return buttons_view_->GetButtonForUnitTest(state);
337 }
338
323 private: 339 private:
324 // The owning class. 340 // The owning class.
325 MaximizeBubbleController::Bubble* bubble_; 341 MaximizeBubbleController::Bubble* bubble_;
326 342
327 // The object which owns all the buttons. 343 // The object which owns all the buttons.
328 BubbleContentsButtonRow* buttons_view_; 344 BubbleContentsButtonRow* buttons_view_;
329 345
330 // The label object which shows the user the selected action. 346 // The label object which shows the user the selected action.
331 views::Label* label_view_; 347 views::Label* label_view_;
332 348
333 DISALLOW_COPY_AND_ASSIGN(BubbleContentsView); 349 DISALLOW_COPY_AND_ASSIGN(BubbleContentsView);
334 }; 350 };
335 351
336 // The image button gets overridden to be able to capture mouse hover events. 352 // The image button gets overridden to be able to capture mouse hover events.
337 // The constructor also assigns all button states and 353 // The constructor also assigns all button states and
338 class BubbleDialogButton : public views::ImageButton { 354 class BubbleDialogButton : public views::ImageButton {
339 public: 355 public:
340 explicit BubbleDialogButton( 356 explicit BubbleDialogButton(
341 BubbleContentsButtonRow* button_row_listener, 357 BubbleContentsButtonRow* button_row_listener,
342 int normal_image, 358 int normal_image,
343 int hovered_image, 359 int hovered_image,
344 int pressed_image); 360 int pressed_image);
345 virtual ~BubbleDialogButton() {} 361 virtual ~BubbleDialogButton() {}
346 362
347 // CustomButton overrides: 363 // CustomButton overrides:
348 virtual void OnMouseCaptureLost() OVERRIDE; 364 virtual void OnMouseCaptureLost() OVERRIDE;
349 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; 365 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
350 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; 366 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
367 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
351 368
352 private: 369 private:
353 // The creating class which needs to get notified in case of a hover event. 370 // The creating class which needs to get notified in case of a hover event.
354 BubbleContentsButtonRow* button_row_; 371 BubbleContentsButtonRow* button_row_;
355 372
356 DISALLOW_COPY_AND_ASSIGN(BubbleDialogButton); 373 DISALLOW_COPY_AND_ASSIGN(BubbleDialogButton);
357 }; 374 };
358 375
359 MaximizeBubbleController::Bubble::Bubble(MaximizeBubbleController* owner) 376 MaximizeBubbleController::Bubble::Bubble(
377 MaximizeBubbleController* owner,
378 int appearance_delay_ms)
360 : views::BubbleDelegateView(owner->frame_maximize_button(), 379 : views::BubbleDelegateView(owner->frame_maximize_button(),
361 views::BubbleBorder::TOP_RIGHT), 380 views::BubbleBorder::TOP_RIGHT),
362 shutting_down_(false), 381 shutting_down_(false),
363 owner_(owner), 382 owner_(owner),
364 bubble_widget_(NULL), 383 bubble_widget_(NULL),
365 contents_view_(NULL), 384 contents_view_(NULL),
366 bubble_border_(NULL) { 385 bubble_border_(NULL),
386 appearance_delay_ms_(appearance_delay_ms) {
367 set_margins(gfx::Insets()); 387 set_margins(gfx::Insets());
368 388
369 // The window needs to be owned by the root so that the SnapSizer does not 389 // The window needs to be owned by the root so that the SnapSizer does not
370 // cover it upon animation. 390 // cover it upon animation.
371 aura::Window* parent = Shell::GetContainer( 391 aura::Window* parent = Shell::GetContainer(
372 Shell::GetActiveRootWindow(), 392 Shell::GetActiveRootWindow(),
373 internal::kShellWindowId_LauncherContainer); 393 internal::kShellWindowId_LauncherContainer);
374 set_parent_window(parent); 394 set_parent_window(parent);
375 395
376 set_notify_enter_exit_on_child(true); 396 set_notify_enter_exit_on_child(true);
(...skipping 18 matching lines...) Expand all
395 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 415 SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
396 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); 416 bubble_widget_->non_client_view()->frame_view()->set_background(NULL);
397 417
398 bubble_border_ = new MaximizeBubbleBorder(this, anchor_view()); 418 bubble_border_ = new MaximizeBubbleBorder(this, anchor_view());
399 GetBubbleFrameView()->SetBubbleBorder(bubble_border_); 419 GetBubbleFrameView()->SetBubbleBorder(bubble_border_);
400 GetBubbleFrameView()->set_background(NULL); 420 GetBubbleFrameView()->set_background(NULL);
401 421
402 // Recalculate size with new border. 422 // Recalculate size with new border.
403 SizeToContents(); 423 SizeToContents();
404 424
405 StartFade(true); 425 if (!appearance_delay_ms_)
426 Show();
427 else
428 StartFade(true);
406 429
407 mouse_watcher_.reset(new views::MouseWatcher( 430 mouse_watcher_.reset(new views::MouseWatcher(
408 new BubbleMouseWatcherHost(this), 431 new BubbleMouseWatcherHost(this),
409 this)); 432 this));
410 mouse_watcher_->Start(); 433 mouse_watcher_->Start();
411 } 434 }
412 435
413 bool BubbleMouseWatcherHost::Contains( 436 bool BubbleMouseWatcherHost::Contains(
414 const gfx::Point& screen_point, 437 const gfx::Point& screen_point,
415 views::MouseWatcherHost::MouseEventType type) { 438 views::MouseWatcherHost::MouseEventType type) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 535
513 void MaximizeBubbleController::Bubble::ControllerRequestsCloseAndDelete() { 536 void MaximizeBubbleController::Bubble::ControllerRequestsCloseAndDelete() {
514 // This only gets called from the owning base class once it is deleted. 537 // This only gets called from the owning base class once it is deleted.
515 if (shutting_down_) 538 if (shutting_down_)
516 return; 539 return;
517 shutting_down_ = true; 540 shutting_down_ = true;
518 owner_ = NULL; 541 owner_ = NULL;
519 542
520 // Close the widget asynchronously after the hide animation is finished. 543 // Close the widget asynchronously after the hide animation is finished.
521 initial_position_ = bubble_widget_->GetNativeWindow()->bounds(); 544 initial_position_ = bubble_widget_->GetNativeWindow()->bounds();
522 StartFade(false); 545 if (!appearance_delay_ms_)
546 bubble_widget_->Close();
547 else
548 StartFade(false);
523 } 549 }
524 550
525 void MaximizeBubbleController::Bubble::SetSnapType(SnapType snap_type) { 551 void MaximizeBubbleController::Bubble::SetSnapType(SnapType snap_type) {
526 if (contents_view_) 552 if (contents_view_)
527 contents_view_->SetSnapType(snap_type); 553 contents_view_->SetSnapType(snap_type);
528 } 554 }
529 555
556 views::CustomButton* MaximizeBubbleController::Bubble::GetButtonForUnitTest(
557 SnapType state) {
558 return contents_view_->GetButtonForUnitTest(state);
559 }
560
530 BubbleContentsButtonRow::BubbleContentsButtonRow( 561 BubbleContentsButtonRow::BubbleContentsButtonRow(
531 MaximizeBubbleController::Bubble* bubble) 562 MaximizeBubbleController::Bubble* bubble)
532 : bubble_(bubble), 563 : bubble_(bubble),
533 left_button_(NULL), 564 left_button_(NULL),
534 minimize_button_(NULL), 565 minimize_button_(NULL),
535 right_button_(NULL) { 566 right_button_(NULL) {
536 SetLayoutManager(new views::BoxLayout( 567 SetLayoutManager(new views::BoxLayout(
537 views::BoxLayout::kHorizontal, 0, 0, kLayoutSpacing)); 568 views::BoxLayout::kHorizontal, 0, 0, kLayoutSpacing));
538 set_background( 569 set_background(
539 views::Background::CreateSolidBackground(kBubbleBackgroundColor)); 570 views::Background::CreateSolidBackground(kBubbleBackgroundColor));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 if (sender == left_button_) 610 if (sender == left_button_)
580 bubble_->controller()->OnButtonHover(SNAP_LEFT); 611 bubble_->controller()->OnButtonHover(SNAP_LEFT);
581 else if (sender == minimize_button_) 612 else if (sender == minimize_button_)
582 bubble_->controller()->OnButtonHover(SNAP_MINIMIZE); 613 bubble_->controller()->OnButtonHover(SNAP_MINIMIZE);
583 else if (sender == right_button_) 614 else if (sender == right_button_)
584 bubble_->controller()->OnButtonHover(SNAP_RIGHT); 615 bubble_->controller()->OnButtonHover(SNAP_RIGHT);
585 else 616 else
586 bubble_->controller()->OnButtonHover(SNAP_NONE); 617 bubble_->controller()->OnButtonHover(SNAP_NONE);
587 } 618 }
588 619
620 views::CustomButton* BubbleContentsButtonRow::GetButtonForUnitTest(
621 SnapType state) {
622 switch (state) {
623 case SNAP_LEFT:
624 return left_button_;
625 case SNAP_MINIMIZE:
626 return minimize_button_;
627 case SNAP_RIGHT:
628 return right_button_;
629 default:
630 NOTREACHED();
631 return NULL;
632 }
633 }
634
589 BubbleContentsView::BubbleContentsView( 635 BubbleContentsView::BubbleContentsView(
590 MaximizeBubbleController::Bubble* bubble) 636 MaximizeBubbleController::Bubble* bubble)
591 : bubble_(bubble), 637 : bubble_(bubble),
592 buttons_view_(NULL), 638 buttons_view_(NULL),
593 label_view_(NULL) { 639 label_view_(NULL) {
594 SetLayoutManager(new views::BoxLayout( 640 SetLayoutManager(new views::BoxLayout(
595 views::BoxLayout::kVertical, 0, 0, kLayoutSpacing)); 641 views::BoxLayout::kVertical, 0, 0, kLayoutSpacing));
596 set_background( 642 set_background(
597 views::Background::CreateSolidBackground(kBubbleBackgroundColor)); 643 views::Background::CreateSolidBackground(kBubbleBackgroundColor));
598 644
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 // If nothing is selected, we automatically select the click operation. 686 // If nothing is selected, we automatically select the click operation.
641 id = bubble_->controller()->is_maximized() ? IDS_ASH_RESTORE_WINDOW : 687 id = bubble_->controller()->is_maximized() ? IDS_ASH_RESTORE_WINDOW :
642 IDS_ASH_MAXIMIZE_WINDOW; 688 IDS_ASH_MAXIMIZE_WINDOW;
643 break; 689 break;
644 } 690 }
645 label_view_->SetText(rb.GetLocalizedString(id)); 691 label_view_->SetText(rb.GetLocalizedString(id));
646 } 692 }
647 693
648 MaximizeBubbleController::MaximizeBubbleController( 694 MaximizeBubbleController::MaximizeBubbleController(
649 FrameMaximizeButton* frame_maximize_button, 695 FrameMaximizeButton* frame_maximize_button,
650 bool is_maximized) 696 bool is_maximized,
697 int appearance_delay_ms)
651 : frame_maximize_button_(frame_maximize_button), 698 : frame_maximize_button_(frame_maximize_button),
652 bubble_(NULL), 699 bubble_(NULL),
653 is_maximized_(is_maximized) { 700 is_maximized_(is_maximized),
701 appearance_delay_ms_(appearance_delay_ms) {
654 // Create the task which will create the bubble delayed. 702 // Create the task which will create the bubble delayed.
655 base::OneShotTimer<MaximizeBubbleController>* new_timer = 703 base::OneShotTimer<MaximizeBubbleController>* new_timer =
656 new base::OneShotTimer<MaximizeBubbleController>(); 704 new base::OneShotTimer<MaximizeBubbleController>();
705 // Note: Even if there was no delay time given, we need to have a timer.
657 new_timer->Start( 706 new_timer->Start(
658 FROM_HERE, 707 FROM_HERE,
659 base::TimeDelta::FromMilliseconds(kBubbleAppearanceDelayMS), 708 base::TimeDelta::FromMilliseconds(
709 appearance_delay_ms_ ? appearance_delay_ms_ : 10),
660 this, 710 this,
661 &MaximizeBubbleController::CreateBubble); 711 &MaximizeBubbleController::CreateBubble);
662 timer_.reset(new_timer); 712 timer_.reset(new_timer);
713 if (!appearance_delay_ms_)
714 CreateBubble();
663 } 715 }
664 716
665 MaximizeBubbleController::~MaximizeBubbleController() { 717 MaximizeBubbleController::~MaximizeBubbleController() {
666 // Note: The destructor only gets initiated through the owner. 718 // Note: The destructor only gets initiated through the owner.
667 timer_.reset(); 719 timer_.reset();
668 if (bubble_) { 720 if (bubble_) {
669 bubble_->ControllerRequestsCloseAndDelete(); 721 bubble_->ControllerRequestsCloseAndDelete();
670 bubble_ = NULL; 722 bubble_ = NULL;
671 } 723 }
672 } 724 }
(...skipping 13 matching lines...) Expand all
686 } 738 }
687 739
688 void MaximizeBubbleController::OnButtonClicked(SnapType snap_type) { 740 void MaximizeBubbleController::OnButtonClicked(SnapType snap_type) {
689 frame_maximize_button_->ExecuteSnapAndCloseMenu(snap_type); 741 frame_maximize_button_->ExecuteSnapAndCloseMenu(snap_type);
690 } 742 }
691 743
692 void MaximizeBubbleController::OnButtonHover(SnapType snap_type) { 744 void MaximizeBubbleController::OnButtonHover(SnapType snap_type) {
693 frame_maximize_button_->SnapButtonHovered(snap_type); 745 frame_maximize_button_->SnapButtonHovered(snap_type);
694 } 746 }
695 747
748 views::CustomButton* MaximizeBubbleController::GetButtonForUnitTest(
749 SnapType state) {
750 return bubble_ ? bubble_->GetButtonForUnitTest(state) : NULL;
751 }
752
696 void MaximizeBubbleController::RequestDestructionThroughOwner() { 753 void MaximizeBubbleController::RequestDestructionThroughOwner() {
697 // Tell the parent to destroy us (if this didn't happen yet). 754 // Tell the parent to destroy us (if this didn't happen yet).
698 if (timer_.get()) { 755 if (timer_.get()) {
699 timer_.reset(NULL); 756 timer_.reset(NULL);
700 // Informs the owner that the menu is gone and requests |this| destruction. 757 // Informs the owner that the menu is gone and requests |this| destruction.
701 frame_maximize_button_->DestroyMaximizeMenu(); 758 frame_maximize_button_->DestroyMaximizeMenu();
702 // Note: After this call |this| is destroyed. 759 // Note: After this call |this| is destroyed.
703 } 760 }
704 } 761 }
705 762
706 void MaximizeBubbleController::CreateBubble() { 763 void MaximizeBubbleController::CreateBubble() {
707 if (!bubble_) 764 if (!bubble_)
708 bubble_ = new Bubble(this); 765 bubble_ = new Bubble(this, appearance_delay_ms_);
709 766
710 timer_->Stop(); 767 timer_->Stop();
711 } 768 }
712 769
713 BubbleDialogButton::BubbleDialogButton( 770 BubbleDialogButton::BubbleDialogButton(
714 BubbleContentsButtonRow* button_row, 771 BubbleContentsButtonRow* button_row,
715 int normal_image, 772 int normal_image,
716 int hovered_image, 773 int hovered_image,
717 int pressed_image) 774 int pressed_image)
718 : views::ImageButton(button_row), 775 : views::ImageButton(button_row),
(...skipping 14 matching lines...) Expand all
733 void BubbleDialogButton::OnMouseEntered(const views::MouseEvent& event) { 790 void BubbleDialogButton::OnMouseEntered(const views::MouseEvent& event) {
734 button_row_->ButtonHovered(this); 791 button_row_->ButtonHovered(this);
735 views::ImageButton::OnMouseEntered(event); 792 views::ImageButton::OnMouseEntered(event);
736 } 793 }
737 794
738 void BubbleDialogButton::OnMouseExited(const views::MouseEvent& event) { 795 void BubbleDialogButton::OnMouseExited(const views::MouseEvent& event) {
739 button_row_->ButtonHovered(NULL); 796 button_row_->ButtonHovered(NULL);
740 views::ImageButton::OnMouseExited(event); 797 views::ImageButton::OnMouseExited(event);
741 } 798 }
742 799
800 bool BubbleDialogButton::OnMouseDragged(const views::MouseEvent& event) {
801 if (!button_row_->bubble()->controller())
802 return false;
803
804 // Remove the phantom window when we leave the button.
805 gfx::Point screen_location = gfx::Screen::GetCursorScreenPoint();
sky 2012/08/13 21:17:14 Use the location passed in the event.
Mr4D (OOO till 08-26) 2012/08/13 23:01:03 Somehow I knew that this would come :). Done. I h
806 if (!GetBoundsInScreen().Contains(screen_location))
807 button_row_->ButtonHovered(NULL);
808
809 // Pass the event on to the normal handler.
810 return views::ImageButton::OnMouseDragged(event);
811 }
812
743 } // namespace ash 813 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698