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

Unified Diff: ash/shelf/app_list_button.cc

Issue 558703002: AppLauncher Touch Feedback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/shelf/app_list_button.cc
diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
index 9ba833254e3e93274058c2a435da2d5ae3e24790..d13a0de9dccd6f3db012c114b7ec5c320ae7ee3f 100644
--- a/ash/shelf/app_list_button.cc
+++ b/ash/shelf/app_list_button.cc
@@ -12,6 +12,7 @@
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
+#include "base/command_line.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/accessibility/ax_view_state.h"
@@ -35,12 +36,19 @@ AppListButton::AppListButton(views::ButtonListener* listener,
ShelfButtonHost* host,
ShelfWidget* shelf_widget)
: views::ImageButton(listener),
+ set_draw_background_as_active_(false),
+ touch_feedback_enabled_(false),
host_(host),
shelf_widget_(shelf_widget) {
SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE));
SetSize(gfx::Size(kShelfSize, kShelfSize));
SetFocusPainter(views::Painter::CreateSolidFocusPainter(
kFocusBorderColor, gfx::Insets(1, 1, 1, 1)));
+
+ if (CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) {
+ touch_feedback_enabled_ = true;
+ }
}
AppListButton::~AppListButton() {
@@ -86,6 +94,7 @@ void AppListButton::OnMouseExited(const ui::MouseEvent& event) {
void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) {
case ui::ET_GESTURE_SCROLL_BEGIN:
+ SetDrawBackgroundAsActive(false);
host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event);
event->SetHandled();
return;
@@ -98,6 +107,15 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false);
event->SetHandled();
return;
+ case ui::ET_GESTURE_TAP_DOWN:
+ SetDrawBackgroundAsActive(true);
+ ImageButton::OnGestureEvent(event);
+ break;
+ case ui::ET_GESTURE_TAP_CANCEL:
+ case ui::ET_GESTURE_TAP:
+ SetDrawBackgroundAsActive(false);
+ ImageButton::OnGestureEvent(event);
+ break;
default:
ImageButton::OnGestureEvent(event);
return;
@@ -109,7 +127,8 @@ void AppListButton::OnPaint(gfx::Canvas* canvas) {
View::OnPaint(canvas);
int background_image_id = 0;
- if (Shell::GetInstance()->GetAppListTargetVisibility()) {
+ if (Shell::GetInstance()->GetAppListTargetVisibility() ||
+ set_draw_background_as_active_) {
background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
} else {
if (shelf_widget_->GetDimsShelf())
@@ -166,4 +185,14 @@ void AppListButton::GetAccessibleState(ui::AXViewState* state) {
state->name = host_->GetAccessibleName(this);
}
+void AppListButton::SetDrawBackgroundAsActive(
+ bool set_draw_background_as_active) {
+ if (!touch_feedback_enabled_)
flackr 2014/09/10 20:04:41 nit: A little confusing that calling SetDrawBackgr
jonross 2014/09/11 15:06:52 Since we want to eventually eliminate the flag I'v
+ return;
+ if (set_draw_background_as_active_ == set_draw_background_as_active)
+ return;
+ set_draw_background_as_active_ = set_draw_background_as_active;
+ SchedulePaint();
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698