| 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/keyboard/keyboard_ui.h" | 7 #include "ash/keyboard/keyboard_ui.h" |
| 8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 9 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
| 10 #include "ash/shelf/shelf_util.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/system/status_area_widget.h" | 12 #include "ash/system/status_area_widget.h" |
| 12 #include "ash/system/tray/system_tray_notifier.h" | 13 #include "ash/system/tray/system_tray_notifier.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 14 #include "ash/system/tray/tray_constants.h" |
| 14 #include "ash/system/tray/tray_utils.h" | 15 #include "ash/system/tray/tray_utils.h" |
| 15 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 16 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 const gfx::ImageSkia image = button_->GetImage( | 54 const gfx::ImageSkia image = button_->GetImage( |
| 54 views::CustomButton::STATE_NORMAL); | 55 views::CustomButton::STATE_NORMAL); |
| 55 int top_padding = (kTrayBarButtonWidth - image.height()) / 2; | 56 int top_padding = (kTrayBarButtonWidth - image.height()) / 2; |
| 56 int left_padding = (kTrayBarButtonWidth - image.width()) / 2; | 57 int left_padding = (kTrayBarButtonWidth - image.width()) / 2; |
| 57 int bottom_padding = kTrayBarButtonWidth - image.height() - top_padding; | 58 int bottom_padding = kTrayBarButtonWidth - image.height() - top_padding; |
| 58 int right_padding = kTrayBarButtonWidth - image.width() - left_padding; | 59 int right_padding = kTrayBarButtonWidth - image.width() - left_padding; |
| 59 | 60 |
| 60 // Square up the padding if horizontally aligned. Avoid extra padding when | 61 // Square up the padding if horizontally aligned. Avoid extra padding when |
| 61 // vertically aligned as the button would violate the width constraint on the | 62 // vertically aligned as the button would violate the width constraint on the |
| 62 // shelf. | 63 // shelf. |
| 63 if (alignment == SHELF_ALIGNMENT_BOTTOM) { | 64 if (IsHorizontalAlignment(alignment)) { |
| 64 gfx::Insets insets = button_->GetInsets(); | 65 gfx::Insets insets = button_->GetInsets(); |
| 65 int additional_padding = std::max(0, top_padding - left_padding); | 66 int additional_padding = std::max(0, top_padding - left_padding); |
| 66 left_padding += additional_padding; | 67 left_padding += additional_padding; |
| 67 right_padding += additional_padding; | 68 right_padding += additional_padding; |
| 68 } | 69 } |
| 69 | 70 |
| 70 button_->SetBorder(views::Border::CreateEmptyBorder( | 71 button_->SetBorder(views::Border::CreateEmptyBorder( |
| 71 top_padding, | 72 top_padding, |
| 72 left_padding, | 73 left_padding, |
| 73 bottom_padding, | 74 bottom_padding, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 const ui::Event& event) { | 97 const ui::Event& event) { |
| 97 DCHECK_EQ(button_, sender); | 98 DCHECK_EQ(button_, sender); |
| 98 PerformAction(event); | 99 PerformAction(event); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { | 102 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { |
| 102 SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled()); | 103 SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled()); |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace ash | 106 } // namespace ash |
| OLD | NEW |