| #pragma once |
| |
| #ifndef PALETTEVIEWERGUI_H |
| #define PALETTEVIEWERGUI_H |
| |
| |
| #include "toonzqt/selection.h" |
| #include "toonzqt/lineedit.h" |
| |
| |
| #include "tpalette.h" |
| |
| |
| #include <QFrame> |
| #include <QTabBar> |
| #include <QShortcut> |
| |
| #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 |
| |
| |
| |
| |
| |
| class TXsheetHandle; |
| class TFrameHandle; |
| class TPaletteHandle; |
| class TXshLevelHandle; |
| class TStyleSelection; |
| class TabBarContainter; |
| class ChangeStyleCommand; |
| class QMimeData; |
| class StyleNameEditor; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| namespace PaletteViewerGUI { |
| |
| enum PaletteViewType |
| { |
| LEVEL_PALETTE, |
| CLEANUP_PALETTE, |
| STUDIO_PALETTE |
| }; |
| |
| |
| |
| |
| |
| class DVAPI PageViewer final : public QFrame, public TSelection::View { |
| Q_OBJECT |
| |
| QColor m_textColor; |
| Q_PROPERTY(QColor TextColor READ getTextColor WRITE setTextColor) |
| |
| |
| QColor m_separatorColor; |
| Q_PROPERTY( |
| QColor SeparatorColor READ getSeparatorColor WRITE setSeparatorColor) |
| |
| |
| QColor m_selectedBorderColor; |
| Q_PROPERTY(QColor SelectedBorderColor READ getSelectedBorderColor WRITE |
| setSelectedBorderColor) |
| |
| |
| QColor m_numpadShortcutBgColor; |
| Q_PROPERTY(QColor NumpadShortcutBgColor READ getNumpadShortcutBgColor WRITE |
| setNumpadShortcutBgColor) |
| |
| QColor m_numpadShortcutBorderColor; |
| Q_PROPERTY(QColor NumpadShortcutBorderColor READ getNumpadShortcutBorderColor |
| WRITE setNumpadShortcutBorderColor) |
| |
| |
| QColor m_currentCellColor; |
| Q_PROPERTY(QColor CurrentCellColor READ getCurrentCellColor WRITE |
| setCurrentCellColor) |
| |
| |
| QColor m_selectedCellColor; |
| Q_PROPERTY(QColor SelectedCellColor READ getSelectedCellColor WRITE |
| setSelectedCellColor) |
| |
| |
| QColor m_listNumpadShortcutBorderColor; |
| Q_PROPERTY( |
| QColor ListNumpadShortcutBorderColor READ getListNumpadShortcutBorderColor |
| WRITE setListNumpadShortcutBorderColor) |
| |
| public: |
| enum ViewMode |
| { |
| SmallChips, |
| MediumChips, |
| LargeChips, |
| List, |
| SmallChipsWithName |
| |
| }; |
| |
| |
| enum NameDisplayMode { Style, Original, StyleAndOriginal }; |
| |
| public: |
| PageViewer(QWidget *parent = 0, PaletteViewType viewType = LEVEL_PALETTE, |
| bool hasPasteColors = true); |
| ~PageViewer(); |
| |
| void setPaletteHandle(TPaletteHandle *paletteHandle); |
| TPaletteHandle *getPaletteHandle() const; |
| |
| void setXsheetHandle(TXsheetHandle *xsheetHandle); |
| TXsheetHandle *getXsheetHandle() const; |
| |
| void setFrameHandle(TFrameHandle *xsheetHandle); |
| TFrameHandle *getFrameHandle() const; |
| |
| |
| void setLevelHandle(TXshLevelHandle *levelHandle); |
| |
| void setCurrentStyleIndex(int index); |
| int getCurrentStyleIndex() const; |
| |
| void setPage(TPalette::Page *page); |
| TPalette::Page *getPage() const { return m_page; } |
| |
| void setChangeStyleCommand(ChangeStyleCommand *changeStyleCommand) { |
| m_changeStyleCommand = changeStyleCommand; |
| }; |
| ChangeStyleCommand *getChangeStyleCommand() const { |
| return m_changeStyleCommand; |
| } |
| |
| int getChipCount() const; |
| |
| ViewMode getViewMode() const { return m_viewMode; } |
| void setViewMode(ViewMode mode); |
| NameDisplayMode getNameDisplayMode() const { return m_nameDisplayMode; } |
| void setNameDisplayMode(NameDisplayMode mode); |
| |
| PaletteViewerGUI::PaletteViewType getViewType() const { return m_viewType; } |
| |
| int posToIndex(const QPoint &pos) const; |
| |
| QRect getItemRect(int index) const; |
| QRect getColorChipRect(int index) const; |
| QRect getColorNameRect(int index) const; |
| |
| void drop(int indexInPage, const QMimeData *mimeData); |
| void createDropPage(); |
| void onSelectionChanged() override { update(); } |
| |
| TStyleSelection *getSelection() const { return m_styleSelection; } |
| void clearSelection(); |
| |
| |
| |
| void updateCommandLocks(); |
| |
| void setTextColor(const QColor &color) { m_textColor = color; } |
| QColor getTextColor() const { return m_textColor; } |
| |
| |
| void setSeparatorColor(const QColor &color) { m_separatorColor = color; } |
| QColor getSeparatorColor() const { return m_separatorColor; } |
| |
| void setSelectedBorderColor(const QColor &color) { |
| m_selectedBorderColor = color; |
| } |
| QColor getSelectedBorderColor() const { return m_selectedBorderColor; } |
| |
| |
| void setNumpadShortcutBgColor(const QColor &color) { |
| m_numpadShortcutBgColor = color; |
| } |
| QColor getNumpadShortcutBgColor() const { return m_numpadShortcutBgColor; } |
| |
| void setNumpadShortcutBorderColor(const QColor &color) { |
| m_numpadShortcutBorderColor = color; |
| } |
| QColor getNumpadShortcutBorderColor() const { |
| return m_numpadShortcutBorderColor; |
| } |
| |
| |
| void setCurrentCellColor(const QColor &color) { m_currentCellColor = color; } |
| QColor getCurrentCellColor() const { return m_currentCellColor; } |
| |
| |
| void setSelectedCellColor(const QColor &color) { |
| m_selectedCellColor = color; |
| } |
| QColor getSelectedCellColor() const { return m_selectedCellColor; } |
| |
| |
| void setListNumpadShortcutBorderColor(const QColor &color) { |
| m_listNumpadShortcutBorderColor = color; |
| } |
| QColor getListNumpadShortcutBorderColor() const { |
| return m_listNumpadShortcutBorderColor; |
| } |
| |
| public slots: |
| |
| void computeSize(); |
| void onFrameChanged(); |
| void onStyleRenamed(); |
| |
| void addNewColor(); |
| void addNewPage(); |
| |
| protected: |
| QSize getChipSize() const; |
| void drawColorChip(QPainter &p, QRect &chipRect, TColorStyle *style); |
| void drawColorName(QPainter &p, QRect &nameRect, TColorStyle *style, |
| int styleIndex); |
| void drawToggleLink(QPainter &p, QRect &chipRect, TColorStyle *style); |
| |
| |
| void paintEvent(QPaintEvent *) override; |
| |
| void resizeEvent(QResizeEvent *) override; |
| |
| void mousePressEvent(QMouseEvent *event) override; |
| void mouseMoveEvent(QMouseEvent *event) override; |
| void mouseReleaseEvent(QMouseEvent *event) override; |
| |
| void mouseDoubleClickEvent(QMouseEvent *event) override; |
| void contextMenuEvent(QContextMenuEvent *event) override; |
| |
| void keyPressEvent(QKeyEvent *event) override; |
| void dragEnterEvent(QDragEnterEvent *event) override; |
| void dragMoveEvent(QDragMoveEvent *event) override; |
| void dropEvent(QDropEvent *event) override; |
| void dragLeaveEvent(QDragLeaveEvent *event) override; |
| void startDragDrop(); |
| void createMenuAction(QMenu &menu, const char *id, QString name, |
| const char *slot); |
| void showEvent(QShowEvent *) override; |
| void hideEvent(QHideEvent *) override; |
| |
| bool event(QEvent *e) override; |
| |
| void select(int indexInPage, QMouseEvent *event); |
| |
| void zoomInChip(); |
| void zoomOutChip(); |
| |
| bool hasShortcut(int indexInPage); |
| |
| private: |
| DVGui::LineEdit *m_renameTextField; |
| QPoint m_dragStartPosition; |
| |
| TPalette::Page *m_page; |
| QPoint m_chipsOrigin; |
| int m_chipPerRow; |
| ViewMode m_viewMode; |
| NameDisplayMode m_nameDisplayMode; |
| int m_dropPositionIndex; |
| bool m_dropPageCreated; |
| bool m_startDrag; |
| |
| TStyleSelection *m_styleSelection; |
| TFrameHandle *m_frameHandle; |
| bool m_hasPasteColors; |
| PaletteViewType m_viewType; |
| |
| ChangeStyleCommand *m_changeStyleCommand; |
| |
| QShortcut *m_zoomInShortCut; |
| QShortcut *m_zoomOutShortCut; |
| StyleNameEditor *m_styleNameEditor; |
| |
| signals: |
| void changeWindowTitleSignal(); |
| void switchToPage(int); |
| }; |
| |
| |
| |
| |
| |
| class DVAPI PaletteTabBar final : public QTabBar { |
| Q_OBJECT |
| |
| public: |
| PaletteTabBar(QWidget *parent, bool hasPageCommand); |
| |
| void setPageViewer(PageViewer *pageViewer) { m_pageViewer = pageViewer; } |
| |
| public slots: |
| |
| void updateTabName(); |
| |
| signals: |
| |
| void tabTextChanged(int index); |
| void movePage(int srcIndex, int dstIndex); |
| |
| protected: |
| void mousePressEvent(QMouseEvent *event) override; |
| void mouseMoveEvent(QMouseEvent *event) override; |
| void mouseDoubleClickEvent(QMouseEvent *event) override; |
| void dragEnterEvent(QDragEnterEvent *event) override; |
| void dragMoveEvent(QDragMoveEvent *event) override; |
| void dropEvent(QDropEvent *event) override; |
| |
| private: |
| DVGui::LineEdit *m_renameTextField; |
| int m_renameTabIndex; |
| PageViewer *m_pageViewer; |
| |
| bool m_hasPageCommand; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI PaletteIconWidget final : public QWidget { |
| Q_OBJECT |
| |
| public: |
| PaletteIconWidget(QWidget *parent = 0, |
| Qt::WindowFlags flags = Qt::WindowFlags()); |
| ~PaletteIconWidget(); |
| |
| signals: |
| |
| void startDrag(); |
| |
| protected: |
| void paintEvent(QPaintEvent *) override; |
| |
| void enterEvent(QEvent *event) override; |
| void leaveEvent(QEvent *event) override; |
| |
| void mousePressEvent(QMouseEvent *event) override; |
| void mouseMoveEvent(QMouseEvent *event) override; |
| |
| private: |
| QPoint m_mousePressPos; |
| bool m_isOver, |
| m_dragged; |
| }; |
| |
| } |
| |
| #endif |