| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_SPECIAL_POPUP_ROW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/common/login_status.h" | 9 #include "ash/common/login_status.h" |
| 10 #include "ash/resources/vector_icons/vector_icons.h" | 10 #include "ash/resources/vector_icons/vector_icons.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 14 | 14 |
| 15 namespace views { | |
| 16 class Button; | |
| 17 class ButtonListener; | |
| 18 class CustomButton; | |
| 19 class Label; | |
| 20 class ToggleButton; | |
| 21 } | |
| 22 | |
| 23 namespace ash { | 15 namespace ash { |
| 24 class SystemMenuButton; | |
| 25 class ThrobberView; | 16 class ThrobberView; |
| 26 class TrayItemView; | 17 class TrayItemView; |
| 27 class TrayPopupHeaderButton; | 18 class TrayPopupHeaderButton; |
| 28 class ViewClickListener; | 19 class ViewClickListener; |
| 29 | 20 |
| 30 // For material design, this class represents the top title row for detailed | 21 // Not used in material design. This class represents the bottom row of |
| 31 // views and handles the creation and layout of its elements (back button, | 22 // detailed views and the bottom row of the system menu (date, help, power, |
| 32 // title, settings button, and possibly other buttons). For non-MD, this class | 23 // and lock). This row has a fixed height. |
| 33 // represents the bottom row of detailed views and the bottom row of the | 24 // TODO(tdanderson): Remove this class when material design is enabled by |
| 34 // system menu (date, help, power, and lock). This row has a fixed height. | 25 // default. See crbug.com/614453. |
| 35 class ASH_EXPORT SpecialPopupRow : public views::View { | 26 class ASH_EXPORT SpecialPopupRow : public views::View { |
| 36 public: | 27 public: |
| 37 SpecialPopupRow(); | 28 SpecialPopupRow(); |
| 38 ~SpecialPopupRow() override; | 29 ~SpecialPopupRow() override; |
| 39 | 30 |
| 40 // Creates a text label corresponding to |string_id| and sets it as the | 31 // Creates a text label corresponding to |string_id| and sets it as the |
| 41 // content of this row. | 32 // content of this row. |
| 42 void SetTextLabel(int string_id, ViewClickListener* listener); | 33 void SetTextLabel(int string_id, ViewClickListener* listener); |
| 43 | 34 |
| 44 // Sets |content_| to be |view| and adds |content_| as a child view of this | 35 // Sets |content_| to be |view| and adds |content_| as a child view of this |
| 45 // row. This should only be called once, upon initialization of the row. | 36 // row. This should only be called once, upon initialization of the row. |
| 46 // TODO(tdanderson): Make this private when material design is enabled by | |
| 47 // default. See crbug.com/614453. | |
| 48 void SetContent(views::View* view); | 37 void SetContent(views::View* view); |
| 49 | 38 |
| 50 // Creates UI elements for the material design title row and adds them to | |
| 51 // the view hierarchy rooted at |this|. Returns a pointer to the created | |
| 52 // view. | |
| 53 views::Button* AddBackButton(views::ButtonListener* listener); | |
| 54 views::CustomButton* AddSettingsButton(views::ButtonListener* listener, | |
| 55 LoginStatus status); | |
| 56 views::CustomButton* AddHelpButton(views::ButtonListener* listener, | |
| 57 LoginStatus status); | |
| 58 views::ToggleButton* AddToggleButton(views::ButtonListener* listener); | |
| 59 | |
| 60 // Adds |view| after this row's content. | 39 // Adds |view| after this row's content. |
| 61 void AddViewToTitleRow(views::View* view); | 40 void AddViewToTitleRow(views::View* view); |
| 62 | 41 |
| 63 // Adds |view| after this row's content, optionally with a separator. Only | 42 // Adds |view| after this row's content, optionally with a separator. Only |
| 64 // used for non-MD. | 43 // used for non-MD. |
| 65 // TODO(tdanderson): Remove this when material design is enabled by default. | |
| 66 // See crbug.com/614453. | |
| 67 void AddViewToRowNonMd(views::View* view, bool add_separator); | 44 void AddViewToRowNonMd(views::View* view, bool add_separator); |
| 68 | 45 |
| 69 // TODO(tdanderson): Remove this accessor when material design is enabled by | |
| 70 // default. See crbug.com/614453. | |
| 71 views::View* content() const { return content_; } | 46 views::View* content() const { return content_; } |
| 72 | 47 |
| 73 private: | 48 private: |
| 74 // views::View: | 49 // views::View: |
| 75 gfx::Size GetPreferredSize() const override; | 50 gfx::Size GetPreferredSize() const override; |
| 76 int GetHeightForWidth(int width) const override; | 51 int GetHeightForWidth(int width) const override; |
| 77 void Layout() override; | 52 void Layout() override; |
| 78 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | |
| 79 | 53 |
| 80 // Updates the style of |label_|, if it exists. Only used in material design. | 54 // Used to add views to |views_after_content_container_|, respectively. Views |
| 81 void UpdateStyle(); | 55 // are added in a left-to-right order. |
| 82 | |
| 83 // Used to add views to |views_before_content_container_| and | |
| 84 // |views_after_content_container_|, respectively. Views are added to both | |
| 85 // containers in a left-to-right order. | |
| 86 void AddViewBeforeContent(views::View* view); | |
| 87 void AddViewAfterContent(views::View* view); | 56 void AddViewAfterContent(views::View* view); |
| 88 void AddViewAfterContent(views::View* view, bool add_separator); | 57 void AddViewAfterContent(views::View* view, bool add_separator); |
| 89 | 58 |
| 90 void SetTextLabelMd(int string_id, ViewClickListener* listener); | |
| 91 void SetTextLabelNonMd(int string_id, ViewClickListener* listener); | |
| 92 | |
| 93 // The container for the views positioned before |content_|. | |
| 94 views::View* views_before_content_container_; | |
| 95 | |
| 96 // The main content of this row, typically a label. | 59 // The main content of this row, typically a label. |
| 97 views::View* content_; | 60 views::View* content_; |
| 98 | 61 |
| 99 // The container for the views positioned after |content_|. | 62 // The container for the views positioned after |content_|. |
| 100 views::View* views_after_content_container_; | 63 views::View* views_after_content_container_; |
| 101 | 64 |
| 102 // A pointer to the label which is parented to |content_|; this is non-null | |
| 103 // only if this row's content is a single label. Not owned. | |
| 104 views::Label* label_; | |
| 105 | |
| 106 DISALLOW_COPY_AND_ASSIGN(SpecialPopupRow); | 65 DISALLOW_COPY_AND_ASSIGN(SpecialPopupRow); |
| 107 }; | 66 }; |
| 108 | 67 |
| 109 } // namespace ash | 68 } // namespace ash |
| 110 | 69 |
| 111 #endif // ASH_COMMON_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ | 70 #endif // ASH_COMMON_SYSTEM_TRAY_SPECIAL_POPUP_ROW_H_ |
| OLD | NEW |