Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef PALETTEVIEWER_H
Toshihiro Shimizu 890ddd
#define PALETTEVIEWER_H
Toshihiro Shimizu 890ddd
Kite 5cb633
#include "saveloadqsettings.h"
Toshihiro Shimizu 890ddd
#include "paletteviewergui.h"
Toshihiro Shimizu 890ddd
#include "toonz/tpalettehandle.h"
Kite 5cb633
#include "toonz/preferences.h"
Kite 5cb633
#include <qvboxlayout></qvboxlayout>
Kite 5cb633
#include <qhboxlayout></qhboxlayout>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
class QScrollArea;
Kite 5cb633
class DvScrollWidget;
Toshihiro Shimizu 890ddd
class QToolBar;
Toshihiro Shimizu 890ddd
class PaletteKeyframeNavigator;
Toshihiro Shimizu 890ddd
class TFrameHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace PaletteViewerGUI;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI ChangeStyleCommand {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ChangeStyleCommand() {}
Shinya Kitaoka 120a6e
  virtual ~ChangeStyleCommand() {}
Shinya Kitaoka 120a6e
  virtual bool onStyleChanged() = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// DAFARE: non mi piace, forse e' meglio un comando esterno!!
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// PaletteViewer
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Kite 5cb633
class DVAPI PaletteViewer final : public QFrame, public SaveLoadQSettings {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  PaletteViewer(QWidget *parent = 0, PaletteViewType viewType = LEVEL_PALETTE,
Shinya Kitaoka 120a6e
                bool hasSaveToolBar = true, bool hasPageCommand = true,
Shinya Kitaoka 120a6e
                bool hasPasteColors = true);
Shinya Kitaoka 120a6e
  ~PaletteViewer();
Toshihiro Shimizu 890ddd
justburner ebb16a
  enum ToolbarButtons : int  //! Toolbar buttons to display
justburner ebb16a
  {
justburner ebb16a
    TBVisKeyframe,
justburner ebb16a
    TBVisNewStylePage,
justburner ebb16a
    TBVisPaletteGizmo,
justburner ebb16a
    TBVisNameEditor,
justburner ebb16a
    TBVisTotal
justburner ebb16a
  };
justburner ebb16a
justburner ebb16a
  TPaletteHandle *getPaletteHandle() const { return m_paletteHandle; }
Shinya Kitaoka 120a6e
  void setPaletteHandle(TPaletteHandle *paletteHandle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TFrameHandle *getFrameHandle() const { return m_frameHandle; }
Shinya Kitaoka 120a6e
  void setFrameHandle(TFrameHandle *frameHandle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TXsheetHandle *getXsheetHandle() const { return m_xsheetHandle; }
Shinya Kitaoka 120a6e
  void setXsheetHandle(TXsheetHandle *xsheetHandle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // for clearing level cache after "paste style" command called from style
Shinya Kitaoka 120a6e
  // selection
Shinya Kitaoka 120a6e
  void setLevelHandle(TXshLevelHandle *levelHandle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPalette *getPalette();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setChangeStyleCommand(ChangeStyleCommand *);  // gets ownership
Shinya Kitaoka 120a6e
  ChangeStyleCommand *getChangeStyleCommand() const {
Shinya Kitaoka 120a6e
    return m_changeStyleCommand;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getViewMode() const { return m_pageViewer->getViewMode(); }
Shinya Kitaoka 120a6e
  void setViewMode(int mode) {
Shinya Kitaoka 120a6e
    m_pageViewer->setViewMode((PaletteViewerGUI::PageViewer::ViewMode)mode);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void updateView();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void enableSaveAction(bool enable);
Toshihiro Shimizu 890ddd
Kite 5cb633
  // SaveLoadQSettings
Kite 5cb633
  virtual void save(QSettings &settings) const override;
Kite 5cb633
  virtual void load(QSettings &settings) override;
Kite 5cb633
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TPaletteHandle *m_paletteHandle;
Shinya Kitaoka 120a6e
  TFrameHandle *m_frameHandle;
Shinya Kitaoka 120a6e
  TXsheetHandle *m_xsheetHandle;
shun-iwasawa b37337
  TXshLevelHandle *m_levelHandle;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QScrollArea *m_pageViewerScrollArea;
Shinya Kitaoka 120a6e
  PaletteViewerGUI::PageViewer *m_pageViewer;
Shinya Kitaoka 120a6e
  TabBarContainter *m_tabBarContainer;
Shinya Kitaoka 120a6e
  PaletteTabBar *m_pagesBar;
Shinya Kitaoka 120a6e
  QToolBar *m_paletteToolBar;
Shinya Kitaoka 120a6e
  QToolBar *m_savePaletteToolBar;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_indexPageToDelete;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  PaletteViewType m_viewType;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  PaletteKeyframeNavigator *m_keyFrameButton;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ChangeStyleCommand *m_changeStyleCommand;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_hasSavePaletteToolbar;
Shinya Kitaoka 120a6e
  bool m_hasPageCommand;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_isSaveActionEnabled;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QAction *m_lockPaletteAction;
Shinya Kitaoka 120a6e
  QToolButton *m_lockPaletteToolButton;
Toshihiro Shimizu 890ddd
shun-iwasawa baaa2c
  bool m_toolbarOnTop;
shun-iwasawa baaa2c
  QAction *m_showToolbarOnTopAct;
shun-iwasawa baaa2c
  DvScrollWidget *m_toolbarContainer;
shun-iwasawa baaa2c
  QHBoxLayout *m_hLayout;
shun-iwasawa baaa2c
justburner ebb16a
  StyleNameEditor *m_styleNameEditor;
justburner ebb16a
  QAction *m_sharedGizmoAction;
justburner ebb16a
justburner ebb16a
  int m_toolbarVisibleOtherParts;
justburner ebb16a
  QMultiMap<int, *="" qaction=""> m_toolbarParts;</int,>
justburner ebb16a
  QAction *m_visibleKeysAction;
justburner ebb16a
  QAction *m_visibleNewAction;
justburner ebb16a
  QAction *m_visibleGizmoAction;
justburner ebb16a
  QAction *m_visibleNameAction;
justburner ebb16a
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  void createTabBar();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void createToolBar() {
Shinya Kitaoka 120a6e
    createPaletteToolBar();
Shinya Kitaoka 120a6e
    createSavePaletteToolBar();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void createPaletteToolBar();
Shinya Kitaoka 120a6e
  void createSavePaletteToolBar();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void updateTabBar();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void updateToolBar() {
Shinya Kitaoka 120a6e
    updatePaletteToolBar();
Shinya Kitaoka 120a6e
    updateSavePaletteToolBar();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void updatePaletteToolBar();
Shinya Kitaoka 120a6e
  void updateSavePaletteToolBar();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void resizeEvent(QResizeEvent *event) override;
Shinya Kitaoka 473e70
  void contextMenuEvent(QContextMenuEvent *event) override;
shun-iwasawa b37337
  void mousePressEvent(QMouseEvent *event) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void showEvent(QShowEvent *) override;
Shinya Kitaoka 473e70
  void hideEvent(QHideEvent *) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void dragEnterEvent(QDragEnterEvent *event) override;
Shinya Kitaoka 473e70
  void dropEvent(QDropEvent *event) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void clearStyleSelection();
Toshihiro Shimizu 890ddd
justburner ebb16a
  void applyToolbarPartVisibility(int part, bool visible);
justburner ebb16a
Toshihiro Shimizu 890ddd
protected slots:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setPageView(int currentIndexPage);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addNewPage();
Shinya Kitaoka 120a6e
  void addNewColor();
Shinya Kitaoka 120a6e
  void deletePage();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void saveStudioPalette();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void onColorStyleSwitched();
Shinya Kitaoka 120a6e
  void onPaletteChanged();
Shinya Kitaoka 120a6e
  void onPaletteSwitched();
Shinya Kitaoka 120a6e
  void onFrameSwitched();
Shinya Kitaoka 120a6e
  void onTabTextChanged(int tabIndex);
Shinya Kitaoka 120a6e
  void onViewMode(QAction *);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void changeWindowTitle();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void movePage(int srcIndex, int dstIndex);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void startDragDrop();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void onNameDisplayMode(QAction *);
Shinya Kitaoka 120a6e
  void setIsLocked(bool lock);
manongjohn 649b9a
manongjohn 649b9a
  void onSwitchToPage(int pageIndex);
shun-iwasawa 726b1d
  void onShowNewStyleButtonToggled();
shun-iwasawa baaa2c
shun-iwasawa baaa2c
  void toggleToolbarOnTop();
justburner ebb16a
justburner ebb16a
  void toggleKeyframeVisibility(bool);
justburner ebb16a
  void toggleNewStylePageVisibility(bool);
justburner ebb16a
  void togglePaletteGizmoVisibility(bool);
justburner ebb16a
  void toggleNameEditorVisibility(bool);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // PALETTEVIEWER_H