-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoreServices: Add ControlIndicatorTimer to remove GuiTick dependency
Previously, the `ControlIndicator` objects relied on the `[Master],guiTickTime` and `[Master],guiTick50ms` that are managed by the `GuiTick` class and processed in the vsync thread during waveform processing. But the blinking of indicator controls is unrelated to Waveforms and should still work when we get rid of the legacy skin system and waveforms widgets. This simple change introduces two new control objects: - `[Master],indicator_250millis` - `[Master],indicator_500millis` Both switch between 0.0 and 1.0 every 250/500ms. `ControlIndicator` has been adapted to use these new controls instead. These controls may also be used by controller mappings that want to implement custom blinking controls. Before, this was already possible using a timer in JavaScript, but these were not synchronized with the other blinking controls, such as `[ChannelN],play_indicator` or `[ChannelN],cue_indicator` which made them more annoying than necessary.
- Loading branch information
Showing
8 changed files
with
124 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "control/controlindicatortimer.h" | ||
|
||
#include "control/controlobject.h" | ||
#include "moc_controlindicatortimer.cpp" | ||
|
||
namespace mixxx { | ||
|
||
ControlIndicatorTimer::ControlIndicatorTimer(QObject* pParent) | ||
: QObject(pParent), | ||
m_pCOIndicator250millis(std::make_unique<ControlObject>( | ||
ConfigKey("[Master]", "indicator_250millis"))), | ||
m_pCOIndicator500millis(std::make_unique<ControlObject>( | ||
ConfigKey("[Master]", "indicator_500millis"))), | ||
m_toggleIndicator500millisOnNextTimeout(true) { | ||
m_pCOIndicator250millis->setReadOnly(); | ||
m_pCOIndicator500millis->setReadOnly(); | ||
connect(&m_timer, &QTimer::timeout, this, &ControlIndicatorTimer::slotTimeout); | ||
m_timer.start(250); | ||
} | ||
|
||
void ControlIndicatorTimer::slotTimeout() { | ||
// The timeout uses an interval of 250ms, so the 250ms indicator is always updated. | ||
m_pCOIndicator250millis->forceSet(1 - m_pCOIndicator250millis->get()); | ||
|
||
// The 500ms indicator is only updated on every second call to the function. | ||
if (m_toggleIndicator500millisOnNextTimeout) { | ||
m_pCOIndicator500millis->forceSet(1 - m_pCOIndicator500millis->get()); | ||
} | ||
m_toggleIndicator500millisOnNextTimeout = !m_toggleIndicator500millisOnNextTimeout; | ||
} | ||
|
||
} // namespace mixxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QTimer> | ||
#include <memory> | ||
|
||
#include "control/controlobject.h" | ||
|
||
namespace mixxx { | ||
|
||
/// This class provides two generic indicator controls that change their value | ||
/// in intervals of 250 milliseconds and 500 milliseconds. These controls are | ||
/// used by all `ControlIndicator` COs and may also be used to implement custom | ||
/// blinking buttons (e.g. for Explicit Sync Leader) on controllers. This | ||
/// ensures that all blinking buttons that use the same interval light up at the | ||
/// same time. | ||
class ControlIndicatorTimer : public QObject { | ||
Q_OBJECT | ||
public: | ||
ControlIndicatorTimer(QObject* pParent = nullptr); | ||
|
||
private slots: | ||
/// Called every 250 milliseconds | ||
void slotTimeout(); | ||
|
||
private: | ||
QTimer m_timer; | ||
std::unique_ptr<ControlObject> m_pCOIndicator250millis; | ||
std::unique_ptr<ControlObject> m_pCOIndicator500millis; | ||
bool m_toggleIndicator500millisOnNextTimeout; | ||
}; | ||
|
||
} // namespace mixxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters