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

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

Issue 2367903002: Introduce SystemMenuButton for Ash material design (Closed)
Patch Set: Created 4 years, 3 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/throbber_view.h" 11 #include "ash/common/system/tray/throbber_view.h"
11 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/common/system/tray/tray_popup_header_button.h" 13 #include "ash/common/system/tray/tray_popup_header_button.h"
13 #include "ash/common/system/tray/tray_popup_item_style.h" 14 #include "ash/common/system/tray/tray_popup_item_style.h"
14 #include "ash/resources/vector_icons/vector_icons.h" 15 #include "ash/resources/vector_icons/vector_icons.h"
15 #include "grit/ash_resources.h" 16 #include "grit/ash_resources.h"
16 #include "grit/ash_strings.h" 17 #include "grit/ash_strings.h"
17 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/geometry/insets.h" 20 #include "ui/gfx/geometry/insets.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 90 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
90 SetLayoutManager(box_layout); 91 SetLayoutManager(box_layout);
91 content_ = view; 92 content_ = view;
92 // TODO(tdanderson): Consider moving this logic to a BoxLayout subclass. 93 // TODO(tdanderson): Consider moving this logic to a BoxLayout subclass.
93 AddChildViewAt(content_, views_before_content_container_ ? 1 : 0); 94 AddChildViewAt(content_, views_before_content_container_ ? 1 : 0);
94 if (MaterialDesignController::IsSystemTrayMenuMaterial()) 95 if (MaterialDesignController::IsSystemTrayMenuMaterial())
95 box_layout->SetFlexForView(content_, 1); 96 box_layout->SetFlexForView(content_, 1);
96 } 97 }
97 98
98 views::Button* SpecialPopupRow::AddBackButton(views::ButtonListener* listener) { 99 views::Button* SpecialPopupRow::AddBackButton(views::ButtonListener* listener) {
99 return AddImageButton(listener, kSystemMenuArrowBackIcon, 100 return AddSystemMenuButton(listener, kSystemMenuArrowBackIcon,
100 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU, false); 101 IDS_ASH_STATUS_TRAY_PREVIOUS_MENU, false);
101 } 102 }
102 103
103 views::Button* SpecialPopupRow::AddSettingsButton( 104 views::Button* SpecialPopupRow::AddSettingsButton(
104 views::ButtonListener* listener) { 105 views::ButtonListener* listener) {
105 return AddImageButton(listener, kSystemMenuSettingsIcon, 106 return AddSystemMenuButton(listener, kSystemMenuSettingsIcon,
106 IDS_ASH_STATUS_TRAY_SETTINGS, true); 107 IDS_ASH_STATUS_TRAY_SETTINGS, true);
107 } 108 }
108 109
109 views::ImageButton* SpecialPopupRow::AddImageButton( 110 SystemMenuButton* SpecialPopupRow::AddSystemMenuButton(
James Cook 2016/09/23 18:32:16 Thanks for renaming this.
110 views::ButtonListener* listener, 111 views::ButtonListener* listener,
111 const gfx::VectorIcon& icon, 112 const gfx::VectorIcon& icon,
112 int accessible_name_id, 113 int accessible_name_id,
113 bool after_content) { 114 bool after_content) {
114 views::ImageButton* button = new views::ImageButton(listener); 115 SystemMenuButton* button =
115 116 new SystemMenuButton(listener, icon, accessible_name_id);
116 gfx::ImageSkia image = gfx::CreateVectorIcon(icon, kMenuIconColor);
117 button->SetImage(views::Button::STATE_NORMAL, &image);
118 const int horizontal_padding = (kMenuButtonSize - image.width()) / 2;
119 const int vertical_padding = (kMenuButtonSize - image.height()) / 2;
120 button->SetBorder(
121 views::Border::CreateEmptyBorder(vertical_padding, horizontal_padding,
122 vertical_padding, horizontal_padding));
123
124 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
125 button->SetTooltipText(bundle.GetLocalizedString(accessible_name_id));
126 button->SetFocusForPlatform();
127 button->SetFocusPainter(views::Painter::CreateSolidFocusPainter(
128 kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
129 117
130 if (after_content) 118 if (after_content)
131 AddViewAfterContent(button); 119 AddViewAfterContent(button);
132 else 120 else
133 AddViewBeforeContent(button); 121 AddViewBeforeContent(button);
134 122
135 return button; 123 return button;
136 } 124 }
137 125
138 views::ToggleButton* SpecialPopupRow::AddToggleButton( 126 views::ToggleButton* SpecialPopupRow::AddToggleButton(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 271
284 container->SetBorder( 272 container->SetBorder(
285 views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0)); 273 views::Border::CreateEmptyBorder(0, kTrayPopupPaddingHorizontal, 0, 0));
286 274
287 container->SetAccessibleName( 275 container->SetAccessibleName(
288 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU)); 276 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU));
289 SetContent(container); 277 SetContent(container);
290 } 278 }
291 279
292 } // namespace ash 280 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698