| OLD | NEW |
| 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 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/common/system/tray/special_popup_row.h" | 9 #include "ash/common/system/tray/special_popup_row.h" |
| 10 #include "ash/common/system/tray/view_click_listener.h" | |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "ui/views/controls/button/button.h" | |
| 13 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
| 14 | 12 |
| 15 namespace views { | 13 namespace views { |
| 16 class ScrollView; | 14 class ScrollView; |
| 17 } // namespace views | 15 } |
| 18 | 16 |
| 19 namespace ash { | 17 namespace ash { |
| 20 namespace test { | |
| 21 class TrayDetailsViewTest; | |
| 22 } // namespace test | |
| 23 | |
| 24 class FixedSizedScrollView; | 18 class FixedSizedScrollView; |
| 25 class ScrollBorder; | 19 class ScrollBorder; |
| 26 class SystemTrayItem; | 20 class SystemTrayItem; |
| 21 class ViewClickListener; |
| 27 | 22 |
| 28 class ASH_EXPORT TrayDetailsView : public views::View, | 23 class ASH_EXPORT TrayDetailsView : public views::View { |
| 29 public ViewClickListener, | |
| 30 public views::ButtonListener { | |
| 31 public: | 24 public: |
| 32 explicit TrayDetailsView(SystemTrayItem* owner); | 25 explicit TrayDetailsView(SystemTrayItem* owner); |
| 33 ~TrayDetailsView() override; | 26 ~TrayDetailsView() override; |
| 34 | 27 |
| 35 // ViewClickListener: | 28 // Creates a row with special highlighting etc. This is typically the |
| 36 void OnViewClicked(views::View* sender) override; | 29 // bottom-most row in the popup. |
| 37 | 30 void CreateSpecialRow(int string_id, ViewClickListener* listener); |
| 38 // views::ButtonListener: | |
| 39 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 40 | |
| 41 SystemTrayItem* owner() { return owner_; } | |
| 42 SpecialPopupRow* title_row() { return title_row_; } | |
| 43 FixedSizedScrollView* scroller() { return scroller_; } | |
| 44 views::View* scroll_content() { return scroll_content_; } | |
| 45 | |
| 46 protected: | |
| 47 // views::View: | |
| 48 void Layout() override; | |
| 49 void OnPaintBorder(gfx::Canvas* canvas) override; | |
| 50 | |
| 51 // Creates the row containing the back button and title. For material design | |
| 52 // this appears at the top of the view, for non-material design it appears | |
| 53 // at the bottom. | |
| 54 void CreateTitleRow(int string_id); | |
| 55 | 31 |
| 56 // Creates a scrollable list. The list has a border at the bottom if there is | 32 // Creates a scrollable list. The list has a border at the bottom if there is |
| 57 // any other view between the list and the footer row at the bottom. | 33 // any other view between the list and the footer row at the bottom. |
| 58 void CreateScrollableList(); | 34 void CreateScrollableList(); |
| 59 | 35 |
| 60 // Adds a separator in scrollable list. | 36 // Adds a separator in scrollable list. |
| 61 void AddScrollSeparator(); | 37 void AddScrollSeparator(); |
| 62 | 38 |
| 63 // Removes (and destroys) all child views. | 39 // Removes (and destroys) all child views. |
| 64 void Reset(); | 40 void Reset(); |
| 65 | 41 |
| 66 private: | 42 // Transition to default view from details view. If |footer_| has focus before |
| 67 friend class test::TrayDetailsViewTest; | 43 // transition, the default view should focus on the owner of this details |
| 68 | 44 // view. |
| 69 // Overridden to handle clicks on subclass-specific views. | |
| 70 virtual void HandleViewClicked(views::View* view); | |
| 71 | |
| 72 // Overridden to handle button presses on subclass-specific buttons. | |
| 73 virtual void HandleButtonPressed(views::Button* sender, | |
| 74 const ui::Event& event); | |
| 75 | |
| 76 // Creates and adds subclass-specific buttons to the title row. | |
| 77 virtual void CreateExtraTitleRowButtons(); | |
| 78 | |
| 79 // Transition to default view from details view. If |title_row_| has focus | |
| 80 // before transition, the default view should focus on the owner of this | |
| 81 // details view. | |
| 82 void TransitionToDefaultView(); | 45 void TransitionToDefaultView(); |
| 83 | 46 |
| 47 SystemTrayItem* owner() const { return owner_; } |
| 48 SpecialPopupRow* footer() const { return footer_; } |
| 49 FixedSizedScrollView* scroller() const { return scroller_; } |
| 50 views::View* scroll_content() const { return scroll_content_; } |
| 51 |
| 52 protected: |
| 53 // Overridden from views::View. |
| 54 void Layout() override; |
| 55 void OnPaintBorder(gfx::Canvas* canvas) override; |
| 56 |
| 57 private: |
| 84 SystemTrayItem* owner_; | 58 SystemTrayItem* owner_; |
| 85 SpecialPopupRow* title_row_; | 59 SpecialPopupRow* footer_; |
| 86 FixedSizedScrollView* scroller_; | 60 FixedSizedScrollView* scroller_; |
| 87 views::View* scroll_content_; | 61 views::View* scroll_content_; |
| 88 ScrollBorder* scroll_border_; // Weak reference | 62 ScrollBorder* scroll_border_; // Weak reference |
| 89 | 63 |
| 90 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); | 64 DISALLOW_COPY_AND_ASSIGN(TrayDetailsView); |
| 91 }; | 65 }; |
| 92 | 66 |
| 93 } // namespace ash | 67 } // namespace ash |
| 94 | 68 |
| 95 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ | 69 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_DETAILS_VIEW_H_ |
| OLD | NEW |