| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_ | 5 #ifndef UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_ |
| 6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_ | 6 #define UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class ArcCustomNotificationView : public views::NativeViewHost, | 28 class ArcCustomNotificationView : public views::NativeViewHost, |
| 29 public views::ButtonListener, | 29 public views::ButtonListener, |
| 30 public aura::WindowObserver, | 30 public aura::WindowObserver, |
| 31 public ArcCustomNotificationItem::Observer { | 31 public ArcCustomNotificationItem::Observer { |
| 32 public: | 32 public: |
| 33 ArcCustomNotificationView(ArcCustomNotificationItem* item, | 33 ArcCustomNotificationView(ArcCustomNotificationItem* item, |
| 34 exo::NotificationSurface* surface); | 34 exo::NotificationSurface* surface); |
| 35 ~ArcCustomNotificationView() override; | 35 ~ArcCustomNotificationView() override; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 class EventForwarder; |
| 39 class SlideHelper; |
| 40 |
| 38 void CreateFloatingCloseButton(); | 41 void CreateFloatingCloseButton(); |
| 42 void SetSurface(exo::NotificationSurface* surface); |
| 39 void UpdatePreferredSize(); | 43 void UpdatePreferredSize(); |
| 44 void UpdateCloseButtonVisiblity(); |
| 40 | 45 |
| 41 // views::NativeViewHost | 46 // views::NativeViewHost |
| 42 void ViewHierarchyChanged( | 47 void ViewHierarchyChanged( |
| 43 const ViewHierarchyChangedDetails& details) override; | 48 const ViewHierarchyChangedDetails& details) override; |
| 44 void Layout() override; | 49 void Layout() override; |
| 50 void OnKeyEvent(ui::KeyEvent* event) override; |
| 51 void OnGestureEvent(ui::GestureEvent* event) override; |
| 52 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 53 void OnMouseExited(const ui::MouseEvent& event) override; |
| 45 | 54 |
| 46 // views::ButtonListener | 55 // views::ButtonListener |
| 47 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 56 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 48 | 57 |
| 49 // aura::WindowObserver | 58 // aura::WindowObserver |
| 50 void OnWindowBoundsChanged(aura::Window* window, | 59 void OnWindowBoundsChanged(aura::Window* window, |
| 51 const gfx::Rect& old_bounds, | 60 const gfx::Rect& old_bounds, |
| 52 const gfx::Rect& new_bounds) override; | 61 const gfx::Rect& new_bounds) override; |
| 53 void OnWindowDestroying(aura::Window* window) override; | 62 void OnWindowDestroying(aura::Window* window) override; |
| 54 | 63 |
| 55 // ArcCustomNotificationItem::Observer | 64 // ArcCustomNotificationItem::Observer |
| 56 void OnItemDestroying() override; | 65 void OnItemDestroying() override; |
| 57 void OnItemPinnedChanged() override; | 66 void OnItemPinnedChanged() override; |
| 58 void OnItemNotificationSurfaceRemoved() override; | 67 void OnItemNotificationSurfaceRemoved() override; |
| 59 | 68 |
| 60 ArcCustomNotificationItem* item_; | 69 ArcCustomNotificationItem* item_ = nullptr; |
| 61 exo::NotificationSurface* surface_; | 70 exo::NotificationSurface* surface_ = nullptr; |
| 71 |
| 72 // A pre-target event handler to forward events on the surface to this view. |
| 73 // Using a pre-target event handler instead of a target handler on the surface |
| 74 // window because it has descendant aura::Window and the events on them need |
| 75 // to be handled as well. |
| 76 // TODO(xiyuan): Revisit after exo::Surface no longer has an aura::Window. |
| 77 std::unique_ptr<EventForwarder> event_forwarder_; |
| 78 |
| 79 // A helper to observe slide transform/animation and use surface layer copy |
| 80 // when a slide is in progress and restore the surface when it finishes. |
| 81 std::unique_ptr<SlideHelper> slide_helper_; |
| 62 | 82 |
| 63 // A close button on top of NotificationSurface. Needed because the | 83 // A close button on top of NotificationSurface. Needed because the |
| 64 // aura::Window of NotificationSurface is added after hosting widget's | 84 // aura::Window of NotificationSurface is added after hosting widget's |
| 65 // RootView thus standard notification close button is always below | 85 // RootView thus standard notification close button is always below |
| 66 // it. | 86 // it. |
| 67 std::unique_ptr<views::Widget> floating_close_button_widget_; | 87 std::unique_ptr<views::Widget> floating_close_button_widget_; |
| 68 | 88 |
| 69 views::ImageButton* floating_close_button_ = nullptr; | 89 views::ImageButton* floating_close_button_ = nullptr; |
| 70 | 90 |
| 71 DISALLOW_COPY_AND_ASSIGN(ArcCustomNotificationView); | 91 DISALLOW_COPY_AND_ASSIGN(ArcCustomNotificationView); |
| 72 }; | 92 }; |
| 73 | 93 |
| 74 } // namespace arc | 94 } // namespace arc |
| 75 | 95 |
| 76 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_ | 96 #endif // UI_ARC_NOTIFICATION_ARC_CUSTOM_NOTIFICATION_VIEW_H_ |
| OLD | NEW |