Bring in fixes from OpenToonz as of 10-12-2020 (#350)

* fix text fx bug

Signed-off-by: Jeremy Bullock <jcbullock@gmail.com>

* fix crash on undoing replace-paste zerary fx

Signed-off-by: Jeremy Bullock <jcbullock@gmail.com>

Co-authored-by: shun-iwasawa <shun.iwasawa@ghibli.jp>
This commit is contained in:
Jeremy Bullock 2020-10-13 22:36:42 -06:00 committed by GitHub
parent 16cd69f0dd
commit b19126c268
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 24 deletions

View file

@ -2793,9 +2793,9 @@ void UndoAddPasteFxs::initialize(TFx *inFx) {
m_linkIn = TFxCommand::Link(inFx, ifx, 0);
// Furthermore, clone the group stack from inFx into each inserted fx
auto const clone_fun = static_cast<void (*)(TFx *, TFx *)>(FxCommandUndo::cloneGroupStack);
for_each_fx(
[inFx, clone_fun](TFx *toFx) { clone_fun(inFx, toFx); });
auto const clone_fun =
static_cast<void (*)(TFx *, TFx *)>(FxCommandUndo::cloneGroupStack);
for_each_fx([inFx, clone_fun](TFx *toFx) { clone_fun(inFx, toFx); });
}
//------------------------------------------------------
@ -2808,7 +2808,8 @@ void UndoAddPasteFxs::redo() const {
FxCommandUndo::attach(xsh, m_linkIn, false);
// Copiare l'indice di gruppo dell'fx di input
auto const copy_fun = static_cast<void (*)(TFx *, TFx *)>(FxCommandUndo::copyGroupEditLevel);
auto const copy_fun =
static_cast<void (*)(TFx *, TFx *)>(FxCommandUndo::copyGroupEditLevel);
for_each_fx([this, copy_fun](TFx *toFx) {
copy_fun(m_linkIn.m_inputFx.getPointer(), toFx);
});
@ -3020,11 +3021,14 @@ void UndoReplacePasteFxs::undo() const {
// Remove m_lastFx's output connections - UndoAddPasteFxs would try to
// redirect them to the replaced fx's input (due to the 'blind' detach
// command)
int ol, olCount = m_rightmostFx->getOutputConnectionCount();
for (ol = olCount - 1; ol >= 0; --ol)
if (TFxPort *port = m_rightmostFx->getOutputConnection(ol)) port->setFx(0);
if (m_rightmostFx) {
int ol, olCount = m_rightmostFx->getOutputConnectionCount();
for (ol = olCount - 1; ol >= 0; --ol)
if (TFxPort *port = m_rightmostFx->getOutputConnection(ol))
port->setFx(0);
fxDag->removeFromXsheet(m_rightmostFx);
fxDag->removeFromXsheet(m_rightmostFx);
}
// Reverse the applied commands. Again, the order prevents 'bumped' dag
// positions

View file

@ -1580,7 +1580,7 @@ void StringParamField::onChange() {
if (m_multiTextFld)
value = m_multiTextFld->toPlainText().toStdWString();
else
value = m_textFld->text().toStdWString();
value = m_textFld->text().toStdWString();
TUndo *undo = 0;
if (!m_actualParam || m_actualParam->getValue() == value) return;
@ -1662,10 +1662,8 @@ FontParamField::FontParamField(QWidget *parent, QString name,
setLayout(m_layout);
bool ret = true;
ret = ret && connect(m_fontCombo, &QFontComboBox::currentFontChanged, this,
&FontParamField::findStyles);
ret = ret && connect(m_fontCombo, &QFontComboBox::currentFontChanged, this,
&FontParamField::onChange);
ret = ret && connect(m_fontCombo, SIGNAL(activated(const QString &)), this,
SLOT(onChange()));
ret = ret && connect(m_styleCombo, SIGNAL(activated(const QString &)), this,
SLOT(onChange()));
ret = ret && connect(m_sizeField, SIGNAL(valueChanged(bool)), this,
@ -1704,9 +1702,15 @@ void FontParamField::onSizeChange(bool isDragging) {
void FontParamField::onChange() {
QString family = m_fontCombo->currentFont().family();
QString style = m_styleCombo->currentText();
int size = m_sizeField->getValue();
TFontParamP fontParam = m_actualParam;
QFont currentFont;
currentFont.fromString(QString::fromStdWString(fontParam->getValue()));
if (family != currentFont.family()) {
findStyles(QFont(family));
}
QString style = m_styleCombo->currentText();
int size = m_sizeField->getValue();
int min, max;
m_sizeField->getRange(min, max);
if (size < min) size = min;
@ -1717,9 +1721,6 @@ void FontParamField::onChange() {
TUndo *undo = 0;
TFontParamP fontParam = m_actualParam;
QFont currentFont;
currentFont.fromString(QString::fromStdWString(fontParam->getValue()));
if (fontParam && currentFont != font)
undo = new FontParamFieldUndo(fontParam, m_interfaceName,
ParamField::m_fxHandleStat);
@ -1749,10 +1750,10 @@ void FontParamField::update(int frame) {
if (!m_actualParam || !m_currentParam) return;
QFont font;
font.fromString(QString::fromStdWString(m_actualParam->getValue()));
if (m_fontCombo->currentText() != font.family())
if (m_fontCombo->currentText() != font.family()) {
m_fontCombo->setCurrentFont(font);
findStyles(font);
}
m_styleCombo->setCurrentText(font.styleName());
m_sizeField->setValue(font.pixelSize());
}
@ -1806,9 +1807,8 @@ ToneCurveParamField::ToneCurveParamField(QWidget *parent, QString name,
void ToneCurveParamField::updateField(const QList<TPointD> value) {
if (m_actualParam) {
assert(m_currentParam &&
m_currentParam->getCurrentChannel() ==
m_actualParam->getCurrentChannel());
assert(m_currentParam && m_currentParam->getCurrentChannel() ==
m_actualParam->getCurrentChannel());
m_toneCurveField->setCurrentChannel(m_actualParam->getCurrentChannel());
assert(m_currentParam &&
m_currentParam->isLinear() == m_actualParam->isLinear());