|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TAPP_H
|
|
Toshihiro Shimizu |
890ddd |
#define TAPP_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qobject></qobject>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// forward declaration
|
|
Toshihiro Shimizu |
890ddd |
class TSceneHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TXsheetHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TXshLevelHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TFrameHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TColumnHandle;
|
|
Toshihiro Shimizu |
890ddd |
class ToolHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TObjectHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TSelectionHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TOnionSkinMaskHandle;
|
|
Toshihiro Shimizu |
890ddd |
class TFxHandle;
|
|
Toshihiro Shimizu |
890ddd |
class PaletteController;
|
|
Toshihiro Shimizu |
890ddd |
class QTimer;
|
|
Toshihiro Shimizu |
890ddd |
class TXshLevel;
|
|
Toshihiro Shimizu |
890ddd |
class QMainWindow;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class TMainWindow;
|
|
Toshihiro Shimizu |
890ddd |
class ComboViewerPanel;
|
|
Jeremy Bullock |
6ee71e |
class SceneViewer;
|
|
manongjohn |
2e094e |
class XsheetViewer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// TXsheeHandle
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//! This is the instance of the main application.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! This class is a singleton and is used to initialize the main application
|
|
Shinya Kitaoka |
120a6e |
window.
|
|
Shinya Kitaoka |
120a6e |
It defines the basic signals used in the application, as the
|
|
Shinya Kitaoka |
120a6e |
status changing of
|
|
Shinya Kitaoka |
120a6e |
the scene and connects them to the basic handlers.
|
|
Shinya Kitaoka |
120a6e |
\n It is also used to retrieve a pointer to the current state of
|
|
Shinya Kitaoka |
120a6e |
the application,
|
|
Shinya Kitaoka |
120a6e |
as the pointer to the main window, a pointer to the current
|
|
Shinya Kitaoka |
120a6e |
scene or a pointer
|
|
Shinya Kitaoka |
120a6e |
to the current selection, etc...
|
|
Shinya Kitaoka |
120a6e |
\n For example to get the pointer to the main window in any part
|
|
Shinya Kitaoka |
120a6e |
of the code one has to write:
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\code
|
|
Toshihiro Shimizu |
890ddd |
// A pointer to the main windows is
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QMainWindow * mainwindow = TApp::instance()->getMainWindow();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// To get the current object id
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId currentObjectId =
|
|
Shinya Kitaoka |
120a6e |
TApp::instance()->getCurrentObject()->getObjectId();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
\endcode
|
|
Shinya Kitaoka |
120a6e |
This class is used to take care of changes on the state of the
|
|
Shinya Kitaoka |
120a6e |
application and to
|
|
Shinya Kitaoka |
120a6e |
notify through event handling to the rest of the code.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
d1f6c4 |
class TApp final : public QObject,
|
|
Shinya Kitaoka |
d1f6c4 |
public TTool::Application // Singleton
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TSceneHandle *m_currentScene;
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *m_currentXsheet;
|
|
Shinya Kitaoka |
120a6e |
TFrameHandle *m_currentFrame;
|
|
Shinya Kitaoka |
120a6e |
TColumnHandle *m_currentColumn;
|
|
Shinya Kitaoka |
120a6e |
TXshLevelHandle *m_currentLevel;
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *m_currentTool;
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *m_currentObject;
|
|
Shinya Kitaoka |
120a6e |
TSelectionHandle *m_currentSelection;
|
|
Shinya Kitaoka |
120a6e |
TOnionSkinMaskHandle *m_currentOnionSkinMask;
|
|
Shinya Kitaoka |
120a6e |
TFxHandle *m_currentFx;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
PaletteController *m_paletteController;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QMainWindow *m_mainWindow;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
6ee71e |
SceneViewer *m_activeViewer;
|
|
manongjohn |
2e094e |
XsheetViewer *m_xsheetViewer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int m_autosavePeriod; // minutes
|
|
Shinya Kitaoka |
120a6e |
bool m_autosaveSuspended;
|
|
Shinya Kitaoka |
120a6e |
QTimer *m_autosaveTimer;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TApp();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_isStarting;
|
|
Shinya Kitaoka |
120a6e |
bool m_isPenCloseToTablet;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
A static pointer to the main application.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
static TApp *instance();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
~TApp();
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current scene.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TSceneHandle *getCurrentScene() const override { return m_currentScene; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current Xsheet.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TXsheetHandle *getCurrentXsheet() const override { return m_currentXsheet; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current frame.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TFrameHandle *getCurrentFrame() const override { return m_currentFrame; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current column.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TColumnHandle *getCurrentColumn() const override { return m_currentColumn; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current level.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TXshLevelHandle *getCurrentLevel() const override { return m_currentLevel; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current tool used.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
ToolHandle *getCurrentTool() const override { return m_currentTool; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current object in use.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TObjectHandle *getCurrentObject() const override { return m_currentObject; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current selection.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
38fd86 |
TSelectionHandle *getCurrentSelection() const override {
|
|
Shinya Kitaoka |
38fd86 |
return m_currentSelection;
|
|
Shinya Kitaoka |
38fd86 |
}
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current layer's mask.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TOnionSkinMaskHandle *getCurrentOnionSkin() const override {
|
|
Shinya Kitaoka |
120a6e |
return m_currentOnionSkinMask;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current effect.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
473e70 |
TFxHandle *getCurrentFx() const override { return m_currentFx; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
PaletteController *getPaletteController() const override {
|
|
Shinya Kitaoka |
120a6e |
return m_paletteController;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Sets a pointer to the main window..
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Current Palette (PaletteController) methods
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
TPaletteHandle *getCurrentPalette() const override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
TColorStyle *getCurrentLevelStyle() const override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
int getCurrentLevelStyleIndex() const override;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
558228 |
void setCurrentLevelStyleIndex(int index, bool forceUpdate = false) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setMainWindow(QMainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the main window.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
QMainWindow *getMainWindow() const { return m_mainWindow; }
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns a pointer to the current room. The current room is the window
|
|
Shinya Kitaoka |
120a6e |
environment in use,
|
|
Shinya Kitaoka |
120a6e |
i.e. the drawing tab, the animation tab, the pltedit tab etc...
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
TMainWindow *getCurrentRoom() const;
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Returns the current image type that can be a raster or a vector image.
|
|
Shinya Kitaoka |
120a6e |
\sa TImage::Type.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
int getCurrentImageType();
|
|
Shinya Kitaoka |
120a6e |
/*!
|
|
Shinya Kitaoka |
120a6e |
Initializes the main window application. It is called in the main
|
|
Shinya Kitaoka |
120a6e |
function
|
|
Shinya Kitaoka |
120a6e |
after the environment initialization.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void init();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString getCurrentRoomName() const;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
784640 |
void setActiveViewer(SceneViewer *viewer) {
|
|
shun-iwasawa |
784640 |
if (m_activeViewer == viewer) return;
|
|
shun-iwasawa |
784640 |
m_activeViewer = viewer;
|
|
shun-iwasawa |
784640 |
emit activeViewerChanged();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Jeremy Bullock |
6ee71e |
|
|
Jeremy Bullock |
6ee71e |
SceneViewer *getActiveViewer() const { return m_activeViewer; }
|
|
Jeremy Bullock |
6ee71e |
|
|
Shinya Kitaoka |
120a6e |
bool isApplicationStarting() { return m_isStarting; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool isPenCloseToTablet() const { return m_isPenCloseToTablet; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void writeSettings();
|
|
turtletooth |
8d9ba3 |
|
|
manongjohn |
2e094e |
void setCurrentXsheetViewer(XsheetViewer *viewer) { m_xsheetViewer = viewer; }
|
|
manongjohn |
2e094e |
|
|
manongjohn |
2e094e |
XsheetViewer *getCurrentXsheetViewer() const { return m_xsheetViewer; }
|
|
manongjohn |
2e094e |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
473e70 |
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
void updateXshLevel();
|
|
Shinya Kitaoka |
120a6e |
void updateCurrentFrame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected slots:
|
|
Shinya Kitaoka |
120a6e |
void onXsheetChanged();
|
|
Shinya Kitaoka |
120a6e |
void onSceneSwitched();
|
|
Shinya Kitaoka |
120a6e |
void onXsheetSwitched();
|
|
Shinya Kitaoka |
120a6e |
void onXsheetSoundChanged();
|
|
Shinya Kitaoka |
120a6e |
void onFrameSwitched();
|
|
Shinya Kitaoka |
120a6e |
void onFxSwitched();
|
|
Shinya Kitaoka |
120a6e |
void onColumnIndexSwitched();
|
|
Shinya Kitaoka |
120a6e |
void onXshLevelSwitched(TXshLevel *);
|
|
Shinya Kitaoka |
120a6e |
void onXshLevelChanged();
|
|
Shinya Kitaoka |
120a6e |
void onObjectSwitched();
|
|
Shinya Kitaoka |
120a6e |
void onSplineChanged();
|
|
Shinya Kitaoka |
120a6e |
void onSceneChanged();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void onImageChanged();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void onPaletteChanged();
|
|
Shinya Kitaoka |
120a6e |
void onLevelColorStyleChanged();
|
|
Shinya Kitaoka |
120a6e |
void onLevelColorStyleSwitched();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void autosave();
|
|
Shinya Kitaoka |
120a6e |
void onToolEditingFinished();
|
|
Shinya Kitaoka |
120a6e |
void onStartAutoSave();
|
|
Shinya Kitaoka |
120a6e |
void onStopAutoSave();
|
|
shun_iwasawa |
491a52 |
|
|
shun_iwasawa |
491a52 |
signals:
|
|
shun_iwasawa |
491a52 |
// on OSX, there is a critical bug that SceneViewer::mousePressEvent is called
|
|
shun_iwasawa |
491a52 |
// when leaving the stylus and it causes unwanted stroke drawn while
|
|
shun_iwasawa |
491a52 |
// hover-moving of the pen.
|
|
shun_iwasawa |
491a52 |
// This signal is to detect tablet leave and force initializing such irregular
|
|
shun_iwasawa |
491a52 |
// mouse press.
|
|
shun_iwasawa |
491a52 |
// NOTE: For now QEvent::TabletLeaveProximity is NOT detected on Windows. See
|
|
shun_iwasawa |
491a52 |
// QTBUG-53628.
|
|
shun_iwasawa |
491a52 |
void tabletLeft();
|
|
shun-iwasawa |
784640 |
|
|
shun-iwasawa |
784640 |
void
|
|
shun-iwasawa |
784640 |
activeViewerChanged(); // TODO: put widgets-related stuffs in some new handle
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TAPP_H
|