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

Unified 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: Cleanup button sizing. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
diff --git a/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc b/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
index 63eadf15bd9cc6aeeabf12619078ceae386b492d..0a89b58f46f1d4c98c03a8761247dabaf954d35f 100644
--- a/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
+++ b/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
@@ -4,6 +4,7 @@
#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
+#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_constants.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
@@ -20,45 +21,26 @@
#include "ui/views/controls/button/image_button.h"
namespace ash {
-namespace {
-
-class VirtualKeyboardButton : public views::ImageButton {
- public:
- VirtualKeyboardButton(views::ButtonListener* listener);
- virtual ~VirtualKeyboardButton();
-
- // Overridden from views::ImageButton:
- virtual gfx::Size GetPreferredSize() const OVERRIDE;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardButton);
-};
-
-VirtualKeyboardButton::VirtualKeyboardButton(views::ButtonListener* listener)
- : views::ImageButton(listener) {
-}
-
-VirtualKeyboardButton::~VirtualKeyboardButton() {
-}
-
-gfx::Size VirtualKeyboardButton::GetPreferredSize() const {
- const int virtual_keyboard_button_height = kShelfSize;
- gfx::Size size = ImageButton::GetPreferredSize();
- int padding = virtual_keyboard_button_height - size.height();
- size.set_height(virtual_keyboard_button_height);
- size.set_width(size.width() + padding);
- return size;
-}
-
-} // namespace
VirtualKeyboardTray::VirtualKeyboardTray(StatusAreaWidget* status_area_widget)
: TrayBackgroundView(status_area_widget),
button_(NULL) {
- button_ = new VirtualKeyboardButton(this);
+ button_ = new views::ImageButton(this);
button_->SetImage(views::CustomButton::STATE_NORMAL,
ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD));
+
+ gfx::Size size = button_->GetPreferredSize();
+ int top_padding = (kTrayBarButtonWidth - size.height()) / 2;
+ int left_padding = (kTrayBarButtonWidth - size.width()) / 2;
+ int bottom_padding = kTrayBarButtonWidth - size.height() - top_padding;
+ int right_padding = kTrayBarButtonWidth - size.width() - left_padding;
+ button_->SetBorder(views::Border::CreateEmptyBorder(
+ top_padding,
+ left_padding,
+ bottom_padding,
+ right_padding));
+
button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
@@ -81,7 +63,16 @@ VirtualKeyboardTray::~VirtualKeyboardTray() {
void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
TrayBackgroundView::SetShelfAlignment(alignment);
- tray_container()->SetBorder(views::Border::NullBorder());
+ int horizontal_padding = 0;
+ // Square up the padding if horizontally aligned. Cannot afford extra padding
+ // when vertically aligned as the button would violate the width constraint on
+ // the shelf.
+ if (alignment == SHELF_ALIGNMENT_BOTTOM || alignment == SHELF_ALIGNMENT_TOP) {
+ gfx::Insets insets = button_->GetInsets();
+ horizontal_padding = std::max(0, insets.top() - insets.left());
+ }
+ tray_container()->SetBorder(views::Border::CreateEmptyBorder(0,
sadrul 2014/08/01 19:49:49 I think you want to SetBorder on button_, and not
kevers 2014/08/05 14:47:18 Done.
+ horizontal_padding, 0, horizontal_padding));
}
base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() {
« 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