Skip to content

Commit

Permalink
Add ink drop ripples to some "square" buttons on shelf
Browse files Browse the repository at this point in the history
Added ink drop ripple to following buttons:
 - ImeMenuTray;
 - PaletteTray;
 - VirtualKeyboardTray;
 - WebNotificationTray.

For the WebNotificationTray it is still not handling size changes.

BUG=612579,643306,644735
TEST=manually run Ash with --ash-md=experimental

Review-Url: https://codereview.chromium.org/2512493002
Cr-Commit-Position: refs/heads/master@{#432687}
  • Loading branch information
mohsen authored and Commit bot committed Nov 17, 2016
1 parent bf7f53d commit 2ee91ab
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 14 deletions.
7 changes: 6 additions & 1 deletion ash/common/system/chromeos/ime_menu/ime_menu_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,14 @@ ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf)
show_keyboard_(false),
force_show_keyboard_(false),
should_block_shelf_auto_hide_(false) {
if (MaterialDesignController::IsShelfMaterial()) {
SetInkDropMode(InkDropMode::ON);
SetContentsBackground(false);
} else {
SetContentsBackground(true);
}
SetupLabelForTray(label_);
tray_container()->AddChildView(label_);
SetContentsBackground(true);
WmShell::Get()->system_tray_notifier()->AddIMEObserver(this);
}

Expand Down
8 changes: 7 additions & 1 deletion ash/common/system/chromeos/palette/palette_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/common/system/chromeos/palette/palette_tray.h"

#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/session/session_state_delegate.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/wm_shelf.h"
Expand Down Expand Up @@ -162,7 +163,12 @@ PaletteTray::PaletteTray(WmShelf* wm_shelf)

PaletteTool::RegisterToolInstances(palette_tool_manager_.get());

SetContentsBackground(true);
if (MaterialDesignController::IsShelfMaterial()) {
SetInkDropMode(InkDropMode::ON);
SetContentsBackground(false);
} else {
SetContentsBackground(true);
}

SetLayoutManager(new views::FillLayout());
icon_ = new views::ImageView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ namespace ash {
VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf)
: TrayBackgroundView(wm_shelf), icon_(new views::ImageView) {
if (MaterialDesignController::IsShelfMaterial()) {
SetInkDropMode(InkDropMode::ON);
SetContentsBackground(false);
gfx::ImageSkia image_md =
CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor);
icon_->SetImage(image_md);
} else {
SetContentsBackground(true);
gfx::ImageSkia* image_non_md =
ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD);
Expand All @@ -41,7 +44,6 @@ VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf)

SetIconBorderForShelfAlignment();
tray_container()->AddChildView(icon_);
SetContentsBackground(true);
// The Shell may not exist in some unit tests.
if (WmShell::HasInstance())
WmShell::Get()->keyboard_ui()->AddObserver(this);
Expand Down Expand Up @@ -77,6 +79,12 @@ void VirtualKeyboardTray::ClickedOutsideBubble() {}

bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
WmShell::Get()->keyboard_ui()->Show();
// Normally, active status is set when virtual keyboard is shown/hidden,
// however, showing virtual keyboard happens asynchronously and, especially
// the first time, takes some time. We need to set active status here to
// prevent bad things happening if user clicked the button before keyboard is
// shown.
SetIsActive(true);
return true;
}

Expand Down
28 changes: 17 additions & 11 deletions ash/common/system/web_notification/web_notification_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,28 @@ WebNotificationTray::WebNotificationTray(WmShelf* shelf,
DCHECK(status_area_window_);
DCHECK(system_tray_);

const bool md_shelf = MaterialDesignController::IsShelfMaterial();
gfx::ImageSkia bell_image =
md_shelf
? CreateVectorIcon(kShelfNotificationsIcon, kShelfIconColor)
: CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS,
kNoUnreadIconSize, kWebNotificationColorNoUnread);
const gfx::Size bell_icon_size =
md_shelf ? kTrayItemInnerIconSize : kTrayItemInnerBellIconSizeNonMd;
bell_icon_.reset(new WebNotificationImage(bell_image, bell_icon_size,
animation_container_.get(), this));
if (MaterialDesignController::IsShelfMaterial()) {
SetInkDropMode(InkDropMode::ON);
SetContentsBackground(false);
gfx::ImageSkia bell_image =
CreateVectorIcon(kShelfNotificationsIcon, kShelfIconColor);
const gfx::Size bell_icon_size = kTrayItemInnerIconSize;
bell_icon_.reset(new WebNotificationImage(
bell_image, bell_icon_size, animation_container_.get(), this));
} else {
SetContentsBackground(true);
gfx::ImageSkia bell_image =
CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS, kNoUnreadIconSize,
kWebNotificationColorNoUnread);
const gfx::Size bell_icon_size = kTrayItemInnerBellIconSizeNonMd;
bell_icon_.reset(new WebNotificationImage(
bell_image, bell_icon_size, animation_container_.get(), this));
}
tray_container()->AddChildView(bell_icon_.get());

counter_.reset(new WebNotificationLabel(animation_container_.get(), this));
tray_container()->AddChildView(counter_.get());

SetContentsBackground(true);
message_center_tray_.reset(new message_center::MessageCenterTray(
this, message_center::MessageCenter::Get()));
popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf));
Expand Down
9 changes: 9 additions & 0 deletions ash/system/web_notification/web_notification_tray_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <utility>
#include <vector>

#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/shelf/shelf_layout_manager.h"
#include "ash/common/shelf/wm_shelf.h"
#include "ash/common/system/status_area_widget.h"
Expand Down Expand Up @@ -472,6 +473,10 @@ TEST_P(WebNotificationTrayTest, PopupAndSystemTrayMultiDisplay) {

// Tests that there is visual feedback for touch presses.
TEST_P(WebNotificationTrayTest, TouchFeedback) {
// Touch feedback is not available in material mode.
if (MaterialDesignController::IsShelfMaterial())
return;

AddNotification("test_id");
RunAllPendingInMessageLoop();
WebNotificationTray* tray = GetTray();
Expand All @@ -496,6 +501,10 @@ TEST_P(WebNotificationTrayTest, TouchFeedback) {
// Tests that while touch presses trigger visual feedback, that subsequent non
// tap gestures cancel the feedback without triggering the message center.
TEST_P(WebNotificationTrayTest, TouchFeedbackCancellation) {
// Touch feedback is not available in material mode.
if (MaterialDesignController::IsShelfMaterial())
return;

AddNotification("test_id");
RunAllPendingInMessageLoop();
WebNotificationTray* tray = GetTray();
Expand Down

0 comments on commit 2ee91ab

Please sign in to comment.