Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / ash / shelf / app_list_button.cc
index 9ba8332..cc379c5 100644 (file)
@@ -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,6 +36,9 @@ AppListButton::AppListButton(views::ButtonListener* listener,
                              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));
@@ -86,6 +90,8 @@ void AppListButton::OnMouseExited(const ui::MouseEvent& event) {
 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;
@@ -98,6 +104,17 @@ void AppListButton::OnGestureEvent(ui::GestureEvent* event) {
      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;
@@ -109,7 +126,8 @@ void AppListButton::OnPaint(gfx::Canvas* canvas) {
   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())
@@ -166,4 +184,12 @@ void AppListButton::GetAccessibleState(ui::AXViewState* state) {
   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