tahoma2d/toonz/sources/include/toonzqt/fxsettings.h

320 lines
8.3 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef FXSETTINGS_H
#define FXSETTINGS_H
#ifdef _MSC_VER
2016-03-19 06:57:51 +13:00
#pragma warning(disable : 4251)
#endif
#include <QSplitter>
#include <QToolBar>
#include <QStackedWidget>
#include <QScrollArea>
#include <QMap>
#include <QGroupBox>
#include "tcommon.h"
#include "tfx.h"
#include "tabbar.h"
#include "gutil.h"
#include "toonzqt/framenavigator.h"
#include "toonzqt/paramfield.h"
#include "toonzqt/swatchviewer.h"
#include "toonzqt/fxhistogramrender.h"
#undef DVAPI
#undef DVVAR
#ifdef TOONZQT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
// forward declaration
class QToolBar;
class QStackedWidget;
class QVBoxLayout;
class QGridLayout;
class QPushButton;
class FxKeyframeNavigator;
class ParamViewer;
class TFxHandle;
class TFrameHandle;
class TXsheetHandle;
class TSceneHandle;
class TXshLevelHandle;
class TObjectHandle;
class ToonzScene;
//=============================================================================
/*! \brief ParamsPage. View a page with fx params.
2016-06-15 18:43:10 +12:00
Inherits \b QWidget.
2016-03-19 06:57:51 +13:00
*/
class DVAPI ParamsPage final : public QFrame {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QColor m_textColor; /*-- 文字の色 デフォルト黒 --*/
Q_PROPERTY(QColor TextColor READ getTextColor WRITE setTextColor)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QGridLayout *m_mainLayout;
QHBoxLayout *m_horizontalLayout;
QGridLayout *m_groupLayout;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
friend class ParamViewer;
QVector<ParamField *> m_fields;
/*! To menage eventually histogram in page. */
FxHistogramRender *m_fxHistogramRender;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
ParamViewer *m_paramViewer;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ParamsPage(QWidget *parent = 0, ParamViewer *paramViewer = 0);
~ParamsPage();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setPage(TIStream &is, const TFxP &fx) {
setPageField(is, fx);
setPageSpace();
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setFx(const TFxP &currentFx, const TFxP &actualFx, int frame);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void update(int frame);
void setPointValue(int index, const TPointD &p);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxHistogramRender *getFxHistogramRender() const {
return m_fxHistogramRender;
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*- 現在のページの最適なサイズを返す -*/
2020-03-16 14:37:10 +13:00
QSize getPreferredSize();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setTextColor(const QColor &color) { m_textColor = color; }
QColor getTextColor() const { return m_textColor; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
void setPageField(TIStream &is, const TFxP &fx, bool isVertical = true);
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
void setPageSpace();
void beginGroup(const char *name);
void endGroup();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void addWidget(QWidget *, bool isVertical = true);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
#define TOONZ_DECLARE_NEW_COMPONENT(NAME) \
QWidget *NAME(TFx *fx, const char *name)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TOONZ_DECLARE_NEW_COMPONENT(newParamField);
TOONZ_DECLARE_NEW_COMPONENT(newLineEdit);
TOONZ_DECLARE_NEW_COMPONENT(newSlider);
TOONZ_DECLARE_NEW_COMPONENT(newSpinBox);
TOONZ_DECLARE_NEW_COMPONENT(newCheckBox);
TOONZ_DECLARE_NEW_COMPONENT(newRadioButton);
TOONZ_DECLARE_NEW_COMPONENT(newComboBox);
2016-03-19 06:57:51 +13:00
#undef TOONZ_DECLARE_NEW_COMPONENT
2020-03-16 14:37:10 +13:00
// make ParamsPageSet to re-compute preferred size.
// currently emitted only from ToneCurveParamField
signals:
void preferredPageSizeChanged();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
2016-06-15 18:43:10 +12:00
/*! \brief ParamsPageSet. Contains a stack of page \b ParamsPage with relative
tab.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
Inherits \b QWidget.
2016-03-19 06:57:51 +13:00
*/
class DVAPI ParamsPageSet final : public QWidget {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TabBarContainter *m_tabBarContainer;
DVGui::TabBar *m_tabBar;
QStackedWidget *m_pagesList;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
ParamViewer *m_parent;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! Allows to map page and index, useful to display a macro.
QMap<ParamsPage *, int> m_pageFxIndexTable;
2016-03-19 06:57:51 +13:00
2020-03-16 14:37:10 +13:00
QSize m_preferredSize;
2016-06-15 18:43:10 +12:00
/*-- ヘルプのファイルパス(もしあれば)---*/
std::string m_helpFilePath;
/*-- pdfファイルのページ指定など、引数が必要な場合の追加引数 --*/
std::string m_helpCommand;
/*-- ヘルプボタンで開くURL --*/
std::string m_helpUrl;
QPushButton *m_helpButton;
2016-03-19 06:57:51 +13:00
public:
#if QT_VERSION >= 0x050500
2016-06-15 18:43:10 +12:00
ParamsPageSet(QWidget *parent = 0, Qt::WindowFlags flags = 0);
2016-03-19 06:57:51 +13:00
#else
2016-06-15 18:43:10 +12:00
ParamsPageSet(QWidget *parent = 0, Qt::WFlags flags = 0);
2016-03-19 06:57:51 +13:00
#endif
2016-06-15 18:43:10 +12:00
~ParamsPageSet();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setFx(const TFxP &currentFx, const TFxP &actualFx, int frame);
void setScene(ToonzScene *scene);
void setIsCameraViewMode(bool isCameraViewMode);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void updatePage(int frame, bool onlyParam);
/*! Create a page reading xml file relating to \b fx. */
void createControls(const TFxP &fx, int index = -1);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
ParamsPage *getCurrentParamsPage() const;
ParamsPage *getParamsPage(int index) const;
int getParamsPageCount() const { return (int)m_pagesList->count(); };
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
ParamsPage *createParamsPage();
void addParamsPage(ParamsPage *page, const char *name);
2016-03-19 06:57:51 +13:00
2020-03-16 14:37:10 +13:00
QSize getPreferredSize() { return m_preferredSize; }
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
void createPage(TIStream &is, const TFxP &fx, int index);
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void setPage(int);
void openHelpFile();
void openHelpUrl();
2020-03-16 14:37:10 +13:00
void recomputePreferredSize();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
/*! \brief ParamViewer. Contains a stack of \b ParamsPageSet.
2016-06-15 18:43:10 +12:00
Inherits \b QWidget.
2016-03-19 06:57:51 +13:00
*/
class DVAPI ParamViewer final : public QFrame {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TFxP m_fx;
TFxP m_actualFx;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QStackedWidget *m_tablePageSet;
QMap<std::string, int> m_tableFxIndex;
2016-03-19 06:57:51 +13:00
public:
#if QT_VERSION >= 0x050500
2016-06-15 18:43:10 +12:00
ParamViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
2016-03-19 06:57:51 +13:00
#else
2016-06-15 18:43:10 +12:00
ParamViewer(QWidget *parent = 0, Qt::WFlags flags = 0);
2016-03-19 06:57:51 +13:00
#endif
2016-06-15 18:43:10 +12:00
~ParamViewer();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setFx(const TFxP &currentFx, const TFxP &actualFx, int frame,
ToonzScene *scene);
void setScene(ToonzScene *scene);
void setIsCameraViewMode(bool isCameraViewMode);
/*! If onlyParam is true don't invalidate raster of associated histogram. */
void update(int frame, bool onlyParam);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setPointValue(int index, const TPointD &p);
2016-03-19 06:57:51 +13:00
2020-03-16 14:37:10 +13:00
void notifyPreferredSizeChanged(QSize size) {
emit preferredSizeChanged(size);
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
ParamsPageSet *getCurrentPageSet() const;
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void currentFxParamChanged();
void actualFxParamChanged();
void paramKeyChanged();
2016-03-19 06:57:51 +13:00
2020-03-16 14:37:10 +13:00
void preferredSizeChanged(QSize);
2016-06-15 18:43:10 +12:00
void showSwatchButtonToggled(bool);
2016-03-19 06:57:51 +13:00
};
//=============================================================================
/*! \brief FxSettings.
2016-06-15 18:43:10 +12:00
Inherits \b QWidget.
2016-03-19 06:57:51 +13:00
*/
class QActionGroup;
class DVAPI FxSettings final : public QSplitter {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QToolBar *m_toolBar;
QAction *m_checkboardBg;
ParamViewer *m_paramViewer;
SwatchViewer *m_viewer;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TFxHandle *m_fxHandle;
TXsheetHandle *m_xsheetHandle;
TSceneHandle *m_sceneHandle;
TXshLevelHandle *m_levelHandle;
TFrameHandle *m_frameHandle;
TObjectHandle *m_objectHandle;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FxKeyframeNavigator *m_keyframeNavigator;
FrameNavigator *m_frameNavigator;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TPixel32 m_checkCol1, m_checkCol2;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_isCameraModeView;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int m_container_height;
int m_container_width;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSettings(QWidget *parent, const TPixel32 &checkCol1,
const TPixel32 &checkCol2);
~FxSettings();
// Devono essere settati!
void setFxHandle(TFxHandle *fxHandle);
TFxHandle *getFxHandle() const { return m_fxHandle; }
void setFrameHandle(TFrameHandle *frameHandle);
TFrameHandle *getFrameHandle() const { return m_frameHandle; }
void setXsheetHandle(TXsheetHandle *XsheetHandle);
TXsheetHandle *getXsheetHandle() const { return m_xsheetHandle; }
void setSceneHandle(TSceneHandle *sceneHandle);
TSceneHandle *getSceneHandle() const { return m_sceneHandle; }
void setLevelHandle(TXshLevelHandle *levelHandle);
TXshLevelHandle *getLevelHandle() const { return m_levelHandle; }
void setObjectHandle(TObjectHandle *objectHandle);
TObjectHandle *getObjectHandle() const { return m_objectHandle; }
2016-03-19 06:57:51 +13:00
public slots:
2016-06-15 18:43:10 +12:00
void setCurrentFrame();
void setCurrentFx();
void setCurrentScene();
void notifySceneChanged();
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
/*! \b currentFx is fx with parent, \b actualFx is simple fx. */
void setFx(const TFxP &currentFx, const TFxP &actualFx);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void createToolBar();
2016-06-19 20:06:29 +12:00
void showEvent(QShowEvent *) override;
void hideEvent(QHideEvent *) override;
2016-06-15 18:43:10 +12:00
void setCheckboardColors(const TPixel32 &col1, const TPixel32 &col2);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void changeTitleBar(TFx *fx);
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void updateViewer();
void updateParamViewer();
void onPointChanged(int index, const TPointD &p);
void onViewModeChanged(QAction *);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setWhiteBg();
void setBlackBg();
void setCheckboardBg();
2016-03-19 06:57:51 +13:00
2020-03-16 14:37:10 +13:00
void onPreferredSizeChanged(QSize);
2016-06-15 18:43:10 +12:00
void onShowSwatchButtonToggled(bool);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // FXSETTINGS_H