OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/launcher/launcher_button.h" | 5 #include "ash/launcher/launcher_button.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher_button_host.h" | 9 #include "ash/launcher/launcher_button_host.h" |
10 #include "grit/ash_resources.h" | 10 #include "grit/ash_resources.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 void LauncherButton::OnFocus() { | 297 void LauncherButton::OnFocus() { |
298 AddState(STATE_FOCUSED); | 298 AddState(STATE_FOCUSED); |
299 CustomButton::OnFocus(); | 299 CustomButton::OnFocus(); |
300 } | 300 } |
301 | 301 |
302 void LauncherButton::OnBlur() { | 302 void LauncherButton::OnBlur() { |
303 ClearState(STATE_FOCUSED); | 303 ClearState(STATE_FOCUSED); |
304 CustomButton::OnBlur(); | 304 CustomButton::OnBlur(); |
305 } | 305 } |
306 | 306 |
307 ui::EventResult LauncherButton::OnGestureEvent(ui::GestureEvent* event) { | 307 void LauncherButton::OnGestureEvent(ui::GestureEvent* event) { |
308 switch (event->type()) { | 308 switch (event->type()) { |
309 case ui::ET_GESTURE_TAP_DOWN: | 309 case ui::ET_GESTURE_TAP_DOWN: |
310 AddState(STATE_HOVERED); | 310 AddState(STATE_HOVERED); |
311 return CustomButton::OnGestureEvent(event); | 311 return CustomButton::OnGestureEvent(event); |
312 case ui::ET_GESTURE_END: | 312 case ui::ET_GESTURE_END: |
313 ClearState(STATE_HOVERED); | 313 ClearState(STATE_HOVERED); |
314 return CustomButton::OnGestureEvent(event); | 314 return CustomButton::OnGestureEvent(event); |
315 case ui::ET_GESTURE_SCROLL_BEGIN: | 315 case ui::ET_GESTURE_SCROLL_BEGIN: |
316 host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event); | 316 host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event); |
317 return ui::ER_CONSUMED; | 317 event->SetHandled(); |
| 318 return; |
318 case ui::ET_GESTURE_SCROLL_UPDATE: | 319 case ui::ET_GESTURE_SCROLL_UPDATE: |
319 host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event); | 320 host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event); |
320 return ui::ER_CONSUMED; | 321 event->SetHandled(); |
| 322 return; |
321 case ui::ET_GESTURE_SCROLL_END: | 323 case ui::ET_GESTURE_SCROLL_END: |
322 case ui::ET_SCROLL_FLING_START: | 324 case ui::ET_SCROLL_FLING_START: |
323 host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false); | 325 host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false); |
324 return ui::ER_CONSUMED; | 326 event->SetHandled(); |
| 327 return; |
325 default: | 328 default: |
326 return CustomButton::OnGestureEvent(event); | 329 return CustomButton::OnGestureEvent(event); |
327 } | 330 } |
328 } | 331 } |
329 | 332 |
330 void LauncherButton::Init() { | 333 void LauncherButton::Init() { |
331 icon_view_ = CreateIconView(); | 334 icon_view_ = CreateIconView(); |
332 | 335 |
333 // TODO: refactor the layers so each button doesn't require 2. | 336 // TODO: refactor the layers so each button doesn't require 2. |
334 icon_view_->SetPaintToLayer(true); | 337 icon_view_->SetPaintToLayer(true); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 bar_->SetVerticalAlignment(views::ImageView::CENTER); | 394 bar_->SetVerticalAlignment(views::ImageView::CENTER); |
392 break; | 395 break; |
393 } | 396 } |
394 | 397 |
395 Layout(); | 398 Layout(); |
396 SchedulePaint(); | 399 SchedulePaint(); |
397 } | 400 } |
398 | 401 |
399 } // namespace internal | 402 } // namespace internal |
400 } // namespace ash | 403 } // namespace ash |
OLD | NEW |