Skip to content

Commit

Permalink
New Fx: Text Fx Iwa (#2393)
Browse files Browse the repository at this point in the history
* text fx iwa

* fix for osx and linux
  • Loading branch information
shun-iwasawa authored and masafumi-inoue committed Dec 18, 2018
1 parent 1cf798a commit 5b2332a
Show file tree
Hide file tree
Showing 12 changed files with 722 additions and 28 deletions.
13 changes: 13 additions & 0 deletions stuff/config/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,19 @@
<item>"STD_iwa_BarrelDistortFx.vignetteMidpoint" "Vignetting Midpoint"</item>
<item>"STD_iwa_BarrelDistortFx.scale" "Scale"</item>

<item>"STD_iwa_TextFx" "Text Iwa"</item>
<item>"STD_iwa_TextFx.targetType" "Source"</item>
<item>"STD_iwa_TextFx.columnIndex" "Column Index"</item>
<item>"STD_iwa_TextFx.hAlign" "Holizontal Align"</item>
<item>"STD_iwa_TextFx.text" "Text"</item>
<item>"STD_iwa_TextFx.center" "Center"</item>
<item>"STD_iwa_TextFx.width" "Width"</item>
<item>"STD_iwa_TextFx.height" "Height"</item>
<item>"STD_iwa_TextFx.font" "Font"</item>
<item>"STD_iwa_TextFx.textColor" "Text Color"</item>
<item>"STD_iwa_TextFx.boxColor" "Box Color"</item>
<item>"STD_iwa_TextFx.showBorder" "Show Border"</item>

<!------------------------------ Tiled Particles Iwa ------------------------------------------->

<item>STD_iwa_TiledParticlesFx "Tiled Particles Iwa" </item>
Expand Down
17 changes: 17 additions & 0 deletions stuff/profiles/layouts/fxs/STD_iwa_TextFx.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<fxlayout>
<page name="Text Iwa">
<vbox>
<control>targetType</control>
<control>columnIndex</control>
<control>text</control>
<control>hAlign</control>
<control>center</control>
<control>width</control>
<control>height</control>
<control>font</control>
<control>textColor</control>
<control>boxColor</control>
<control>showBorder</control>
</vbox>
</page>
</fxlayout>
3 changes: 2 additions & 1 deletion stuff/profiles/layouts/fxs/fxs.lst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
STD_inopnCloudsFx
STD_particlesFx
STD_iwa_TiledParticlesFx
STD_iwa_TimeCodeFx
STD_iwa_PNPerspectiveFx
STD_iwa_TextFx
</Render>
<Stylize>
STD_colorEmbossFx
Expand Down
12 changes: 12 additions & 0 deletions toonz/sources/common/tparam/tnotanimatableparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ PERSIST_IDENTIFIER(TBoolParam, "boolParam")
PERSIST_IDENTIFIER(TFilePathParam, "filePathParam")
PERSIST_IDENTIFIER(TStringParam, "stringParam")
PERSIST_IDENTIFIER(TNADoubleParam, "naDoubleParam")
PERSIST_IDENTIFIER(TFontParam, "fontParam")
// PERSIST_IDENTIFIER(TIntEnumParam, "intEnumParam")

TPersistDeclarationT<TEnumParam> TEnumParam::m_declaration("intEnumParam");
Expand Down Expand Up @@ -94,6 +95,17 @@ void TNADoubleParam::saveData(TOStream &os) {
os << getDefaultValue();
os << getValue();
}

//=========================================================

void TFontParam::loadData(TIStream &is) {
std::wstring str;
is >> str;
setValue(str, false);
}

void TFontParam::saveData(TOStream &os) { os << getValue(); }

//=========================================================

//=========================================================
Expand Down
33 changes: 33 additions & 0 deletions toonz/sources/include/tnotanimatableparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "tconvert.h"

#include <set>
#include <QFont>

#undef DVAPI
#undef DVVAR
Expand Down Expand Up @@ -169,6 +170,7 @@ class DVAPI TNotAnimatableParam : public TParam {
using namespace std;
return to_string(getValue());
}

bool hasKeyframes() const override { return 0; };
void getKeyframes(std::set<double> &) const override{};
int getNextKeyframe(double) const override { return -1; };
Expand Down Expand Up @@ -280,13 +282,18 @@ template class DVAPI TPersistDeclarationT<TStringParam>;
class DVAPI TStringParam final : public TNotAnimatableParam<std::wstring> {
PERSIST_DECLARATION(TStringParam);

bool m_multiLine = false;

public:
TStringParam(std::wstring v = L"") : TNotAnimatableParam<std::wstring>(v) {}
TStringParam(const TStringParam &src)
: TNotAnimatableParam<std::wstring>(src) {}
TParam *clone() const override { return new TStringParam(*this); }
void loadData(TIStream &is) override;
void saveData(TOStream &os) override;

void setMultiLineEnabled(bool enable) { m_multiLine = enable; }
bool isMultiLineEnabled() { return m_multiLine; }
};

DEFINE_PARAM_SMARTPOINTER(TStringParam, std::wstring)
Expand Down Expand Up @@ -393,6 +400,32 @@ class DVAPI TNADoubleParam final : public TNotAnimatableParam<double> {

DEFINE_PARAM_SMARTPOINTER(TNADoubleParam, double)

//=========================================================
//
// class TFontParam
//
//=========================================================

#ifdef _WIN32
template class DVAPI TNotAnimatableParam<std::wstring>;
class TFontParam;
template class DVAPI TPersistDeclarationT<TFontParam>;
#endif

class DVAPI TFontParam final : public TNotAnimatableParam<std::wstring> {
PERSIST_DECLARATION(TFontParam);

public:
TFontParam(std::wstring v = QFont().toString().toStdWString())
: TNotAnimatableParam<std::wstring>(v) {}
TFontParam(const TFontParam &src) : TNotAnimatableParam<std::wstring>(src) {}
TParam *clone() const override { return new TFontParam(*this); }
void loadData(TIStream &is) override;
void saveData(TOStream &os) override;
};

DEFINE_PARAM_SMARTPOINTER(TFontParam, std::wstring)

//-----------------------------------------------------------------------------
// TNotAnimatableParamChangeUndo
//-----------------------------------------------------------------------------
Expand Down
56 changes: 54 additions & 2 deletions toonz/sources/include/toonzqt/paramfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <QButtonGroup>
#include <QRadioButton>
#include <QPushButton>
#include <QTextEdit>

#include "tgeometry.h"
#include "tparam.h"
Expand All @@ -40,6 +41,7 @@ class QString;
class QComboBox;
class QHBoxLayout;
class TFxHandle;
class QFontComboBox;

namespace DVGui {
class LineEdit;
Expand Down Expand Up @@ -501,11 +503,28 @@ protected slots:
// StringParamField
//-----------------------------------------------------------------------------

namespace component {
class MyTextEdit : public QTextEdit {
Q_OBJECT
public:
MyTextEdit(const QString &text, QWidget *parent = Q_NULLPTR)
: QTextEdit(text, parent) {}

protected:
void keyPressEvent(QKeyEvent *event) override;
void focusOutEvent(QFocusEvent *e) override;

signals:
void edited();
};
};

class DVAPI StringParamField final : public ParamField {
Q_OBJECT

TStringParamP m_currentParam, m_actualParam;
DVGui::LineEdit *m_textFld;
DVGui::LineEdit *m_textFld = nullptr;
component::MyTextEdit *m_multiTextFld = nullptr;

public:
StringParamField(QWidget *parent, QString name, const TStringParamP &param);
Expand All @@ -514,8 +533,41 @@ class DVAPI StringParamField final : public ParamField {
int frame) override;
void update(int frame) override;

QSize getPreferedSize() override { return QSize(100, 20); }
QSize getPreferedSize() override {
if (m_textFld)
return QSize(100, 20);
else
return QSize(100, 80);
}
protected slots:
void onChange();
};

//=============================================================================
// FontParamField
//-----------------------------------------------------------------------------

class FontParamField final : public ParamField {
Q_OBJECT

TFontParamP m_currentParam, m_actualParam;

QFontComboBox *m_fontCombo;
QComboBox *m_styleCombo;
DVGui::IntField *m_sizeField;

public:
FontParamField(QWidget *parent, QString name, const TFontParamP &param);

void setParam(const TParamP &current, const TParamP &actual,
int frame) override;
void update(int frame) override;

QSize getPreferedSize() override { return QSize(150, 20); }

protected slots:
void findStyles(const QFont &font);
void onSizeChange(bool);
void onChange();
};

Expand Down
20 changes: 11 additions & 9 deletions toonz/sources/stdfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ set(HEADERS
iwa_fresnel.h
iwa_pnperspectivefx.h
iwa_soapbubblefx.h
iwa_bokehfx.h
iwa_timecodefx.h
iwa_bokehreffx.h
iwa_bokehfx.h
iwa_timecodefx.h
iwa_bokehreffx.h
iwa_textfx.h
)

set(SOURCES
Expand Down Expand Up @@ -250,12 +251,13 @@ set(SOURCES
iwa_noise1234.cpp
iwa_pnperspectivefx.cpp
iwa_soapbubblefx.cpp
${SDKROOT}/kiss_fft130/kiss_fft.c
${SDKROOT}/kiss_fft130/tools/kiss_fftnd.c
iwa_bokehfx.cpp
iwa_timecodefx.cpp
iwa_bokehreffx.cpp
iwa_barreldistortfx.cpp
${SDKROOT}/kiss_fft130/kiss_fft.c
${SDKROOT}/kiss_fft130/tools/kiss_fftnd.c
iwa_bokehfx.cpp
iwa_timecodefx.cpp
iwa_bokehreffx.cpp
iwa_barreldistortfx.cpp
iwa_textfx.cpp
)

set(OBJCSOURCES
Expand Down
Loading

0 comments on commit 5b2332a

Please sign in to comment.