#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"
ShelfButtonHost* host,
ShelfWidget* shelf_widget)
: views::ImageButton(listener),
+ draw_background_as_active_(false),
+ touch_feedback_enabled_(CommandLine::ForCurrentProcess()->
+ HasSwitch(switches::kAshEnableTouchViewTouchFeedback)),
host_(host),
shelf_widget_(shelf_widget) {
SetAccessibleName(l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_TITLE));
void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) {
case ui::ET_GESTURE_SCROLL_BEGIN:
+ if (touch_feedback_enabled_)
+ SetDrawBackgroundAsActive(false);
host_->PointerPressedOnButton(this, ShelfButtonHost::TOUCH, *event);
event->SetHandled();
return;
host_->PointerReleasedOnButton(this, ShelfButtonHost::TOUCH, false);
event->SetHandled();
return;
+ case ui::ET_GESTURE_TAP_DOWN:
+ if (touch_feedback_enabled_)
+ SetDrawBackgroundAsActive(true);
+ ImageButton::OnGestureEvent(event);
+ break;
+ case ui::ET_GESTURE_TAP_CANCEL:
+ case ui::ET_GESTURE_TAP:
+ if (touch_feedback_enabled_)
+ SetDrawBackgroundAsActive(false);
+ ImageButton::OnGestureEvent(event);
+ break;
default:
ImageButton::OnGestureEvent(event);
return;
View::OnPaint(canvas);
int background_image_id = 0;
- if (Shell::GetInstance()->GetAppListTargetVisibility()) {
+ if (Shell::GetInstance()->GetAppListTargetVisibility() ||
+ draw_background_as_active_) {
background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED;
} else {
if (shelf_widget_->GetDimsShelf())
state->name = host_->GetAccessibleName(this);
}
+void AppListButton::SetDrawBackgroundAsActive(
+ bool draw_background_as_active) {
+ if (draw_background_as_active_ == draw_background_as_active)
+ return;
+ draw_background_as_active_ = draw_background_as_active;
+ SchedulePaint();
+}
+
} // namespace ash