1 #pragma once
2 
3 #ifndef VIEWER_PANE_INCLUDED
4 #define VIEWER_PANE_INCLUDED
5 
6 #include "sceneviewer.h"
7 #include "toonzqt/intfield.h"
8 #include "toonzqt/keyframenavigator.h"
9 #include "toonzqt/flipconsoleowner.h"
10 #include "saveloadqsettings.h"
11 
12 #include <QFrame>
13 
14 class SceneViewer;
15 class QPoint;
16 class QToolBar;
17 class QLabel;
18 class QSlider;
19 class QActionGroup;
20 class QButtonGroup;
21 class QToolBar;
22 class Ruler;
23 
24 //=============================================================================
25 // ViewerPanel
26 //-----------------------------------------------------------------------------
27 
28 class FlipConsole;
29 class TXshLevel;
30 class SceneViewerPanel final : public QFrame,
31                                public FlipConsoleOwner,
32                                public SaveLoadQSettings {
33   Q_OBJECT
34 
35   friend class SceneViewer;
36   SceneViewer *m_sceneViewer;
37   FlipConsole *m_flipConsole;
38   ViewerKeyframeNavigator *m_keyFrameButton;
39 
40   TPanelTitleBarButtonSet *m_referenceModeBs;
41   TPanelTitleBarButton *m_previewButton;
42   TPanelTitleBarButton *m_subcameraPreviewButton;
43   bool m_onionSkinActive = false;
44   UINT m_visiblePartsFlag;
45   bool m_playSound       = true;
46   bool m_hasSoundtrack   = false;
47   bool m_playing         = false;
48   double m_fps;
49   int m_viewerFps;
50   double m_samplesPerFrame;
51   bool m_first         = true;
52   TSoundTrack *m_sound = NULL;
53 
54 public:
55 #if QT_VERSION >= 0x050500
56   SceneViewerPanel(QWidget *parent = 0, Qt::WindowFlags flags = 0);
57 #else
58   SceneViewerPanel(QWidget *parent = 0, Qt::WFlags flags = 0);
59 #endif
60   ~SceneViewerPanel();
61 
62   // toggle show/hide of the widgets according to m_visiblePartsFlag
63   void setVisiblePartsFlag(UINT flag);
64   void updateShowHide();
65   void addShowHideContextMenu(QMenu*);
66 
67   void onDrawFrame(int frame,
68                    const ImagePainter::VisualSettings &settings) override;
69 
onEnterPanel()70   void onEnterPanel() {
71       m_sceneViewer->setFocus(Qt::OtherFocusReason);
72       // activate shortcut key for this flipconsole
73       m_flipConsole->makeCurrent();
74   }
onLeavePanel()75   void onLeavePanel() { m_sceneViewer->clearFocus(); }
76 
77   // SaveLoadQSettings
78   virtual void save(QSettings& settings) const override;
79   virtual void load(QSettings& settings) override;
80 
81   void initializeTitleBar(TPanelTitleBar* titleBar);
82 
83 protected:
84   void showEvent(QShowEvent *) override;
85   void hideEvent(QHideEvent *) override;
86   void resizeEvent(QResizeEvent *) override;
87   void createFrameToolBar();
88   void createPlayToolBar();
89   void addColorMaskButton(QWidget *parent, const char *iconSVGName, int id);
90   // reimplementation of TPanel::widgetFocusOnEnter
91 
92   void enableFlipConsoleForCamerastand(bool on);
93   void playAudioFrame(int frame);
94   bool hasSoundtrack();
95   void contextMenuEvent(QContextMenuEvent* event) override;
96 
97 public slots:
98 
99   void changeWindowTitle();
100   void onSceneChanged();
101   void onXshLevelSwitched(TXshLevel *);
102   void updateFrameRange();
103   void updateFrameMarkers();
104   void onButtonPressed(FlipConsole::EGadget button);
105   void setFlipHButtonChecked(bool checked);
106   void setFlipVButtonChecked(bool checked);
107 
108 protected slots:
109 
110   void onFrameSwitched();
111   void onSceneSwitched();
112   void onFrameTypeChanged();
113   void onPlayingStatusChanged(bool playing);
114   // for showing/hiding the parts
115   void onShowHideActionTriggered(QAction*);
116   void enableFullPreview(bool enabled);
117   void enableSubCameraPreview(bool enabled);
118 };
119 
120 #endif
121