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

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

Issue 2147143002: [Chrome OS MD] Draw a 1px separator between 2 tray items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
diff --git a/ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc b/ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
index 39eae983dde818d98b91a90c9c0b57ac2322b111..54c2f2febe2ab109b3e3cd9d36d11163155c533b 100644
--- a/ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
+++ b/ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc
@@ -9,7 +9,10 @@
#include "ash/common/keyboard/keyboard_ui.h"
#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/shelf/shelf_constants.h"
+#include "ash/common/shelf/wm_shelf.h"
+#include "ash/common/shelf/wm_shelf_observer.h"
#include "ash/common/shelf/wm_shelf_util.h"
+#include "ash/common/system/chromeos/session/logout_button_tray.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_utils.h"
#include "ash/common/wm_shell.h"
@@ -26,8 +29,10 @@
namespace ash {
-VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf)
- : TrayBackgroundView(wm_shelf), icon_(new views::ImageView) {
+VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf,
+ WmShelfObserver* wm_shelf_observer)
+ : TrayBackgroundView(wm_shelf, wm_shelf_observer),
+ icon_(new views::ImageView) {
if (MaterialDesignController::IsShelfMaterial()) {
gfx::ImageSkia image_md =
CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor);
@@ -61,6 +66,19 @@ void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
if (alignment == shelf_alignment())
return;
+ // Pad button size to align with other controls in the system tray.
+ const gfx::ImageSkia image = icon_->GetImage();
+ 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);
+ }
+
TrayBackgroundView::SetShelfAlignment(alignment);
SetIconBorderForShelfAlignment();
}

Powered by Google App Engine
This is Rietveld 408576698