Merge pull request #3298 from shun-iwasawa/fix_multi_flipbooks_playback

Fix Multiple Flipbooks Playback At the Same Time
This commit is contained in:
Rodney 2020-05-20 06:38:37 -05:00 committed by GitHub
commit 6d88776b43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,7 +191,8 @@ void PlaybackExecutor::run() {
emissionInstant = timer.getTotalTime();
// Draw the next frame
if (playedFramesCount) emit nextFrame(fps); // Show the next frame, telling
if (playedFramesCount)
emit nextFrame(fps); // Show the next frame, telling
// currently measured fps
if (FlipConsole::m_areLinked) {
@ -320,15 +321,17 @@ void FlipSlider::paintEvent(QPaintEvent *ev) {
p.drawImage(QRect(0, 0, PBColorMarginLeft, height()), PBOverlay,
QRect(0, 0, PBColorMarginLeft, PBOverlay.height()));
p.drawImage(QRect(PBColorMarginLeft, 0,
p.drawImage(
QRect(PBColorMarginLeft, 0,
sliderRect.width() - PBColorMarginLeft - PBColorMarginRight,
height()),
PBOverlay, QRect(PBColorMarginLeft, 0, overlayInnerWidth,
PBOverlay.height()));
PBOverlay,
QRect(PBColorMarginLeft, 0, overlayInnerWidth, PBOverlay.height()));
p.drawImage(
QRect(width() - PBColorMarginRight, 0, PBColorMarginRight, height()),
PBOverlay, QRect(PBOverlay.width() - PBColorMarginRight, 0,
PBColorMarginRight, PBOverlay.height()));
PBOverlay,
QRect(PBOverlay.width() - PBColorMarginRight, 0, PBColorMarginRight,
PBOverlay.height()));
// Draw the position marker
currPos = sliderPositionFromValue(minimum(), maxValuePlusStep, value(),
@ -771,8 +774,7 @@ bool FlipConsole::drawBlanks(int from, int to) {
if (m_blanksToDraw > 1 ||
(m_blanksToDraw == 0 &&
((m_reverse && m_currentFrame - m_step < from) ||
(!m_reverse &&
m_currentFrame + m_step >
(!m_reverse && m_currentFrame + m_step >
to)))) // we are on the last frame of the loop
{
m_blanksToDraw = (m_blanksToDraw == 0 ? m_blanksCount : m_blanksToDraw - 1);
@ -1437,13 +1439,14 @@ void FlipConsole::onButtonPressed(int button) {
(button == FlipConsole::ePlay || button == FlipConsole::eLoop)) {
pressButton(ePause);
} else {
if (button == FlipConsole::ePlay || button == FlipConsole::eLoop) {
// Sync playback state among all viewers & combo viewers.
// Note that the property "m_isLinkable" is used for distinguishing the
// owner between (viewer / combo viewer) and (flipbook / color model).
if (!m_isLinkable &&
(button == FlipConsole::ePlay || button == FlipConsole::eLoop)) {
bool stoppedOther = false;
int i;
FlipConsole *playingConsole = 0;
for (i = 0; i < m_visibleConsoles.size(); i++) {
playingConsole = m_visibleConsoles.at(i);
if (playingConsole == this) continue;
for (auto playingConsole : m_visibleConsoles) {
if (playingConsole == this || playingConsole->isLinkable()) continue;
if (playingConsole->m_playbackExecutor.isRunning()) {
playingConsole->doButtonPressed(ePause);
playingConsole->setChecked(ePlay, false);
@ -1586,16 +1589,19 @@ void FlipConsole::doButtonPressed(UINT button) {
case ePause:
if (!m_playbackExecutor.isRunning() && !m_isLinkedPlaying) {
int i;
FlipConsole *playingConsole = 0;
for (i = 0; i < m_visibleConsoles.size(); i++) {
playingConsole = m_visibleConsoles.at(i);
// Sync playback state among all viewers & combo viewers.
// Note that the property "m_isLinkable" is used for distinguishing the
// owner between (viewer / combo viewer) and (flipbook / color model).
if (!m_isLinkable) {
for (auto playingConsole : m_visibleConsoles) {
if (playingConsole->isLinkable()) continue;
if (playingConsole->m_playbackExecutor.isRunning())
playingConsole->doButtonPressed(button);
playingConsole->setChecked(ePlay, false);
playingConsole->setChecked(eLoop, false);
playingConsole->setChecked(ePause, true);
}
}
return;
}