| OLD | NEW |
| 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/common/keyboard/keyboard_ui.h" | 7 #include "ash/common/keyboard/keyboard_ui.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // The Shell may not exist in some unit tests. | 54 // The Shell may not exist in some unit tests. |
| 55 if (Shell::HasInstance()) | 55 if (Shell::HasInstance()) |
| 56 Shell::GetInstance()->keyboard_ui()->RemoveObserver(this); | 56 Shell::GetInstance()->keyboard_ui()->RemoveObserver(this); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { | 59 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 60 TrayBackgroundView::SetShelfAlignment(alignment); | 60 TrayBackgroundView::SetShelfAlignment(alignment); |
| 61 tray_container()->SetBorder(views::Border::NullBorder()); | 61 tray_container()->SetBorder(views::Border::NullBorder()); |
| 62 | 62 |
| 63 // Pad button size to align with other controls in the system tray. | 63 // Pad button size to align with other controls in the system tray. |
| 64 const gfx::ImageSkia image = button_->GetImage( | 64 const gfx::ImageSkia image = |
| 65 views::CustomButton::STATE_NORMAL); | 65 button_->GetImage(views::CustomButton::STATE_NORMAL); |
| 66 int top_padding = (kTrayBarButtonWidth - image.height()) / 2; | 66 int top_padding = (kTrayBarButtonWidth - image.height()) / 2; |
| 67 int left_padding = (kTrayBarButtonWidth - image.width()) / 2; | 67 int left_padding = (kTrayBarButtonWidth - image.width()) / 2; |
| 68 int bottom_padding = kTrayBarButtonWidth - image.height() - top_padding; | 68 int bottom_padding = kTrayBarButtonWidth - image.height() - top_padding; |
| 69 int right_padding = kTrayBarButtonWidth - image.width() - left_padding; | 69 int right_padding = kTrayBarButtonWidth - image.width() - left_padding; |
| 70 | 70 |
| 71 // Square up the padding if horizontally aligned. Avoid extra padding when | 71 // Square up the padding if horizontally aligned. Avoid extra padding when |
| 72 // vertically aligned as the button would violate the width constraint on the | 72 // vertically aligned as the button would violate the width constraint on the |
| 73 // shelf. | 73 // shelf. |
| 74 if (IsHorizontalAlignment(alignment)) { | 74 if (IsHorizontalAlignment(alignment)) { |
| 75 int additional_padding = std::max(0, top_padding - left_padding); | 75 int additional_padding = std::max(0, top_padding - left_padding); |
| 76 left_padding += additional_padding; | 76 left_padding += additional_padding; |
| 77 right_padding += additional_padding; | 77 right_padding += additional_padding; |
| 78 } | 78 } |
| 79 | 79 |
| 80 button_->SetBorder(views::Border::CreateEmptyBorder( | 80 button_->SetBorder(views::Border::CreateEmptyBorder( |
| 81 top_padding, | 81 top_padding, left_padding, bottom_padding, right_padding)); |
| 82 left_padding, | |
| 83 bottom_padding, | |
| 84 right_padding)); | |
| 85 } | 82 } |
| 86 | 83 |
| 87 base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() { | 84 base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() { |
| 88 return l10n_util::GetStringUTF16( | 85 return l10n_util::GetStringUTF16( |
| 89 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); | 86 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); |
| 90 } | 87 } |
| 91 | 88 |
| 92 void VirtualKeyboardTray::HideBubbleWithView( | 89 void VirtualKeyboardTray::HideBubbleWithView( |
| 93 const views::TrayBubbleView* bubble_view) { | 90 const views::TrayBubbleView* bubble_view) {} |
| 94 } | |
| 95 | 91 |
| 96 void VirtualKeyboardTray::ClickedOutsideBubble() {} | 92 void VirtualKeyboardTray::ClickedOutsideBubble() {} |
| 97 | 93 |
| 98 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { | 94 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { |
| 99 Shell::GetInstance()->keyboard_ui()->Show(); | 95 Shell::GetInstance()->keyboard_ui()->Show(); |
| 100 return true; | 96 return true; |
| 101 } | 97 } |
| 102 | 98 |
| 103 void VirtualKeyboardTray::ButtonPressed(views::Button* sender, | 99 void VirtualKeyboardTray::ButtonPressed(views::Button* sender, |
| 104 const ui::Event& event) { | 100 const ui::Event& event) { |
| 105 DCHECK_EQ(button_, sender); | 101 DCHECK_EQ(button_, sender); |
| 106 PerformAction(event); | 102 PerformAction(event); |
| 107 } | 103 } |
| 108 | 104 |
| 109 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { | 105 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { |
| 110 SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled()); | 106 SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled()); |
| 111 } | 107 } |
| 112 | 108 |
| 113 } // namespace ash | 109 } // namespace ash |
| OLD | NEW |