Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: ash/common/system/tray/special_popup_row.cc

Issue 2429923002: Implement all system menu title row buttons for Ash MD (Closed)
Patch Set: OS_WIN define in tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ash/common/system/tray/special_popup_row.h" 5 #include "ash/common/system/tray/special_popup_row.h"
6 6
7 #include "ash/common/ash_constants.h" 7 #include "ash/common/ash_constants.h"
8 #include "ash/common/material_design/material_design_controller.h" 8 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/common/system/tray/hover_highlight_view.h" 9 #include "ash/common/system/tray/hover_highlight_view.h"
10 #include "ash/common/system/tray/system_menu_button.h" 10 #include "ash/common/system/tray/system_menu_button.h"
11 #include "ash/common/system/tray/throbber_view.h" 11 #include "ash/common/system/tray/throbber_view.h"
12 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/system/tray/tray_popup_header_button.h" 13 #include "ash/common/system/tray/tray_popup_header_button.h"
14 #include "ash/common/system/tray/tray_popup_item_style.h" 14 #include "ash/common/system/tray/tray_popup_item_style.h"
15 #include "ash/common/system/tray/tray_utils.h"
15 #include "ash/resources/vector_icons/vector_icons.h" 16 #include "ash/resources/vector_icons/vector_icons.h"
16 #include "grit/ash_resources.h" 17 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/geometry/insets.h" 21 #include "ui/gfx/geometry/insets.h"
21 #include "ui/gfx/geometry/rect.h" 22 #include "ui/gfx/geometry/rect.h"
22 #include "ui/gfx/paint_vector_icon.h" 23 #include "ui/gfx/paint_vector_icon.h"
23 #include "ui/views/background.h" 24 #include "ui/views/background.h"
24 #include "ui/views/border.h" 25 #include "ui/views/border.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 91 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
91 SetLayoutManager(box_layout); 92 SetLayoutManager(box_layout);
92 content_ = view; 93 content_ = view;
93 // TODO(tdanderson): Consider moving this logic to a BoxLayout subclass. 94 // TODO(tdanderson): Consider moving this logic to a BoxLayout subclass.
94 AddChildViewAt(content_, views_before_content_container_ ? 1 : 0); 95 AddChildViewAt(content_, views_before_content_container_ ? 1 : 0);
95 if (MaterialDesignController::IsSystemTrayMenuMaterial()) 96 if (MaterialDesignController::IsSystemTrayMenuMaterial())
96 box_layout->SetFlexForView(content_, 1); 97 box_layout->SetFlexForView(content_, 1);
97 } 98 }
98 99
99 views::Button* SpecialPopupRow::AddBackButton(views::ButtonListener* listener) { 100 views::Button* SpecialPopupRow::AddBackButton(views::ButtonListener* listener) {
100 return AddSystemMenuButton(listener, kSystemMenuArrowBackIcon, 101 SystemMenuButton* button = new SystemMenuButton(
101 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU, false); 102 listener, kSystemMenuArrowBackIcon, IDS_ASH_STATUS_TRAY_PREVIOUS_MENU);
103 AddViewBeforeContent(button);
104 return button;
102 } 105 }
103 106
104 views::Button* SpecialPopupRow::AddSettingsButton( 107 views::Button* SpecialPopupRow::AddSettingsButton(
105 views::ButtonListener* listener) {
106 return AddSystemMenuButton(listener, kSystemMenuSettingsIcon,
107 IDS_ASH_STATUS_TRAY_SETTINGS, true);
108 }
109
110 SystemMenuButton* SpecialPopupRow::AddSystemMenuButton(
111 views::ButtonListener* listener, 108 views::ButtonListener* listener,
112 const gfx::VectorIcon& icon, 109 LoginStatus status) {
113 int accessible_name_id, 110 SystemMenuButton* button = new SystemMenuButton(
114 bool after_content) { 111 listener, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_SETTINGS);
115 SystemMenuButton* button = 112 if (!CanOpenWebUISettings(status))
116 new SystemMenuButton(listener, icon, accessible_name_id); 113 button->SetState(views::Button::STATE_DISABLED);
117 114 AddViewAfterContent(button);
118 if (after_content)
119 AddViewAfterContent(button);
120 else
121 AddViewBeforeContent(button);
122
123 return button; 115 return button;
124 } 116 }
125 117
118 views::Button* SpecialPopupRow::AddHelpButton(views::ButtonListener* listener,
119 LoginStatus status) {
120 SystemMenuButton* button = new SystemMenuButton(listener, kSystemMenuHelpIcon,
121 IDS_ASH_STATUS_TRAY_HELP);
122 if (!CanOpenWebUISettings(status))
123 button->SetState(views::Button::STATE_DISABLED);
124 AddViewAfterContent(button);
125 return button;
126 }
127
126 views::ToggleButton* SpecialPopupRow::AddToggleButton( 128 views::ToggleButton* SpecialPopupRow::AddToggleButton(
127 views::ButtonListener* listener) { 129 views::ButtonListener* listener) {
128 // TODO(tdanderson): Define the focus rect for ToggleButton. 130 // TODO(tdanderson): Define the focus rect for ToggleButton.
129 views::ToggleButton* toggle = new views::ToggleButton(listener); 131 views::ToggleButton* toggle = new views::ToggleButton(listener);
130 toggle->SetFocusForPlatform(); 132 toggle->SetFocusForPlatform();
131 133
132 views::View* container = new views::View; 134 views::View* container = new views::View;
133 views::BoxLayout* layout = 135 views::BoxLayout* layout =
134 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); 136 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
135 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); 137 layout->set_main_axis_alignment(views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER);
136 layout->set_cross_axis_alignment( 138 layout->set_cross_axis_alignment(
137 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 139 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
138 container->SetLayoutManager(layout); 140 container->SetLayoutManager(layout);
139 141
140 container->AddChildView(toggle); 142 container->AddChildView(toggle);
141 AddViewAfterContent(container); 143 AddViewAfterContent(container);
142 144
143 return toggle; 145 return toggle;
144 } 146 }
145 147
148 void SpecialPopupRow::AddViewToTitleRow(views::View* view) {
149 AddViewAfterContent(view);
150 }
151
146 void SpecialPopupRow::AddViewToRowNonMd(views::View* view, bool add_separator) { 152 void SpecialPopupRow::AddViewToRowNonMd(views::View* view, bool add_separator) {
147 AddViewAfterContent(view, add_separator); 153 AddViewAfterContent(view, add_separator);
148 } 154 }
149 155
150 gfx::Size SpecialPopupRow::GetPreferredSize() const { 156 gfx::Size SpecialPopupRow::GetPreferredSize() const {
151 gfx::Size size = views::View::GetPreferredSize(); 157 gfx::Size size = views::View::GetPreferredSize();
152 size.set_height(kSpecialPopupRowHeight); 158 size.set_height(kSpecialPopupRowHeight);
153 return size; 159 return size;
154 } 160 }
155 161
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 277
272 container->SetBorder( 278 container->SetBorder(
273 views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); 279 views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0));
274 280
275 container->SetAccessibleName( 281 container->SetAccessibleName(
276 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); 282 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU));
277 SetContent(container); 283 SetContent(container);
278 } 284 }
279 285
280 } // namespace ash 286 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/special_popup_row.h ('k') | ash/common/system/tray/system_menu_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698