Scroller.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Elem.hpp"
4 #include "Slot.hpp"
5 #include "OneChildElem.hpp"
8 
9 namespace iv
10 {
11 
18 class Scroller : public OneChildElem< SlotChild >, public SlotChild, private FixedUpdateClient, private FrameUpdateClient, protected PrivValAttr_Owner
19 {
20 public:
22 using Elem::instance;
23 
24  Scroller( Instance * );
25  void status( iv::TableDebugView * view );
26 
28  InputId input_id();
29 
30 // for visualization
36 
37 // utility methods
38 
39  // Elem
40  Scroller * enabled( bool );
41 
42 protected:
43  // Elem
44  virtual void first_pass_impl( ElementRenderer * ) override;
45  virtual void second_pass_impl( ElementRenderer * ) override;
46 
47  // InputNode
48  virtual void input_process( InputRoot * root, Input::DeviceKey key, bool & press, bool & real, bool & offspace ) override;
49  virtual bool input_trigger_process( InputRoot * root, Input::DeviceKey key ) override;
50 
51  // FixedUpdateClient
52  virtual void fixed_update( TimeId time, int time_step, int steps ) override;
53 
54  // FrameUpdateClient
55  virtual void frame_update() override;
56 
57 private:
58  void clamp_position();
59  void accept_candidate();
60  float2 input_position( Input::DeviceKey key );
61  void reserve_hover_keys( InputRoot * root, bool reserve );
62  void refresh_clamp_countdown();
63 
64 private:
65  //
66  DirtyAttr< float > position;
67  DirtyAttr< float > smoothedPosition;
68 
69  // drag and drop input
71  InputQuery iq;
72 
73  std::optional< Input::DeviceKey > _candidate;
74  std::optional< Input::DeviceKey > _active;
75  float _candidate_pos;
76  float _residual_speed;
77  int _full_clamp_countdown;
78 
79  InputId _input_id;
80 };
81 
82 }