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

Side by Side Diff: ash/system/lock_screen_action/lock_screen_action_tray.cc

Issue 2956383002: Fixup icon for new lock screen note action item (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « ash/system/lock_screen_action/lock_screen_action_tray.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/system/lock_screen_action/lock_screen_action_tray.h" 5 #include "ash/system/lock_screen_action/lock_screen_action_tray.h"
6 6
7 #include "ash/resources/vector_icons/vector_icons.h" 7 #include "ash/resources/vector_icons/vector_icons.h"
8 #include "ash/session/session_controller.h" 8 #include "ash/session/session_controller.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/strings/grit/ash_strings.h" 11 #include "ash/strings/grit/ash_strings.h"
12 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
13 #include "ash/system/tray/tray_container.h" 13 #include "ash/system/tray/tray_container.h"
14 #include "ash/tray_action/tray_action.h" 14 #include "ash/tray_action/tray_action.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
18 #include "ui/gfx/paint_vector_icon.h" 18 #include "ui/gfx/paint_vector_icon.h"
19 #include "ui/views/controls/image_view.h" 19 #include "ui/views/controls/image_view.h"
20 #include "ui/views/layout/fill_layout.h" 20 #include "ui/views/layout/fill_layout.h"
21 21
22 namespace ash { 22 namespace ash {
23 23
24 namespace {
25
26 // The preferred size for the tray item view.
27 const int kItemViewPreferredSize = 32;
28
29 } // namespace
30
31 // View for the tray item for the lock screen note creation action.
32 class LockScreenActionTray::NewNoteActionView : public views::View {
33 public:
34 NewNoteActionView() {
35 SetLayoutManager(new views::FillLayout);
36 icon_ = new views::ImageView();
37 icon_->SetImage(CreateVectorIcon(kPaletteActionCreateNoteIcon,
38 kTrayIconSize, kShelfIconColor));
39 icon_->SetTooltipText(
40 l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION));
41 AddChildView(icon_);
42 }
43
44 ~NewNoteActionView() override {}
45
46 gfx::Size CalculatePreferredSize() const override {
47 return gfx::Size(kItemViewPreferredSize, kItemViewPreferredSize);
48 }
49
50 const gfx::ImageSkia& GetImage() const { return icon_->GetImage(); }
51
52 private:
53 views::ImageView* icon_;
54
55 DISALLOW_COPY_AND_ASSIGN(NewNoteActionView);
56 };
57
58 LockScreenActionTray::LockScreenActionTray(Shelf* shelf) 24 LockScreenActionTray::LockScreenActionTray(Shelf* shelf)
59 : TrayBackgroundView(shelf), 25 : TrayBackgroundView(shelf),
60 session_observer_(this), 26 session_observer_(this),
61 tray_action_observer_(this) { 27 tray_action_observer_(this) {
62 SetInkDropMode(InkDropMode::ON); 28 SetInkDropMode(InkDropMode::ON);
63 SetVisible(false); 29 SetVisible(false);
64 new_note_action_view_ = new NewNoteActionView(); 30 new_note_action_view_ = new views::ImageView();
31 new_note_action_view_->SetImage(CreateVectorIcon(
32 kTrayActionNewLockScreenNoteIcon, kTrayIconSize, kShelfIconColor));
tdanderson 2017/06/28 20:45:23 nit: you can omit the kTrayIconSize argument since
tbarzic 2017/06/28 21:00:07 Done.
33 new_note_action_view_->SetTooltipText(
34 l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION));
35 new_note_action_view_->SetPreferredSize(
36 gfx::Size(kTrayItemSize, kTrayItemSize));
65 tray_container()->AddChildView(new_note_action_view_); 37 tray_container()->AddChildView(new_note_action_view_);
66 } 38 }
67 39
68 LockScreenActionTray::~LockScreenActionTray() {} 40 LockScreenActionTray::~LockScreenActionTray() {}
69 41
70 void LockScreenActionTray::Initialize() { 42 void LockScreenActionTray::Initialize() {
71 TrayBackgroundView::Initialize(); 43 TrayBackgroundView::Initialize();
72 44
73 session_observer_.Add(Shell::Get()->session_controller()); 45 session_observer_.Add(Shell::Get()->session_controller());
74 46
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 mojom::TrayActionState::kLaunching); 99 mojom::TrayActionState::kLaunching);
128 100
129 SetVisible(true); 101 SetVisible(true);
130 } 102 }
131 103
132 const gfx::ImageSkia& LockScreenActionTray::GetImageForTesting() const { 104 const gfx::ImageSkia& LockScreenActionTray::GetImageForTesting() const {
133 return new_note_action_view_->GetImage(); 105 return new_note_action_view_->GetImage();
134 } 106 }
135 107
136 } // namespace ash 108 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/lock_screen_action/lock_screen_action_tray.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698