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

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

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

Powered by Google App Engine
This is Rietveld 408576698