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

Unified Diff: ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc

Issue 2099103002: Give Ash material design tray items the correct size and layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split shelf and tray constants Created 4 years, 6 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 | « ash/system/chromeos/session/logout_button_tray.cc ('k') | ash/system/overview/overview_button_tray.cc » ('j') | 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 38e35fdc878e096366a3ccb0948c81460d45a943..55e884c1a8616bfffee6bc47daa26794bc7290cf 100644
--- a/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
+++ b/ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
@@ -60,22 +60,19 @@ void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
// Pad button size to align with other controls in the system tray.
const gfx::ImageSkia image =
button_->GetImage(views::CustomButton::STATE_NORMAL);
- int top_padding = (kTrayBarButtonWidth - image.height()) / 2;
- int left_padding = (kTrayBarButtonWidth - image.width()) / 2;
- int bottom_padding = kTrayBarButtonWidth - image.height() - top_padding;
- int right_padding = kTrayBarButtonWidth - image.width() - left_padding;
-
- // Square up the padding if horizontally aligned. Avoid extra padding when
- // vertically aligned as the button would violate the width constraint on the
- // shelf.
- if (IsHorizontalAlignment(alignment)) {
- int additional_padding = std::max(0, top_padding - left_padding);
- left_padding += additional_padding;
- right_padding += additional_padding;
+ const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE);
+ const int vertical_padding = (size - image.height()) / 2;
+ int horizontal_padding = (size - image.width()) / 2;
+ if (!ash::MaterialDesignController::IsShelfMaterial() &&
+ IsHorizontalAlignment(alignment)) {
+ // Square up the padding if horizontally aligned. Avoid extra padding when
+ // vertically aligned as the button would violate the width constraint on
+ // the shelf.
+ horizontal_padding += std::max(0, vertical_padding - horizontal_padding);
}
button_->SetBorder(views::Border::CreateEmptyBorder(
- top_padding, left_padding, bottom_padding, right_padding));
+ gfx::Insets(vertical_padding, horizontal_padding)));
}
base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() {
« no previous file with comments | « ash/system/chromeos/session/logout_button_tray.cc ('k') | ash/system/overview/overview_button_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698