1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_VR_ELEMENTS_RESIZER_H_ 6 #define CHROME_BROWSER_VR_ELEMENTS_RESIZER_H_ 7 8 #include <sstream> 9 10 #include "base/macros.h" 11 #include "chrome/browser/vr/elements/ui_element.h" 12 #include "chrome/browser/vr/vr_ui_export.h" 13 #include "ui/gfx/transform.h" 14 15 namespace vr { 16 17 // When enabled, a resizer scales its descendant elements in response to 18 // trackpad use. 19 class VR_UI_EXPORT Resizer : public UiElement { 20 public: 21 Resizer(); 22 ~Resizer() override; 23 set_touch_position(const gfx::PointF & position)24 void set_touch_position(const gfx::PointF& position) { 25 touchpad_position_ = position; 26 } 27 28 void SetTouchingTouchpad(bool touching); 29 30 void SetEnabled(bool enabled); 31 void Reset(); 32 33 #ifndef NDEBUG 34 void DumpGeometry(std::ostringstream* os) const override; 35 #endif 36 37 bool ShouldUpdateWorldSpaceTransform( 38 bool parent_transform_changed) const override; 39 40 private: 41 gfx::Transform LocalTransform() const override; 42 gfx::Transform GetTargetLocalTransform() const override; 43 void UpdateTransform(const gfx::Transform& head_pose); 44 bool OnBeginFrame(const gfx::Transform& head_pose) override; 45 46 bool enabled_ = false; 47 48 // Initialized via constants. 49 float t_; 50 float initial_t_; 51 52 gfx::Transform transform_; 53 54 gfx::PointF touchpad_position_; 55 gfx::PointF initial_touchpad_position_; 56 57 DISALLOW_COPY_AND_ASSIGN(Resizer); 58 }; 59 60 } // namespace vr 61 62 #endif // CHROME_BROWSER_VR_ELEMENTS_RESIZER_H_ 63