| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 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_ |
| 7 |
| 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" |
| 22 |
| 23 namespace ui { |
| 24 class SlideAnimation; |
| 25 class AnimationDelegate; |
| 26 } |
| 27 |
| 28 namespace message_center { |
| 29 |
| 30 enum Alignment { |
| 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, |
| 36 }; |
| 37 |
| 38 struct PositionInfo { |
| 39 int max_height; |
| 40 |
| 41 // Alignment of the message center relative to the center of the screen. |
| 42 Alignment message_center_alignment; |
| 43 |
| 44 // Alignment of the taskbar relative to the center of the screen. |
| 45 Alignment taskbar_alignment; |
| 46 |
| 47 // Point relative to which message center is positioned. |
| 48 gfx::Point inital_anchor_point; |
| 49 }; |
| 50 |
| 51 class WebNotificationTray; |
| 52 class MessageCenterFrameView; |
| 53 |
| 54 // MessageCenterWidgetDelegate is the message center's client view. It also |
| 55 // creates the message center widget and sets the notifications. |
| 56 // |
| 57 //////////////////////////////////////////////////////////////////////////////// |
| 58 class MessageCenterWidgetDelegate : public views::WidgetDelegate, |
| 59 public message_center::MessageCenterView, |
| 60 public views::WidgetObserver { |
| 61 public: |
| 62 MessageCenterWidgetDelegate(WebNotificationTray* tray, |
| 63 MessageCenterTray* mc_tray, |
| 64 bool initially_settings_visible, |
| 65 const PositionInfo& pos_info); |
| 66 virtual ~MessageCenterWidgetDelegate(); |
| 67 |
| 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; |
| 75 |
| 76 // WidgetObserver overrides: |
| 77 virtual void OnWidgetActivationChanged(views::Widget* widget, |
| 78 bool active) OVERRIDE; |
| 79 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; |
| 80 |
| 81 // View overrides: |
| 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; |
| 87 |
| 88 private: |
| 89 // Creates and initializes the message center widget. |
| 90 void InitWidget(); |
| 91 |
| 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); |
| 97 |
| 98 // Calculates the message center bounds using the position info and the |
| 99 // corrected anchor. |
| 100 gfx::Rect GetMessageCenterBounds(); |
| 101 |
| 102 // Insets of the message center border (set in MessageCenterFrameView). |
| 103 gfx::Insets border_insets_; |
| 104 |
| 105 // Info necessary to calculate the estimated position of the message center. |
| 106 PositionInfo pos_info_; |
| 107 |
| 108 WebNotificationTray* tray_; |
| 109 }; |
| 110 |
| 111 } // namespace message_center |
| 112 |
| 113 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_MESSAGE_CENTER_WIDGET_DELEGATE
_H_ |
| OLD | NEW |