File indexing completed on 2024-12-22 04:14:39

0001 /*
0002  *  SPDX-FileCopyrightText: 2023 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "KisAnimationPlaybackControlsModel.h"
0008 
0009 #include "KisLager.h"
0010 
0011 #include "KisCanvasAnimationState.h"
0012 #include "KisPlaybackEngine.h"
0013 
0014 
0015 KisAnimationPlaybackControlsModel::KisAnimationPlaybackControlsModel()
0016     : m_dropFramesMode {true}
0017     , LAGER_QT(dropFramesMode) {m_dropFramesMode}
0018     , LAGER_QT(playbackSpeed) {m_playbackSpeed}
0019     , LAGER_QT(playbackSpeedDenorm) {m_playbackSpeed.zoom(kislager::lenses::scale_real_to_int(100.0))}
0020 {
0021 }
0022 
0023 void KisAnimationPlaybackControlsModel::connectAnimationState(KisCanvasAnimationState *state)
0024 {
0025     connect(state, &KisCanvasAnimationState::sigPlaybackSpeedChanged,
0026             this, &KisAnimationPlaybackControlsModel::setplaybackSpeed);
0027     connect(this, &KisAnimationPlaybackControlsModel::playbackSpeedChanged,
0028             state, &KisCanvasAnimationState::setPlaybackSpeed);
0029     setplaybackSpeed(state->playbackSpeed());
0030 }
0031 
0032 void KisAnimationPlaybackControlsModel::connectPlaybackEngine(KisPlaybackEngine *engine)
0033 {
0034     connect(this, &KisAnimationPlaybackControlsModel::dropFramesModeChanged,
0035             engine, &KisPlaybackEngine::setDropFramesMode);
0036     connect(engine, &KisPlaybackEngine::sigDropFramesModeChanged,
0037             this, &KisAnimationPlaybackControlsModel::setdropFramesMode);
0038     setdropFramesMode(engine->dropFrames());
0039 }