Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
timelinepage.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17
18#include "timelinepage.h"
19
20#include "pencildef.h"
21#include "preferencemanager.h"
22
23#include "ui_timelinepage.h"
24
25TimelinePage::TimelinePage()
26 : ui(new Ui::TimelinePage)
27{
28 ui->setupUi(this);
29
30 ui->timelineLength->setMaximum(MaxFramesBound);
31
32 auto spinBoxValueChange = static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged);
33 auto sliderChanged = static_cast<void(QSlider::*)(int)>(&QSlider::valueChanged);
34 auto comboChanged = static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged);
35 connect(ui->timelineLength, spinBoxValueChange, this, &TimelinePage::timelineLengthChanged);
36 connect(ui->scrubBox, &QCheckBox::stateChanged, this, &TimelinePage::scrubChanged);
37 connect(ui->radioButtonAddNewKey, &QRadioButton::toggled, this, &TimelinePage::drawEmptyKeyRadioButtonToggled);
38 connect(ui->radioButtonDuplicate, &QRadioButton::toggled, this, &TimelinePage::drawEmptyKeyRadioButtonToggled);
39 connect(ui->radioButtonDrawOnPrev, &QRadioButton::toggled, this, &TimelinePage::drawEmptyKeyRadioButtonToggled);
40 connect(ui->flipRollMsecsSlider, sliderChanged, this, &TimelinePage::flipRollMsecSliderChanged);
41 connect(ui->flipRollMsecsSpinBox, spinBoxValueChange, this, &TimelinePage::flipRollMsecSpinboxChanged);
42 connect(ui->flipRollNumDrawingsSlider, sliderChanged, this, &TimelinePage::flipRollNumDrawingsSliderChanged);
43 connect(ui->flipRollNumDrawingsSpinBox, spinBoxValueChange, this, &TimelinePage::flipRollNumDrawingsSpinboxChanged);
44 connect(ui->flipInBtwnMsecSlider, sliderChanged, this, &TimelinePage::flipInbetweenMsecSliderChanged);
45 connect(ui->flipInBtwnMsecSpinBox, spinBoxValueChange, this, &TimelinePage::flipInbetweenMsecSpinboxChanged);
46 connect(ui->soundScrubSlider, sliderChanged, this, &TimelinePage::soundScrubMsecSliderChanged);
47 connect(ui->soundScrubSpinBox, spinBoxValueChange, this, &TimelinePage::soundScrubMsecSpinboxChanged);
48 connect(ui->layerVisibilityComboBox, comboChanged, this, &TimelinePage::layerVisibilityChanged);
49 connect(ui->visibilitySlider, &QSlider::valueChanged, this, &TimelinePage::layerVisibilityThresholdChanged);
50 connect(ui->visibilitySpinbox, spinBoxValueChange, this, &TimelinePage::layerVisibilityThresholdChanged);
51 ui->visibilitySpinbox->setSuffix("%");
52}
53
54TimelinePage::~TimelinePage()
55{
56 delete ui;
57}
58
59void TimelinePage::updateValues()
60{
61 QSignalBlocker b1(ui->scrubBox);
62 ui->scrubBox->setChecked(mManager->isOn(SETTING::SHORT_SCRUB));
63
64 QSignalBlocker b3(ui->timelineLength);
65 ui->timelineLength->setValue(mManager->getInt(SETTING::TIMELINE_SIZE));
66 if (mManager->getString(SETTING::TIMELINE_SIZE).toInt() <= 0)
67 ui->timelineLength->setValue(240);
68
69 QSignalBlocker b4(ui->radioButtonAddNewKey);
70 QSignalBlocker b5(ui->radioButtonDuplicate);
71 QSignalBlocker b6(ui->radioButtonDrawOnPrev);
72 int action = mManager->getInt(SETTING::DRAW_ON_EMPTY_FRAME_ACTION);
73 switch (action)
74 {
75 case CREATE_NEW_KEY:
76 ui->radioButtonAddNewKey->setChecked(true);
77 break;
78 case DUPLICATE_PREVIOUS_KEY:
79 ui->radioButtonDuplicate->setChecked(true);
80 break;
81 case KEEP_DRAWING_ON_PREVIOUS_KEY:
82 ui->radioButtonDrawOnPrev->setChecked(true);
83 break;
84 default:
85 break;
86 }
87
88 // to secure that you have a relevant minimum setting for sound scrub
89 int fps = mManager->getInt(SETTING::FPS);
90 int minMsec = 1000 / fps;
91 if (minMsec > 100) { minMsec = 100; }
92 ui->soundScrubSpinBox->setMinimum(minMsec);
93 ui->soundScrubSlider->setMinimum(minMsec);
94
95 ui->flipRollMsecsSlider->setValue(mManager->getInt(SETTING::FLIP_ROLL_MSEC));
96 ui->flipRollNumDrawingsSlider->setValue(mManager->getInt(SETTING::FLIP_ROLL_DRAWINGS));
97 ui->flipInBtwnMsecSlider->setValue(mManager->getInt(SETTING::FLIP_INBETWEEN_MSEC));
98 ui->flipRollMsecsSpinBox->setValue(mManager->getInt(SETTING::FLIP_ROLL_MSEC));
99 ui->flipRollNumDrawingsSpinBox->setValue(mManager->getInt(SETTING::FLIP_ROLL_DRAWINGS));
100 ui->flipInBtwnMsecSpinBox->setValue(mManager->getInt(SETTING::FLIP_INBETWEEN_MSEC));
101 ui->soundScrubSpinBox->setValue(mManager->getInt(SETTING::SOUND_SCRUB_MSEC));
102 ui->soundScrubSlider->setValue(mManager->getInt(SETTING::SOUND_SCRUB_MSEC));
103
104 int convertedVisibilityThreshold = static_cast<int>(mManager->getFloat(SETTING::LAYER_VISIBILITY_THRESHOLD)*100);
105
106 ui->visibilitySlider->setValue(convertedVisibilityThreshold);
107 ui->visibilitySpinbox->setValue(convertedVisibilityThreshold);
108
109 int visibilityType = mManager->getInt(SETTING::LAYER_VISIBILITY);
110 ui->layerVisibilityComboBox->setCurrentIndex(visibilityType);
111 layerVisibilityChanged(visibilityType);
112}
113
114void TimelinePage::timelineLengthChanged(int value)
115{
116 mManager->set(SETTING::TIMELINE_SIZE, value);
117}
118
119void TimelinePage::fontSizeChanged(int value)
120{
121 mManager->set(SETTING::LABEL_FONT_SIZE, value);
122}
123
124void TimelinePage::scrubChanged(int value)
125{
126 mManager->set(SETTING::SHORT_SCRUB, value != Qt::Unchecked);
127}
128
129void TimelinePage::layerVisibilityChanged(int value)
130{
131 mManager->set(SETTING::LAYER_VISIBILITY, value);
132 ui->visibilitySlider->setEnabled(value == 1);
133 ui->visibilitySpinbox->setEnabled(value == 1);
134}
135
136void TimelinePage::layerVisibilityThresholdChanged(int value)
137{
138 float percentage = static_cast<float>(value/100.0f);
139 mManager->set(SETTING::LAYER_VISIBILITY_THRESHOLD, percentage);
140
141 QSignalBlocker b8(ui->visibilitySlider);
142 ui->visibilitySlider->setValue(value);
143
144 QSignalBlocker b9(ui->visibilitySpinbox);
145 ui->visibilitySpinbox->setValue(value);
146}
147
148void TimelinePage::drawEmptyKeyRadioButtonToggled(bool)
149{
150 if (ui->radioButtonAddNewKey->isChecked())
151 {
152 mManager->set(SETTING::DRAW_ON_EMPTY_FRAME_ACTION, CREATE_NEW_KEY);
153 }
154 else if (ui->radioButtonDuplicate->isChecked())
155 {
156 mManager->set(SETTING::DRAW_ON_EMPTY_FRAME_ACTION, DUPLICATE_PREVIOUS_KEY);
157 }
158 else if (ui->radioButtonDrawOnPrev->isChecked())
159 {
160 mManager->set(SETTING::DRAW_ON_EMPTY_FRAME_ACTION, KEEP_DRAWING_ON_PREVIOUS_KEY);
161 }
162}
163
164void TimelinePage::flipRollMsecSliderChanged(int value)
165{
166 ui->flipRollMsecsSpinBox->setValue(value);
167 mManager->set(SETTING::FLIP_ROLL_MSEC, value);
168}
169
170void TimelinePage::flipRollMsecSpinboxChanged(int value)
171{
172 ui->flipRollMsecsSlider->setValue(value);
173 mManager->set(SETTING::FLIP_ROLL_MSEC, value);
174}
175
176void TimelinePage::flipRollNumDrawingsSliderChanged(int value)
177{
178 ui->flipRollNumDrawingsSpinBox->setValue(value);
179 mManager->set(SETTING::FLIP_ROLL_DRAWINGS, value);
180}
181
182void TimelinePage::flipRollNumDrawingsSpinboxChanged(int value)
183{
184 ui->flipRollNumDrawingsSlider->setValue(value);
185 mManager->set(SETTING::FLIP_ROLL_DRAWINGS, value);
186}
187
188void TimelinePage::flipInbetweenMsecSliderChanged(int value)
189{
190 ui->flipInBtwnMsecSpinBox->setValue(value);
191 mManager->set(SETTING::FLIP_INBETWEEN_MSEC, value);
192}
193
194void TimelinePage::flipInbetweenMsecSpinboxChanged(int value)
195{
196 ui->flipInBtwnMsecSlider->setValue(value);
197 mManager->set(SETTING::FLIP_INBETWEEN_MSEC, value);
198}
199
200void TimelinePage::soundScrubActiveChanged(int i)
201{
202 bool b = true;
203 if (i == 0)
204 b = false;
205 mManager->set(SETTING::SOUND_SCRUB_ACTIVE, b);
206 emit soundScrubChanged(b);
207}
208
209void TimelinePage::soundScrubMsecSliderChanged(int value)
210{
211 ui->soundScrubSpinBox->setValue(value);
212 mManager->set(SETTING::SOUND_SCRUB_MSEC, value);
213 emit soundScrubMsecChanged(value);
214}
215
216void TimelinePage::soundScrubMsecSpinboxChanged(int value)
217{
218 ui->soundScrubSlider->setValue(value);
219 mManager->set(SETTING::SOUND_SCRUB_MSEC, value);
220 emit soundScrubMsecChanged(value);
221}
TimelinePage
Definition: timelinepage.h:28
QAbstractButton::toggled
void toggled(bool checked)
QAbstractSlider::valueChanged
void valueChanged(int value)
QCheckBox::stateChanged
void stateChanged(int state)
QComboBox
QComboBox::currentIndexChanged
void currentIndexChanged(int index)
QSignalBlocker
QSlider
QSpinBox
QSpinBox::valueChanged
void valueChanged(int i)
QString::toInt
int toInt(bool *ok, int base) const const
Qt::Unchecked
Unchecked
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39