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 CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_
6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "chrome/browser/ui/views/message_center/web_notification_tray.h"
12 #include "ui/base/animation/animation_delegate.h"
13 #include "ui/base/animation/slide_animation.h"
14 #include "ui/gfx/point.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/message_center/message_center.h"
17 #include "ui/message_center/message_center_tray.h"
18 #include "ui/message_center/message_center_tray_delegate.h"
19 #include "ui/message_center/views/message_center_view.h"
20 #include "ui/views/widget/widget_delegate.h"
21 #include "ui/views/widget/widget_observer.h"
25 class AnimationDelegate
;
28 namespace message_center
{
31 ALIGNMENT_TOP
= 1 << 0,
32 ALIGNMENT_LEFT
= 1 << 1,
33 ALIGNMENT_BOTTOM
= 1 << 2,
34 ALIGNMENT_RIGHT
= 1 << 3,
35 ALIGNMENT_NONE
= 1 << 4,
41 // Alignment of the message center relative to the center of the screen.
42 Alignment message_center_alignment
;
44 // Alignment of the taskbar relative to the center of the screen.
45 Alignment taskbar_alignment
;
47 // Point relative to which message center is positioned.
48 gfx::Point inital_anchor_point
;
51 class WebNotificationTray
;
52 class MessageCenterFrameView
;
54 // MessageCenterWidgetDelegate is the message center's client view. It also
55 // creates the message center widget and sets the notifications.
57 ////////////////////////////////////////////////////////////////////////////////
58 class MessageCenterWidgetDelegate
: public views::WidgetDelegate
,
59 public message_center::MessageCenterView
,
60 public views::WidgetObserver
{
62 MessageCenterWidgetDelegate(WebNotificationTray
* tray
,
63 MessageCenterTray
* mc_tray
,
64 bool initially_settings_visible
,
65 const PositionInfo
& pos_info
);
66 virtual ~MessageCenterWidgetDelegate();
68 // WidgetDelegate overrides:
69 virtual View
* GetContentsView() OVERRIDE
;
70 virtual views::NonClientFrameView
* CreateNonClientFrameView(
71 views::Widget
* widget
) OVERRIDE
;
72 virtual void DeleteDelegate() OVERRIDE
;
73 virtual views::Widget
* GetWidget() OVERRIDE
;
74 virtual const views::Widget
* GetWidget() const OVERRIDE
;
76 // WidgetObserver overrides:
77 virtual void OnWidgetActivationChanged(views::Widget
* widget
,
78 bool active
) OVERRIDE
;
79 virtual void OnWidgetClosing(views::Widget
* widget
) OVERRIDE
;
82 virtual void PreferredSizeChanged() OVERRIDE
;
83 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
84 virtual gfx::Size
GetMaximumSize() OVERRIDE
;
85 virtual int GetHeightForWidth(int width
) OVERRIDE
;
86 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
89 // Creates and initializes the message center widget.
92 // Shifts the message center anchor point such that the mouse click point is
93 // along the middle 60% of the width of the message center if taskbar is
94 // horizontal aligned. If vertically aligned, ensures that mouse click point
95 // is along the height of the message center (at least at a corner).
96 gfx::Point
GetCorrectedAnchor(gfx::Size calculated_size
);
98 // Calculates the message center bounds using the position info and the
100 gfx::Rect
GetMessageCenterBounds();
102 // Insets of the message center border (set in MessageCenterFrameView).
103 gfx::Insets border_insets_
;
105 // Info necessary to calculate the estimated position of the message center.
106 PositionInfo pos_info_
;
108 WebNotificationTray
* tray_
;
111 } // namespace message_center
113 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE_H_