tahoma2d/toonz/sources/include/toonzqt/flipconsole.h
Jeremy Bullock af90cdedbe
UI update and Icons from Konero (#126)
* add multi arc mockup

* implement mutli arc

* add join and smooth option

* reset multiarc and arc when deactivated

* create self loop if the last point is the same as the first

* make join option in multiarc consistent with tape tool

* fix a bug where thickness don't affect mutliarc in vector level

* remove join option in geometric tool

* stop mutliarc after closing shape

* double click can also end multi arc

* fix a bug where multiArc will produce buggy stroke

* fix a bug where geometric tools is not deactivated

* add multiArc shortcut

* rewrite multiArc

* revert changes to tvectorimage

* add undo data for multiArc

* Paste as Copy Command for XSheet

* Remove unneeded code

* Bug fix

* prevent guide lines from jumping around in MultiArc

* make stroke color consistent in MultiArc

* remove color in MultiArc's undo data

* make color consistent in MultiArc with previous version

* Fix single image raster levels

* fix compilation error

* fix a bug where multiArc might generate bugged stroke

* Remove ICONV dep (#3304)

* fix crash on saving studio palette

* Move to Paste Special Menu

* Don't Set Fixed Width if Docking a Floating Panel

* Update how_to_build_win.md

New draft of pr for requested changes to windows build instructions.

* fix geometric tool multiarc smooth option

* fix level saving failure

* fix wrong warning after saving palette

* fix a bug where moving a control point while holding alt has unintended result

* fix travis-install (#3389)

* Fix assert debug crash in flipconsole.cpp

Fix crash when using the viewer controls in the console (debug)

* Redraw Audio Waveform

Fills the waveform rather than outlines it.

* Update .gitignore

* fix undo data when drawing arc and mutliarc

* fix overwriting raster drawing palette (#3387)

* mode sensitive fx settings

* Create New Style Command Button (#3394)

* Create New Style Command Button

This PR creates a new button in the pallette editor that creates a new style.  Button is large and easy access for a faster and easier workflow.  Original code developed by Turtletooth for Tahoma.  Given permission to develop within Openoonz.

Co-Authored-By: Jeremy Bullock <turtletooth@users.noreply.github.com>

* Update paletteviewergui.cpp

Made changes to the PR per request by Shun.

* Fixed a space within the code that wasn't suppose to be there.

Co-authored-by: Jeremy Bullock <turtletooth@users.noreply.github.com>

* tahoma license (#3396)

* new style button optional

* fix loading pegbars (removing updateKeyframes)

* periodic random expression

* add fx in linear color space
this commit is based on source for the ComposeAdd plugin fx by DWANGO Co., Ltd.
in dwango_opentoonz_plugins and opentoonz_plugin_utility repositories.

* fractal noise iwa fx

* skip unnecessary icon invalidation

* fix frame range fill with tablet

* stop function editor to open by dbl clicking key

* Expanding the radius of the rotation handle.

This just changes when the cursor transforms into the rotation tool.

(cherry picked from commit 7722ae989bbdc6aa5cb48df7a4c08bae1fe6ea39)

* fix vector img patern stroke style

* Update Stylesheets

- Support the new icon sizes
- XSheet and Timeline significantly redesigned
- Lots of margin fixes and refactoring
- Remove deprecated icons, as some icons are moved into binary
- New Light theme

* New Icons

- Redesigns almost every icon as symbolic
- Adds icons for most commands

* Add Option for Icon Themes

- Adds option for icon themes
- Removes useless label from Preferences category list

* Update Icon Functions

- Adds themePath() boolean
- Adds function for recoloring black pixels in pixmaps to any color
- Rebuilds createQIcon to use fromTheme() and recolorPixmap()
- Removes createQIconOnOff as it seemed to be a rarely used duplicate of createQIcon
- Removes a grey horizontal line drawn above the console play bar in the viewer

* Set Default Icon Theme and Paths

- Sets search paths for icons for use with QIcon::fromTheme()
- Sets default start icon theme on first install
- Sets flag for displaying icons in menus, so we can selectively hide them

* Set Icons for Commands

- Sets icons for the commands
- Hides icons being displayed in menus as most icons are 20x20, they will look blurry when shrunk to 16x16
- Selectively allows icons to display for Tools in menus

* Change Icon Sizes, General Fixes and Stylesheet Additions

- Change icon sizes to new size
- Remove margin around FX Editor window
- Remove white line under color sliders in Style Editor
- Make keyframe icons uniform and color stylable in the stylesheets
- Removes deprecated stylesheet strings
- Redesign GUI for palette list view
- Make tree list header sort row stylable
- Remove black lines from scrollbars in New Project window
- Remove margin around combobox in Level Strip
- Alter how some lines are drawn in the Timeline to fix some alpha issues
- Make conditional fixed onion skin and normal onion skin dots contrast more against a light background area to make sure they have good visibility
- Make text always viewable in the FPS field in console bar
- Increase size of radio buttons in Cleanup Settings
- Increase size of switches in motion path nodes
- Remove unessesary "Layer" label in Timeline and other rects
- Various colors made stylable in the stylesheets; palette numpad and selection frame, cleanup settings border, scene cast folder path, schematic lines, ruler, xsheet lines, keyframes, cell input box and more
- Moves some external stylesheet icons into binary

* Make TPanelTitleBar Icon States Stylable

- Makes icon states for TPanelTitleBar buttons stylable in stylesheets

* Travis Fixes

* Swap Startup Popup Logos

They were in the wrong folders

* Revert "Swap Startup Popup Logos"

This reverts commit 815908a9f3e725f48507dab8a2270bdfa045649d.

* Fix Startup Popup Logo

It wasn't switching

* Feedback Changes

- Change render visualization to clapboard
- Fix text contrast on levels in XSheet

* Make Cell Selection More Clear

* Darken Light Theme and Tint Empty Cell Selection

* Fix missing icons

* Fix memo button

* Bring back colors

* Hide Motion Tab

* Fix Play Range Area (Light)

Make play range area more visible

* Vector Column Color

Co-authored-by: pojienie <pojienie@gmail.com>
Co-authored-by: rim <11380091+rozhuk-im@users.noreply.github.com>
Co-authored-by: shun-iwasawa <shun.iwasawa@ghibli.jp>
Co-authored-by: Rodney <rodney.baker@gmail.com>
Co-authored-by: DoctorRyan <65507211+DoctorRyan@users.noreply.github.com>
Co-authored-by: shun-iwasawa <shun-iwasawa@users.noreply.github.com>
Co-authored-by: Kite <konero@users.noreply.github.com>
Co-authored-by: Jeremy Bullock <turtletooth@users.noreply.github.com>
Co-authored-by: DoctorRyan <doctorryan1969.gmail.com>
2020-08-31 12:51:22 -06:00

451 lines
13 KiB
C++

#pragma once
#ifndef FLICONSOLE_H
#define FLICONSOLE_H
#include <QWidget>
#include <QAction>
#include <QMap>
#include <QList>
#include <QTime>
#include <QStyleOption>
#include <QStyleOptionFrameV3>
#include <QColor>
#include <QImage>
#include "tcommon.h"
#include "tpixel.h"
#include "toonzqt/intfield.h"
#include "toonz/imagepainter.h"
#include "tstopwatch.h"
#include <QThread>
#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
enum {
eShowCompare = 0x001,
eShowBg = 0x002,
eShowFramerate = 0x004,
eShowVcr = 0x008,
eShowcolorFilter = 0x010,
eShowCustom = 0x020,
eShowHisto = 0x040,
eShowSave = 0x080,
eShowDefineSubCamera = 0x100,
eShowFilledRaster = 0x200,
eShowDefineLoadBox = 0x400,
eShowUseLoadBox = 0x800,
eShowViewerControls = 0x1000,
eShowSound = 0x2000,
eShowLocator = 0x4000,
eShowHowMany = 0x8000
};
class QToolBar;
class QLabel;
class QSlider;
class QTimerEvent;
class QVBoxLayout;
class QActionGroup;
class QAbstractButton;
class QPushButton;
class QScrollBar;
class DoubleButton;
class FlipSlider;
class FlipConsole;
class ToolBarContainer;
class FlipConsoleOwner;
class TFrameHandle;
//-----------------------------------------------------------------------------
class PlaybackExecutor final : public QThread {
Q_OBJECT
int m_fps;
bool m_abort;
public:
PlaybackExecutor();
void resetFps(int fps);
void run() override;
void abort() { m_abort = true; }
void emitNextFrame(int fps) { emit nextFrame(fps); }
signals:
void nextFrame(int fps); // Must be connect with Qt::BlockingQueuedConnection
// connection type.
void playbackAborted();
};
//-----------------------------------------------------------------------------
// Implements a flipbook slider with a progress bar in background.
class FlipSlider final : public QAbstractSlider {
Q_OBJECT
Q_PROPERTY(int PBHeight READ getPBHeight WRITE setPBHeight)
Q_PROPERTY(QImage PBOverlay READ getPBOverlay WRITE setPBOverlay)
Q_PROPERTY(QImage PBMarker READ getPBMarker WRITE setPBMarker)
Q_PROPERTY(int PBColorMarginLeft READ getPBColorMarginLeft WRITE
setPBColorMarginLeft)
Q_PROPERTY(
int PBColorMarginTop READ getPBColorMarginTop WRITE setPBColorMarginTop)
Q_PROPERTY(int PBColorMarginRight READ getPBColorMarginRight WRITE
setPBColorMarginRight)
Q_PROPERTY(int PBColorMarginBottom READ getPBColorMarginBottom WRITE
setPBColorMarginBottom)
Q_PROPERTY(int PBMarkerMarginLeft READ getPBMarkerMarginLeft WRITE
setPBMarkerMarginLeft)
Q_PROPERTY(int PBMarkerMarginRight READ getPBMarkerMarginRight WRITE
setPBMarkerMarginRight)
Q_PROPERTY(QColor baseColor READ getBaseColor WRITE setBaseColor)
Q_PROPERTY(
QColor notStartedColor READ getNotStartedColor WRITE setNotStartedColor)
Q_PROPERTY(QColor startedColor READ getStartedColor WRITE setStartedColor)
Q_PROPERTY(QColor finishedColor READ getFinishedColor WRITE setFinishedColor)
bool m_enabled;
const std::vector<UCHAR> *m_progressBarStatus;
public:
enum { PBFrameNotStarted, PBFrameStarted, PBFrameFinished };
FlipSlider(QWidget *parent);
~FlipSlider() {}
void setProgressBarEnabled(bool enabled) { m_enabled = enabled; }
void setProgressBarStatus(const std::vector<UCHAR> *pbStatus) {
m_progressBarStatus = pbStatus;
}
const std::vector<UCHAR> *getProgressBarStatus() const {
return m_progressBarStatus;
}
public:
// Properties setters-getters
int getPBHeight() const;
void setPBHeight(int height);
QImage getPBOverlay() const;
void setPBOverlay(const QImage &img);
QImage getPBMarker() const;
void setPBMarker(const QImage &img);
int getPBColorMarginLeft() const;
void setPBColorMarginLeft(int margin);
int getPBColorMarginTop() const;
void setPBColorMarginTop(int margin);
int getPBColorMarginRight() const;
void setPBColorMarginRight(int margin);
int getPBColorMarginBottom() const;
void setPBColorMarginBottom(int margin);
int getPBMarkerMarginLeft() const;
void setPBMarkerMarginLeft(int margin);
int getPBMarkerMarginRight() const;
void setPBMarkerMarginRight(int margin);
QColor getBaseColor() const;
void setBaseColor(const QColor &color);
QColor getNotStartedColor() const;
void setNotStartedColor(const QColor &color);
QColor getStartedColor() const;
void setStartedColor(const QColor &color);
QColor getFinishedColor() const;
void setFinishedColor(const QColor &color);
protected:
void paintEvent(QPaintEvent *ev) override;
void mousePressEvent(QMouseEvent *me) override;
void mouseMoveEvent(QMouseEvent *me) override;
void mouseReleaseEvent(QMouseEvent *me) override;
private:
int sliderPositionFromValue(int min, int max, int pos, int span);
int sliderValueFromPosition(int min, int max, int step, int pos, int span);
int pageStepVal(int val);
signals:
void flipSliderReleased();
void flipSliderPressed();
};
//-----------------------------------------------------------------------------
class DVAPI FlipConsole final : public QWidget {
Q_OBJECT
QColor m_fpsFieldColor;
Q_PROPERTY(QColor FpsFieldColor READ getFpsFieldColor WRITE setFpsFieldColor)
public:
enum EGadget {
eBegin,
ePlay,
eLoop,
ePause,
ePrev,
eNext,
eFirst,
eLast,
eRed,
eGreen,
eBlue,
eGRed,
eGGreen,
eGBlue,
eMatte,
eFrames,
eRate,
eSound,
eHisto,
eSaveImg,
eCompare,
eCustomize,
eSave,
eDefineSubCamera,
eFilledRaster, // Used only in LineTest
eDefineLoadBox,
eUseLoadBox,
eLocator,
eZoomIn,
eZoomOut,
eFlipHorizontal,
eFlipVertical,
eResetView,
// following values are hard-coded in ImagePainter
eBlackBg = 0x40000,
eWhiteBg = 0x80000,
eCheckBg = 0x100000,
eEnd
};
static FlipConsole *m_currentConsole;
static QList<FlipConsole *> m_visibleConsoles;
static bool m_isLinkedPlaying;
static bool m_areLinked;
// blanksEnabled==true->at begin of each loop a number of blank frames are
// drawn (according to rpeferences settings)
FlipConsole(QVBoxLayout *layout, std::vector<int> gadgetsMask,
bool isLinkable, QWidget *customWidget,
const QString &customizeId,
FlipConsoleOwner *consoleOwner, // call
// consoleOwner->onDrawFrame()
// intead of emitting drawFrame
// signal
bool enableBlanks = false);
void enableBlanks(bool state);
void setFrameRange(
int from, int to, int step,
int current = -1); // if current==-1, current position will be ==from
void getFrameRange(int &from, int &to, int &step) const {
from = m_from, to = m_to, step = m_step;
}
void setFrameRate(int rate, bool forceUpdate = true);
// if doShowHide==true, applies set visible, otherwise applies setEnabled
void enableButton(UINT button, bool enable, bool doShowHide = true);
void showCurrentFrame();
int getCurrentFrame() const { return m_currentFrame; }
int getCurrentFps() const { return m_fps; }
void setChecked(UINT button, bool state);
bool isChecked(UINT button) const;
void setCurrentFrame(int frame, bool forceResetting = false);
void setMarkers(int fromIndex, int toIndex) {
m_markerFrom = fromIndex + 1;
m_markerTo = toIndex + 1;
}
void pressButton(UINT button) {
doButtonPressed(button);
setChecked(button, !isChecked(button));
}
UINT getCustomizeMask() { return m_customizeMask; }
void setCustomizemask(UINT mask);
void setStopAt(int frame);
// the main (currently the only) use for current flipconsole and setActive is
// to
// support shortcuts handling
// setActive() should be called every time the visibility state of the console
// changes
// a list of visible console is maintained. calling setActive(false) for the
// current
// console makes automatically current the next one in the list
static FlipConsole *getCurrent() { return m_currentConsole; };
static void toggleLinked();
void makeCurrent();
void setActive(bool active);
void pressButton(EGadget buttonId);
void showHideAllParts(bool);
void showHidePlaybar(bool);
void showHideFrameSlider(bool);
void enableProgressBar(bool enable);
void setProgressBarStatus(const std::vector<UCHAR> *status);
const std::vector<UCHAR> *getProgressBarStatus() const;
void setFrameHandle(TFrameHandle *frameHandle) {
m_frameHandle = frameHandle;
}
bool isLinkable() const { return m_isLinkable; }
void playNextFrame();
void updateCurrentFPS(int val);
bool hasButton(std::vector<int> buttonMask, FlipConsole::EGadget buttonId) {
if (buttonMask.size() == 0) return true;
return std::find(buttonMask.begin(), buttonMask.end(), buttonId) ==
buttonMask.end();
}
void setFpsFieldColor(const QColor &color) { m_fpsFieldColor = color; }
QColor getFpsFieldColor() const { return m_fpsFieldColor; }
signals:
void buttonPressed(FlipConsole::EGadget button);
void playStateChanged(bool isPlaying);
void sliderReleased();
void changeSceneFps(int);
private:
UINT m_customizeMask;
QString m_customizeId;
QAction *m_customAction;
PlaybackExecutor m_playbackExecutor;
QAction *m_customSep, *m_rateSep, *m_histoSep, *m_bgSep, *m_vcrSep,
*m_compareSep, *m_saveSep, *m_colorFilterSep, *m_soundSep, *m_subcamSep,
*m_filledRasterSep, *m_viewerSep;
QToolBar *m_playToolBar;
QActionGroup *m_colorFilterGroup;
ToolBarContainer *m_playToolBarContainer;
QFrame *m_frameSliderFrame;
QLabel *m_fpsLabel, *m_timeLabel;
QScrollBar *m_fpsSlider;
DVGui::IntLineEdit *m_fpsField;
//QColor m_fpsFieldColor = QColor(1, 1, 1);
QAction *m_fpsFieldAction;
QAction *m_fpsLabelAction;
QAction *m_fpsSliderAction;
QFrame *createFpsSlider();
QAction *m_doubleRedAction, *m_doubleGreenAction, *m_doubleBlueAction;
DoubleButton *m_doubleRed, *m_doubleGreen, *m_doubleBlue;
std::vector<int> m_gadgetsMask;
int m_from, m_to, m_step;
int m_currentFrame, m_framesCount;
int m_stopAt = -1;
ImagePainter::VisualSettings m_settings;
bool m_isPlay;
int m_fps, m_sceneFps;
bool m_reverse;
int m_markerFrom, m_markerTo;
bool m_drawBlanksEnabled;
int m_blanksCount;
TPixel m_blankColor;
int m_blanksToDraw;
bool m_isLinkable;
QMenu *m_menu;
QMap<EGadget, QAbstractButton *> m_buttons;
QMap<EGadget, QAction *> m_actions;
void createCustomizeMenu(bool withCustomWidget);
void addMenuItem(UINT id, const QString &text, QMenu *menu);
void createButton(UINT buttonMask, const char *iconStr, const QString &tip,
bool checkable, QActionGroup *groupIt = 0);
QAction *createCheckedButtonWithBorderImage(
UINT buttonMask, const char *iconStr, const QString &tip, bool checkable,
QActionGroup *groupIt = 0, const char *cmdId = 0);
void createOnOffButton(UINT buttonMask, const char *iconStr,
const QString &tip, QActionGroup *group);
QAction *createDoubleButton(UINT buttonMask1, UINT buttonMask2,
const char *iconStr1, const char *iconStr2,
const QString &tip1, const QString &tip2,
QActionGroup *group, DoubleButton *&w);
QFrame *createFrameSlider();
void createPlayToolBar(QWidget *customWidget);
DVGui::IntLineEdit *m_editCurrFrame;
FlipSlider *m_currFrameSlider;
void updateCurrentTime();
void doButtonPressed(UINT button);
static void pressLinkedConsoleButton(UINT button, FlipConsole *skipIt);
void applyCustomizeMask();
void onLoadBox(bool isDefine);
QPushButton *m_enableBlankFrameButton;
FlipConsoleOwner *m_consoleOwner;
TFrameHandle *m_frameHandle;
protected slots:
void OnSetCurrentFrame();
void OnFrameSliderRelease();
void OnFrameSliderPress();
void OnSetCurrentFrame(int);
void setCurrentFPS(int);
void setCurrentFPS(bool dragging);
inline void onButtonPressed(QAction *action) {
onButtonPressed(action->data().toUInt());
}
void onButtonPressed(int button);
void incrementCurrentFrame(int delta);
void onNextFrame(int fps);
void setFpsFieldColors();
void onCustomizeButtonPressed(QAction *);
bool drawBlanks(int from, int to);
void onSliderRelease();
void onFPSEdited();
public slots:
void onPreferenceChanged(const QString &);
void resetToSceneFps();
void setSceneFpsToCurrent();
private:
friend class PlaybackExecutor;
PlaybackExecutor &playbackExecutor() { return m_playbackExecutor; }
};
#endif