Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/palette/palette_tray.h" | 5 #include "ash/common/system/chromeos/palette/palette_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/shelf/wm_shelf_util.h" | 11 #include "ash/common/shelf/wm_shelf_util.h" |
| 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" | 12 #include "ash/common/system/chromeos/palette/palette_tool_manager.h" |
| 13 #include "ash/common/system/chromeos/palette/palette_utils.h" | 13 #include "ash/common/system/chromeos/palette/palette_utils.h" |
| 14 #include "ash/common/system/tray/system_menu_button.h" | |
| 14 #include "ash/common/system/tray/system_tray_controller.h" | 15 #include "ash/common/system/tray/system_tray_controller.h" |
| 15 #include "ash/common/system/tray/system_tray_delegate.h" | 16 #include "ash/common/system/tray/system_tray_delegate.h" |
| 16 #include "ash/common/system/tray/tray_bubble_wrapper.h" | 17 #include "ash/common/system/tray/tray_bubble_wrapper.h" |
| 17 #include "ash/common/system/tray/tray_constants.h" | 18 #include "ash/common/system/tray/tray_constants.h" |
| 18 #include "ash/common/system/tray/tray_popup_header_button.h" | |
| 19 #include "ash/common/wm_lookup.h" | 19 #include "ash/common/wm_lookup.h" |
| 20 #include "ash/common/wm_root_window_controller.h" | 20 #include "ash/common/wm_root_window_controller.h" |
| 21 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 22 #include "ash/common/wm_window.h" | 22 #include "ash/common/wm_window.h" |
| 23 #include "ash/public/cpp/shell_window_ids.h" | 23 #include "ash/public/cpp/shell_window_ids.h" |
| 24 #include "ash/resources/vector_icons/vector_icons.h" | 24 #include "ash/resources/vector_icons/vector_icons.h" |
| 25 #include "base/metrics/histogram_macros.h" | 25 #include "base/metrics/histogram_macros.h" |
| 26 #include "grit/ash_resources.h" | 26 #include "grit/ash_resources.h" |
| 27 #include "grit/ash_strings.h" | 27 #include "grit/ash_strings.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 kHorizontalPaddingBetweenTitleEntries); | 98 kHorizontalPaddingBetweenTitleEntries); |
| 99 SetLayoutManager(box_layout); | 99 SetLayoutManager(box_layout); |
| 100 | 100 |
| 101 views::Label* text_label = | 101 views::Label* text_label = |
| 102 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); | 102 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); |
| 103 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 103 text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 104 text_label->SetFontList(GetTitleFont()); | 104 text_label->SetFontList(GetTitleFont()); |
| 105 AddChildView(text_label); | 105 AddChildView(text_label); |
| 106 box_layout->SetFlexForView(text_label, 1); | 106 box_layout->SetFlexForView(text_label, 1); |
| 107 | 107 |
| 108 gfx::ImageSkia settings_icon = | 108 help_button_ = |
| 109 gfx::CreateVectorIcon(kSystemMenuSettingsIcon, kMenuIconColor); | 109 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, |
| 110 gfx::ImageSkia help_icon = | 110 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); |
| 111 gfx::CreateVectorIcon(kSystemMenuHelpIcon, kMenuIconColor); | |
| 112 | |
| 113 help_button_ = new ash::TrayPopupHeaderButton(this, help_icon, | |
| 114 IDS_ASH_STATUS_TRAY_HELP); | |
| 115 help_button_->SetTooltipText( | |
| 116 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); | |
| 117 AddChildView(help_button_); | 111 AddChildView(help_button_); |
| 118 | 112 |
| 119 settings_button_ = new ash::TrayPopupHeaderButton( | 113 settings_button_ = new SystemMenuButton( |
| 120 this, settings_icon, IDS_ASH_STATUS_TRAY_SETTINGS); | 114 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuSettingsIcon, |
| 121 settings_button_->SetTooltipText( | 115 IDS_ASH_STATUS_TRAY_SETTINGS); |
|
tdanderson
2016/11/23 02:19:07
Actually I would hold off on touching the palette
Evan Stade
2016/11/28 19:05:53
Done.
tdanderson
2016/11/29 18:58:34
Just double checked and the palette should indeed
| |
| 122 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SETTINGS)); | |
| 123 AddChildView(settings_button_); | 116 AddChildView(settings_button_); |
| 124 } | 117 } |
| 125 | 118 |
| 126 ~TitleView() override {} | 119 ~TitleView() override {} |
| 127 | 120 |
| 128 private: | 121 private: |
| 129 // views::ButtonListener: | 122 // views::ButtonListener: |
| 130 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 123 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 131 if (sender == settings_button_) { | 124 if (sender == settings_button_) { |
| 132 palette_tray_->RecordPaletteOptionsUsage( | 125 palette_tray_->RecordPaletteOptionsUsage( |
| 133 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); | 126 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); |
| 134 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); | 127 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); |
| 135 palette_tray_->HidePalette(); | 128 palette_tray_->HidePalette(); |
| 136 } else if (sender == help_button_) { | 129 } else if (sender == help_button_) { |
| 137 palette_tray_->RecordPaletteOptionsUsage( | 130 palette_tray_->RecordPaletteOptionsUsage( |
| 138 PaletteTrayOptions::PALETTE_HELP_BUTTON); | 131 PaletteTrayOptions::PALETTE_HELP_BUTTON); |
| 139 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); | 132 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); |
| 140 palette_tray_->HidePalette(); | 133 palette_tray_->HidePalette(); |
| 141 } else { | 134 } else { |
| 142 NOTREACHED(); | 135 NOTREACHED(); |
| 143 } | 136 } |
| 144 } | 137 } |
| 145 | 138 |
| 146 // Unowned pointers to button views so we can determine which button was | 139 // Unowned pointers to button views so we can determine which button was |
| 147 // clicked. | 140 // clicked. |
| 148 ash::TrayPopupHeaderButton* settings_button_; | 141 views::Button* settings_button_; |
| 149 ash::TrayPopupHeaderButton* help_button_; | 142 views::Button* help_button_; |
| 150 PaletteTray* palette_tray_; | 143 PaletteTray* palette_tray_; |
| 151 | 144 |
| 152 DISALLOW_COPY_AND_ASSIGN(TitleView); | 145 DISALLOW_COPY_AND_ASSIGN(TitleView); |
| 153 }; | 146 }; |
| 154 | 147 |
| 155 } // namespace | 148 } // namespace |
| 156 | 149 |
| 157 PaletteTray::PaletteTray(WmShelf* wm_shelf) | 150 PaletteTray::PaletteTray(WmShelf* wm_shelf) |
| 158 : TrayBackgroundView(wm_shelf), | 151 : TrayBackgroundView(wm_shelf), |
| 159 palette_tool_manager_(new PaletteToolManager(this)), | 152 palette_tool_manager_(new PaletteToolManager(this)), |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 bubble_view->AddChildView(separator); | 248 bubble_view->AddChildView(separator); |
| 256 | 249 |
| 257 // Add palette tools. | 250 // Add palette tools. |
| 258 // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design | 251 // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design |
| 259 // ripples. | 252 // ripples. |
| 260 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); | 253 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); |
| 261 for (const PaletteToolView& view : views) | 254 for (const PaletteToolView& view : views) |
| 262 bubble_view->AddChildView(view.view); | 255 bubble_view->AddChildView(view.view); |
| 263 | 256 |
| 264 // Show the bubble. | 257 // Show the bubble. |
| 265 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); | 258 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); |
| 266 SetIsActive(true); | 259 SetIsActive(true); |
| 267 return true; | 260 return true; |
| 268 } | 261 } |
| 269 | 262 |
| 270 bool PaletteTray::ContainsPointInScreen(const gfx::Point& point) { | 263 bool PaletteTray::ContainsPointInScreen(const gfx::Point& point) { |
| 271 if (icon_ && icon_->GetBoundsInScreen().Contains(point)) | 264 if (icon_ && icon_->GetBoundsInScreen().Contains(point)) |
| 272 return true; | 265 return true; |
| 273 | 266 |
| 274 return bubble_ && bubble_->bubble_view()->GetBoundsInScreen().Contains(point); | 267 return bubble_ && bubble_->bubble_view()->GetBoundsInScreen().Contains(point); |
| 275 } | 268 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding))); | 394 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding))); |
| 402 } else { | 395 } else { |
| 403 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets( | 396 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets( |
| 404 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); | 397 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); |
| 405 } | 398 } |
| 406 } | 399 } |
| 407 | 400 |
| 408 void PaletteTray::UpdateTrayIcon() { | 401 void PaletteTray::UpdateTrayIcon() { |
| 409 icon_->SetImage(CreateVectorIcon( | 402 icon_->SetImage(CreateVectorIcon( |
| 410 palette_tool_manager_->GetActiveTrayIcon( | 403 palette_tool_manager_->GetActiveTrayIcon( |
| 411 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)), | 404 palette_tool_manager_->GetActiveTool(PaletteGroup::MODE)), |
| 412 kShelfIconSize, kShelfIconColor)); | 405 kShelfIconSize, kShelfIconColor)); |
| 413 } | 406 } |
| 414 | 407 |
| 415 void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { | 408 void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { |
| 416 PaletteDelegate* palette_delegate = WmShell::Get()->palette_delegate(); | 409 PaletteDelegate* palette_delegate = WmShell::Get()->palette_delegate(); |
| 417 | 410 |
| 418 // Don't do anything if the palette should not be shown or if the user has | 411 // Don't do anything if the palette should not be shown or if the user has |
| 419 // disabled it all-together. | 412 // disabled it all-together. |
| 420 if (!IsInUserSession() || !palette_delegate->ShouldShowPalette()) | 413 if (!IsInUserSession() || !palette_delegate->ShouldShowPalette()) |
| 421 return; | 414 return; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 442 } else { | 435 } else { |
| 443 UpdateIconVisibility(); | 436 UpdateIconVisibility(); |
| 444 } | 437 } |
| 445 } | 438 } |
| 446 | 439 |
| 447 void PaletteTray::UpdateIconVisibility() { | 440 void PaletteTray::UpdateIconVisibility() { |
| 448 SetVisible(IsInUserSession()); | 441 SetVisible(IsInUserSession()); |
| 449 } | 442 } |
| 450 | 443 |
| 451 } // namespace ash | 444 } // namespace ash |
| OLD | NEW |