1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_
6 #define ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_
8 #include "ash/wm/workspace/snap_types.h"
9 #include "ui/views/bubble/bubble_delegate.h"
10 #include "ui/views/mouse_watcher.h"
18 class BubbleContentsView;
19 class MaximizeBubbleBorder;
20 class MaximizeBubbleController;
22 // The class which creates and manages the bubble menu element.
23 // It creates a 'bubble border' and the content accordingly.
24 // Note: Since the phantom window will show animations on top of the maximize
25 // button this menu gets created as a separate window and the phantom window
26 // will be created underneath this window.
27 class MaximizeBubbleControllerBubble : public views::BubbleDelegateView,
28 public views::MouseWatcherListener {
30 static const SkColor kBubbleBackgroundColor;
31 static const int kLayoutSpacing; // The spacing between two buttons.
33 MaximizeBubbleControllerBubble(MaximizeBubbleController* owner,
34 int appearance_delay_ms,
35 SnapType initial_snap_type);
36 virtual ~MaximizeBubbleControllerBubble();
38 // The window of the menu under which the phantom window will get created.
39 aura::Window* GetBubbleWindow();
41 // Overridden from views::BubbleDelegateView.
42 virtual gfx::Rect GetAnchorRect() OVERRIDE;
43 virtual bool CanActivate() const OVERRIDE;
45 // Overridden from views::WidgetDelegateView.
46 virtual bool WidgetHasHitTestMask() const OVERRIDE;
47 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
49 // Implementation of MouseWatcherListener.
50 virtual void MouseMovedOutOfHost() OVERRIDE;
52 // Implementation of MouseWatcherHost.
53 virtual bool Contains(const gfx::Point& screen_point,
54 views::MouseWatcherHost::MouseEventType type);
56 // Overridden from views::View.
57 virtual gfx::Size GetPreferredSize() OVERRIDE;
59 // Overridden from views::Widget::Observer.
60 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
62 // Called from the controller class to indicate that the menu should get
64 virtual void ControllerRequestsCloseAndDelete();
66 // Called from the owning class to change the menu content to the given
67 // |snap_type| so that the user knows what is selected.
68 void SetSnapType(SnapType snap_type);
70 // Get the owning MaximizeBubbleController. This might return NULL in case
71 // of an asynchronous shutdown.
72 MaximizeBubbleController* controller() const { return owner_; }
74 // Added for unit test: Retrieve the button for an action.
75 // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
76 views::CustomButton* GetButtonForUnitTest(SnapType state);
79 // True if the shut down has been initiated.
83 MaximizeBubbleController* owner_;
85 // The content accessor of the menu.
86 BubbleContentsView* contents_view_;
88 // The bubble border (weak reference).
89 MaximizeBubbleBorder* bubble_border_;
91 // The mouse watcher which takes care of out of window hover events.
92 scoped_ptr<views::MouseWatcher> mouse_watcher_;
94 // The fade delay - if 0 it will show / hide immediately.
95 const int appearance_delay_ms_;
97 DISALLOW_COPY_AND_ASSIGN(MaximizeBubbleControllerBubble);
102 #endif // ASH_FRAME_CAPTION_BUTTONS_MAXIMIZE_BUBBLE_CONTROLLER_BUBBLE_H_