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

Side by Side Diff: chrome/browser/android/vr_shell/ui_elements/button.cc

Issue 2966793002: NOT FOR REVIEW - convert to cc animation
Patch Set: switch to transform operations Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/android/vr_shell/ui_elements/button.h" 5 #include "chrome/browser/android/vr_shell/ui_elements/button.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/android/vr_shell/textures/button_texture.h" 8 #include "chrome/browser/android/vr_shell/textures/button_texture.h"
9 #include "ui/gfx/geometry/point_f.h" 9 #include "ui/gfx/geometry/point_f.h"
10 10
11 namespace vr_shell { 11 namespace vr_shell {
12 12
13 Button::Button(base::Callback<void()> click_handler, 13 Button::Button(int id,
14 base::Callback<void()> click_handler,
14 std::unique_ptr<ButtonTexture> texture) 15 std::unique_ptr<ButtonTexture> texture)
15 : TexturedElement(256), 16 : TexturedElement(id, 256),
16 texture_(std::move(texture)), 17 texture_(std::move(texture)),
17 click_handler_(click_handler) {} 18 click_handler_(click_handler) {}
18 19
19 Button::~Button() = default; 20 Button::~Button() = default;
20 21
21 void Button::OnHoverEnter(const gfx::PointF& position) { 22 void Button::OnHoverEnter(const gfx::PointF& position) {
22 OnStateUpdated(position); 23 OnStateUpdated(position);
23 } 24 }
24 25
25 void Button::OnHoverLeave() { 26 void Button::OnHoverLeave() {
(...skipping 28 matching lines...) Expand all
54 void Button::OnStateUpdated(const gfx::PointF& position) { 55 void Button::OnStateUpdated(const gfx::PointF& position) {
55 const bool hovered = HitTest(position); 56 const bool hovered = HitTest(position);
56 const bool pressed = hovered ? down_ : false; 57 const bool pressed = hovered ? down_ : false;
57 58
58 texture_->SetHovered(hovered); 59 texture_->SetHovered(hovered);
59 texture_->SetPressed(pressed); 60 texture_->SetPressed(pressed);
60 UpdateTexture(); 61 UpdateTexture();
61 } 62 }
62 63
63 } // namespace vr_shell 64 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698