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

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

Issue 433483002: Fix padding of a11y keyboard indicator when shelf is vertically aligned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix formatting. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 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/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" 5 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
6 6
7 #include "ash/shelf/shelf.h"
7 #include "ash/shelf/shelf_constants.h" 8 #include "ash/shelf/shelf_constants.h"
8 #include "ash/shell.h" 9 #include "ash/shell.h"
9 #include "ash/system/status_area_widget.h" 10 #include "ash/system/status_area_widget.h"
10 #include "ash/system/tray/system_tray_notifier.h" 11 #include "ash/system/tray/system_tray_notifier.h"
11 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
12 #include "ash/system/tray/tray_utils.h" 13 #include "ash/system/tray/tray_utils.h"
13 #include "grit/ash_resources.h" 14 #include "grit/ash_resources.h"
14 #include "grit/ash_strings.h" 15 #include "grit/ash_strings.h"
15 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
(...skipping 20 matching lines...) Expand all
37 VirtualKeyboardButton::VirtualKeyboardButton(views::ButtonListener* listener) 38 VirtualKeyboardButton::VirtualKeyboardButton(views::ButtonListener* listener)
38 : views::ImageButton(listener) { 39 : views::ImageButton(listener) {
39 } 40 }
40 41
41 VirtualKeyboardButton::~VirtualKeyboardButton() { 42 VirtualKeyboardButton::~VirtualKeyboardButton() {
42 } 43 }
43 44
44 gfx::Size VirtualKeyboardButton::GetPreferredSize() const { 45 gfx::Size VirtualKeyboardButton::GetPreferredSize() const {
45 const int virtual_keyboard_button_height = kShelfSize; 46 const int virtual_keyboard_button_height = kShelfSize;
46 gfx::Size size = ImageButton::GetPreferredSize(); 47 gfx::Size size = ImageButton::GetPreferredSize();
47 int padding = virtual_keyboard_button_height - size.height(); 48 Shelf* shelf = Shelf::ForPrimaryDisplay();
49 bool is_horizontal = shelf && (shelf->alignment() == SHELF_ALIGNMENT_BOTTOM ||
50 shelf->alignment() == SHELF_ALIGNMENT_TOP);
51 int padding = is_horizontal ? virtual_keyboard_button_height - size.height() :
52 0;
48 size.set_height(virtual_keyboard_button_height); 53 size.set_height(virtual_keyboard_button_height);
49 size.set_width(size.width() + padding); 54 size.set_width(size.width() + padding);
50 return size; 55 return size;
51 } 56 }
52 57
53 } // namespace 58 } // namespace
54 59
55 VirtualKeyboardTray::VirtualKeyboardTray(StatusAreaWidget* status_area_widget) 60 VirtualKeyboardTray::VirtualKeyboardTray(StatusAreaWidget* status_area_widget)
56 : TrayBackgroundView(status_area_widget), 61 : TrayBackgroundView(status_area_widget),
57 button_(NULL) { 62 button_(NULL) {
58 button_ = new VirtualKeyboardButton(this); 63 button_ = new VirtualKeyboardButton(this);
59 button_->SetImage(views::CustomButton::STATE_NORMAL, 64 button_->SetImage(views::CustomButton::STATE_NORMAL,
60 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 65 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
61 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD)); 66 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD));
62 button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, 67 button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
63 views::ImageButton::ALIGN_MIDDLE); 68 views::ImageButton::ALIGN_MIDDLE);
sadrul 2014/08/01 15:29:17 As discussed offline: you should be able to do:
kevers 2014/08/01 18:44:00 Done.
64 69
65 tray_container()->AddChildView(button_); 70 tray_container()->AddChildView(button_);
66 SetContentsBackground(); 71 SetContentsBackground();
67 // The Shell may not exist in some unit tests. 72 // The Shell may not exist in some unit tests.
68 if (Shell::HasInstance()) { 73 if (Shell::HasInstance()) {
69 Shell::GetInstance()->system_tray_notifier()-> 74 Shell::GetInstance()->system_tray_notifier()->
70 AddAccessibilityObserver(this); 75 AddAccessibilityObserver(this);
71 } 76 }
72 } 77 }
73 78
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 PerformAction(event); 113 PerformAction(event);
109 } 114 }
110 115
111 void VirtualKeyboardTray::OnAccessibilityModeChanged( 116 void VirtualKeyboardTray::OnAccessibilityModeChanged(
112 AccessibilityNotificationVisibility notify) { 117 AccessibilityNotificationVisibility notify) {
113 SetVisible(Shell::GetInstance()->accessibility_delegate()-> 118 SetVisible(Shell::GetInstance()->accessibility_delegate()->
114 IsVirtualKeyboardEnabled()); 119 IsVirtualKeyboardEnabled());
115 } 120 }
116 121
117 } // namespace ash 122 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698