@@ -44,7 +44,7 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
4444 void initUi (const QString & name); // !< to be called by ctors
4545
4646public:
47- enum class DirectionOfManipulation
47+ enum class DirectionOfManipulation : bool
4848 {
4949 Vertical,
5050 Horizontal
@@ -60,25 +60,34 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
6060 setUnit (txt_after);
6161 }
6262
63- // ! In this mode, floating text is obtained by calling `pullFloatingText`.
64- void setFloatingTextPullMode ()
63+ // ! Push model or pull model for floating text updates
64+ enum class FloatingTextMode : bool
6565 {
66- m_floatingTextPushMode = false ;
67- m_floatingTextRefreshRate = 0 ;
68- }
66+ // ! Floating text is updated by this widget calling `pullFloatingText` as needed
67+ Pull,
68+
69+ /* *
70+ * Floating text is updated by an external component calling `pushFloatingText` when needed.
71+ *
72+ * This mode may optionally function in a hybrid fashion where this widget periodically emits
73+ * the `floatingTextUpdateRequested` signal for an external component to respond to by pushing
74+ * an update to `pushFloatingText`.
75+ */
76+ Push
77+ };
78+
79+ // ! In this mode, floating text is updated by this widget calling `pullFloatingText` as needed
80+ void setFloatingTextPullMode ();
6981
7082 /* *
71- * In this mode, floating text must be set manually by calling `pushFloatingText`.
83+ * In this mode, floating text must be updated by an external component calling `pushFloatingText`.
7284 *
7385 * @param refreshRate How many times per second `floatingTextUpdateRequested` will be emitted
86+ * while the text float is visible
7487 */
75- void setFloatingTextPushMode (std::uint8_t refreshRate = 0 )
76- {
77- m_floatingTextPushMode = true ;
78- m_floatingTextRefreshRate = refreshRate;
79- }
88+ void setFloatingTextPushMode (std::uint8_t refreshRate = 0 );
8089
81- // ! Manually updates the text float's text
90+ // ! When using the push mode, external components must call this to update the text float's text
8291 void pushFloatingText (const QString& text);
8392
8493signals:
@@ -87,8 +96,8 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
8796 void sliderMoved (float value);
8897
8998 /* *
90- * May be emitted periodically when the text float is visible.
91- * Upon receiving this signal, call `pushFloatingText() ` to update the
99+ * In push mode, may be emitted periodically when the text float is visible.
100+ * Upon receiving this signal, call `pushFloatingText` to update the
92101 * text float's text.
93102 */
94103 void floatingTextUpdateRequested ();
@@ -114,10 +123,11 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
114123
115124 virtual float getValue (const QPoint & p);
116125
117- // ! Retreives floating text in a "pull" fashion
126+ // ! When using the pull mode, this method is periodically called to obtain the text float's text
118127 virtual QString pullFloatingText () const ;
119128
120- void updateFloatingText ();
129+ // ! Call before showing the text float
130+ void takeControlOfTextFloat ();
121131
122132 void doConnections () override ;
123133
@@ -137,13 +147,19 @@ class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
137147
138148 DirectionOfManipulation m_directionOfManipulation;
139149
140- bool m_floatingTextPushMode = false ;
150+ FloatingTextMode m_floatingTextMode = FloatingTextMode::Pull ;
141151 std::uint8_t m_floatingTextRefreshRate = 0 ; // ! times per second
152+ int m_textFloatRefreshTimerId = 0 ;
153+
154+ private:
155+ void timerEvent (QTimerEvent* event) override ;
142156
143157private slots:
144158 virtual void enterValue ();
145159 void friendlyUpdate ();
146160 void toggleScale ();
161+
162+ void textFloatVisibilityChanged (bool visible);
147163};
148164
149165} // namespace lmms::gui
0 commit comments