Chromium Code Reviews| Index: ash/common/system/tray/tray_details_view.cc |
| diff --git a/ash/common/system/tray/tray_details_view.cc b/ash/common/system/tray/tray_details_view.cc |
| index 9ca7fafd1f6a6578666e87fa161057232dcda5b3..266e587a3c65566b10205e8e201a74846b0d41c8 100644 |
| --- a/ash/common/system/tray/tray_details_view.cc |
| +++ b/ash/common/system/tray/tray_details_view.cc |
| @@ -7,17 +7,24 @@ |
| #include "ash/common/ash_view_ids.h" |
| #include "ash/common/material_design/material_design_controller.h" |
| #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| +#include "ash/common/system/tray/system_menu_button.h" |
| #include "ash/common/system/tray/system_tray.h" |
| #include "ash/common/system/tray/system_tray_item.h" |
| #include "ash/common/system/tray/tray_constants.h" |
| +#include "ash/common/system/tray/tray_popup_item_style.h" |
| +#include "ash/common/system/tray/tray_popup_utils.h" |
| +#include "ash/common/system/tray/tri_view.h" |
| #include "base/containers/adapters.h" |
| +#include "grit/ash_strings.h" |
| #include "third_party/skia/include/core/SkDrawLooper.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| #include "ui/compositor/paint_context.h" |
| #include "ui/compositor/paint_recorder.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/skia_util.h" |
| #include "ui/views/background.h" |
| #include "ui/views/border.h" |
| +#include "ui/views/controls/label.h" |
| #include "ui/views/controls/progress_bar.h" |
| #include "ui/views/controls/scroll_view.h" |
| #include "ui/views/controls/separator.h" |
| @@ -264,6 +271,8 @@ TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) |
| scroll_content_(nullptr), |
| progress_bar_(nullptr), |
| scroll_border_(nullptr), |
| + tri_view_(nullptr), |
| + label_(nullptr), |
| back_button_(nullptr) { |
| SetLayoutManager(box_layout_); |
| set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
| @@ -291,13 +300,26 @@ void TrayDetailsView::ButtonPressed(views::Button* sender, |
| } |
| void TrayDetailsView::CreateTitleRow(int string_id) { |
| + DCHECK(!tri_view_); |
| DCHECK(!title_row_); |
| - title_row_ = new SpecialPopupRow(); |
| - title_row_->SetTextLabel(string_id, this); |
| + |
| if (UseMd()) { |
| - title_row_->SetBorder(views::CreateEmptyBorder(kTitleRowPaddingTop, 0, |
| - kTitleRowPaddingBottom, 0)); |
| - AddChildViewAt(title_row_, 0); |
| + tri_view_ = TrayPopupUtils::CreateDefaultRowView(); |
| + |
| + back_button_ = CreateBackButton(); |
| + tri_view_->AddView(TriView::Container::START, back_button_); |
| + |
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| + label_ = TrayPopupUtils::CreateDefaultLabel(); |
| + label_->SetText(rb.GetLocalizedString(string_id)); |
| + UpdateStyle(); |
| + tri_view_->AddView(TriView::Container::CENTER, label_); |
| + |
| + tri_view_->SetContainerVisible(TriView::Container::END, false); |
| + |
| + tri_view_->SetBorder(views::CreateEmptyBorder(kTitleRowPaddingTop, 0, |
| + kTitleRowPaddingBottom, 0)); |
| + AddChildViewAt(tri_view_, 0); |
| views::Separator* separator = |
| new views::Separator(views::Separator::HORIZONTAL); |
| separator->SetColor(kHorizontalSeparatorColor); |
| @@ -306,14 +328,12 @@ void TrayDetailsView::CreateTitleRow(int string_id) { |
| kTitleRowProgressBarHeight - kTitleRowSeparatorHeight, 0, 0, 0)); |
| AddChildViewAt(separator, kTitleRowSeparatorIndex); |
| } else { |
| + title_row_ = new SpecialPopupRow(); |
| + title_row_->SetTextLabel(string_id, this); |
| AddChildViewAt(title_row_, child_count()); |
| } |
| CreateExtraTitleRowButtons(); |
| - |
| - if (UseMd()) |
| - back_button_ = title_row_->AddBackButton(this); |
| - |
| Layout(); |
| } |
| @@ -356,11 +376,13 @@ void TrayDetailsView::Reset() { |
| scroll_content_ = nullptr; |
| progress_bar_ = nullptr; |
| back_button_ = nullptr; |
| + label_ = nullptr; |
| + tri_view_ = nullptr; |
| } |
| void TrayDetailsView::ShowProgress(double value, bool visible) { |
| DCHECK(UseMd()); |
| - DCHECK(title_row_); |
| + DCHECK(tri_view_); |
| if (!progress_bar_) { |
| progress_bar_ = new views::ProgressBar(kTitleRowProgressBarHeight); |
| progress_bar_->SetVisible(false); |
| @@ -372,6 +394,39 @@ void TrayDetailsView::ShowProgress(double value, bool visible) { |
| child_at(kTitleRowSeparatorIndex)->SetVisible(!visible); |
| } |
| +views::CustomButton* TrayDetailsView::CreateSettingsButton(LoginStatus status) { |
| + DCHECK(UseMd()); |
| + SystemMenuButton* button = new SystemMenuButton( |
| + this, SystemMenuButton::InkDropStyle::SQUARE, kSystemMenuSettingsIcon, |
| + IDS_ASH_STATUS_TRAY_SETTINGS); |
| + if (!TrayPopupUtils::CanOpenWebUISettings(status)) |
| + button->SetState(views::Button::STATE_DISABLED); |
| + return button; |
| +} |
| + |
| +views::CustomButton* TrayDetailsView::CreateHelpButton(LoginStatus status) { |
| + DCHECK(UseMd()); |
| + SystemMenuButton* button = |
| + new SystemMenuButton(this, SystemMenuButton::InkDropStyle::SQUARE, |
| + kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); |
| + if (!TrayPopupUtils::CanOpenWebUISettings(status)) |
| + button->SetState(views::Button::STATE_DISABLED); |
| + return button; |
| +} |
| + |
| +void TrayDetailsView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| + UpdateStyle(); |
| +} |
| + |
| +void TrayDetailsView::UpdateStyle() { |
| + if (!GetNativeTheme()) |
|
bruthig
2016/11/16 14:58:31
I have to apologize, I was wrong. GetNativeTheme(
|
| + return; |
| + |
| + TrayPopupItemStyle style(GetNativeTheme(), |
| + TrayPopupItemStyle::FontStyle::TITLE); |
| + style.SetupLabel(label_); |
| +} |
| + |
| void TrayDetailsView::HandleViewClicked(views::View* view) { |
| NOTREACHED(); |
| } |
| @@ -400,6 +455,14 @@ void TrayDetailsView::TransitionToDefaultView() { |
| owner->set_restore_focus(false); |
| } |
| +views::Button* TrayDetailsView::CreateBackButton() { |
| + DCHECK(UseMd()); |
| + SystemMenuButton* button = new SystemMenuButton( |
| + this, SystemMenuButton::InkDropStyle::SQUARE, kSystemMenuArrowBackIcon, |
| + IDS_ASH_STATUS_TRAY_PREVIOUS_MENU); |
| + return button; |
| +} |
| + |
| void TrayDetailsView::Layout() { |
| if (UseMd()) { |
| views::View::Layout(); |