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

Side by Side Diff: ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc

Issue 2147143002: [Chrome OS MD] Draw a 1px separator between 2 tray items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new approach Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/virtual_keyboard/virtual_keyboard_tray.h" 5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/keyboard/keyboard_ui.h" 9 #include "ash/common/keyboard/keyboard_ui.h"
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
11 #include "ash/common/shelf/shelf_constants.h" 11 #include "ash/common/shelf/shelf_constants.h"
12 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shelf/wm_shelf_util.h" 13 #include "ash/common/shelf/wm_shelf_util.h"
14 #include "ash/common/system/chromeos/session/logout_button_tray.h"
13 #include "ash/common/system/tray/tray_constants.h" 15 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_utils.h" 16 #include "ash/common/system/tray/tray_utils.h"
17 #include "ash/common/system/view_observer.h"
15 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
16 #include "grit/ash_resources.h" 19 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 20 #include "grit/ash_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/events/event.h" 23 #include "ui/events/event.h"
21 #include "ui/gfx/image/image_skia.h" 24 #include "ui/gfx/image/image_skia.h"
22 #include "ui/gfx/paint_vector_icon.h" 25 #include "ui/gfx/paint_vector_icon.h"
23 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
24 #include "ui/views/controls/button/image_button.h" 27 #include "ui/views/controls/button/image_button.h"
25 28
26 namespace ash { 29 namespace ash {
27 30
28 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf) 31 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf,
29 : TrayBackgroundView(wm_shelf), button_(nullptr) { 32 ViewObserver* view_observer)
33 : TrayBackgroundView(wm_shelf, view_observer), button_(nullptr) {
30 button_ = new views::ImageButton(this); 34 button_ = new views::ImageButton(this);
31 if (MaterialDesignController::IsShelfMaterial()) { 35 if (MaterialDesignController::IsShelfMaterial()) {
32 gfx::ImageSkia image_md = 36 gfx::ImageSkia image_md =
33 CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor); 37 CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor);
34 button_->SetImage(views::CustomButton::STATE_NORMAL, &image_md); 38 button_->SetImage(views::CustomButton::STATE_NORMAL, &image_md);
35 } else { 39 } else {
36 gfx::ImageSkia* image_non_md = 40 gfx::ImageSkia* image_non_md =
37 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 41 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
38 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); 42 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD);
39 button_->SetImage(views::CustomButton::STATE_NORMAL, image_non_md); 43 button_->SetImage(views::CustomButton::STATE_NORMAL, image_non_md);
(...skipping 10 matching lines...) Expand all
50 } 54 }
51 55
52 VirtualKeyboardTray::~VirtualKeyboardTray() { 56 VirtualKeyboardTray::~VirtualKeyboardTray() {
53 // The Shell may not exist in some unit tests. 57 // The Shell may not exist in some unit tests.
54 if (WmShell::HasInstance()) 58 if (WmShell::HasInstance())
55 WmShell::Get()->keyboard_ui()->RemoveObserver(this); 59 WmShell::Get()->keyboard_ui()->RemoveObserver(this);
56 } 60 }
57 61
58 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { 62 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
59 TrayBackgroundView::SetShelfAlignment(alignment); 63 TrayBackgroundView::SetShelfAlignment(alignment);
60 tray_container()->SetBorder(views::Border::NullBorder());
61 64
62 // Pad button size to align with other controls in the system tray. 65 // Pad button size to align with other controls in the system tray.
63 const gfx::ImageSkia image = 66 const gfx::ImageSkia image =
64 button_->GetImage(views::CustomButton::STATE_NORMAL); 67 button_->GetImage(views::CustomButton::STATE_NORMAL);
65 const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE); 68 const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE);
66 const int vertical_padding = (size - image.height()) / 2; 69 const int vertical_padding = (size - image.height()) / 2;
67 int horizontal_padding = (size - image.width()) / 2; 70 int horizontal_padding = (size - image.width()) / 2;
68 if (!ash::MaterialDesignController::IsShelfMaterial() && 71 if (!ash::MaterialDesignController::IsShelfMaterial() &&
69 IsHorizontalAlignment(alignment)) { 72 IsHorizontalAlignment(alignment)) {
70 // Square up the padding if horizontally aligned. Avoid extra padding when 73 // Square up the padding if horizontally aligned. Avoid extra padding when
(...skipping 25 matching lines...) Expand all
96 const ui::Event& event) { 99 const ui::Event& event) {
97 DCHECK_EQ(button_, sender); 100 DCHECK_EQ(button_, sender);
98 PerformAction(event); 101 PerformAction(event);
99 } 102 }
100 103
101 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { 104 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) {
102 SetVisible(WmShell::Get()->keyboard_ui()->IsEnabled()); 105 SetVisible(WmShell::Get()->keyboard_ui()->IsEnabled());
103 } 106 }
104 107
105 } // namespace ash 108 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698