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

Side by Side Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: fix cros build Created 3 years, 9 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 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"
(...skipping 15 matching lines...) Expand all
26 #include "ash/root_window_controller.h" 26 #include "ash/root_window_controller.h"
27 #include "ash/strings/grit/ash_strings.h" 27 #include "ash/strings/grit/ash_strings.h"
28 #include "base/metrics/histogram_macros.h" 28 #include "base/metrics/histogram_macros.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/events/devices/input_device_manager.h" 31 #include "ui/events/devices/input_device_manager.h"
32 #include "ui/events/devices/stylus_state.h" 32 #include "ui/events/devices/stylus_state.h"
33 #include "ui/gfx/color_palette.h" 33 #include "ui/gfx/color_palette.h"
34 #include "ui/gfx/paint_vector_icon.h" 34 #include "ui/gfx/paint_vector_icon.h"
35 #include "ui/gfx/vector_icons_public.h" 35 #include "ui/gfx/vector_icons_public.h"
36 #include "ui/views/controls/button/image_button.h"
36 #include "ui/views/controls/image_view.h" 37 #include "ui/views/controls/image_view.h"
37 #include "ui/views/controls/label.h" 38 #include "ui/views/controls/label.h"
38 #include "ui/views/controls/separator.h" 39 #include "ui/views/controls/separator.h"
39 #include "ui/views/layout/box_layout.h" 40 #include "ui/views/layout/box_layout.h"
40 #include "ui/views/layout/fill_layout.h" 41 #include "ui/views/layout/fill_layout.h"
41 42
42 namespace ash { 43 namespace ash {
43 44
44 namespace { 45 namespace {
45 46
(...skipping 19 matching lines...) Expand all
65 bool IsInUserSession() { 66 bool IsInUserSession() {
66 SessionStateDelegate* session_state_delegate = 67 SessionStateDelegate* session_state_delegate =
67 WmShell::Get()->GetSessionStateDelegate(); 68 WmShell::Get()->GetSessionStateDelegate();
68 return !session_state_delegate->IsUserSessionBlocked() && 69 return !session_state_delegate->IsUserSessionBlocked() &&
69 session_state_delegate->GetSessionState() == 70 session_state_delegate->GetSessionState() ==
70 session_manager::SessionState::ACTIVE && 71 session_manager::SessionState::ACTIVE &&
71 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != 72 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
72 LoginStatus::KIOSK_APP; 73 LoginStatus::KIOSK_APP;
73 } 74 }
74 75
75 class TitleView : public views::View, public views::ButtonListener { 76 class TitleView : public views::View, public views::ImageButtonDelegate {
76 public: 77 public:
77 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { 78 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
78 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. 79 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title.
79 // See crbug.com/614453. 80 // See crbug.com/614453.
80 auto* box_layout = 81 auto* box_layout =
81 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 82 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
82 SetLayoutManager(box_layout); 83 SetLayoutManager(box_layout);
83 84
84 auto* title_label = 85 auto* title_label =
85 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); 86 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE));
(...skipping 28 matching lines...) Expand all
114 settings_button_ = settings_button; 115 settings_button_ = settings_button;
115 } 116 }
116 117
117 AddChildView(help_button_); 118 AddChildView(help_button_);
118 AddChildView(settings_button_); 119 AddChildView(settings_button_);
119 } 120 }
120 121
121 ~TitleView() override {} 122 ~TitleView() override {}
122 123
123 private: 124 private:
124 // views::ButtonListener: 125 // views::ImageButtonDelegate:
125 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 126 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
126 if (sender == settings_button_) { 127 if (sender == settings_button_) {
127 palette_tray_->RecordPaletteOptionsUsage( 128 palette_tray_->RecordPaletteOptionsUsage(
128 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON); 129 PaletteTrayOptions::PALETTE_SETTINGS_BUTTON);
129 WmShell::Get()->system_tray_controller()->ShowPaletteSettings(); 130 WmShell::Get()->system_tray_controller()->ShowPaletteSettings();
130 palette_tray_->HidePalette(); 131 palette_tray_->HidePalette();
131 } else if (sender == help_button_) { 132 } else if (sender == help_button_) {
132 palette_tray_->RecordPaletteOptionsUsage( 133 palette_tray_->RecordPaletteOptionsUsage(
133 PaletteTrayOptions::PALETTE_HELP_BUTTON); 134 PaletteTrayOptions::PALETTE_HELP_BUTTON);
134 WmShell::Get()->system_tray_controller()->ShowPaletteHelp(); 135 WmShell::Get()->system_tray_controller()->ShowPaletteHelp();
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 UpdateIconVisibility(); 429 UpdateIconVisibility();
429 } 430 }
430 } 431 }
431 432
432 void PaletteTray::UpdateIconVisibility() { 433 void PaletteTray::UpdateIconVisibility() {
433 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && 434 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() &&
434 IsInUserSession()); 435 IsInUserSession());
435 } 436 }
436 437
437 } // namespace ash 438 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698