#pragma once #include "Document/EditorSession.h" #include "IO/ProjectController.h" #include "Rendering/EditorCanvas.h" #include "UI/FloatingPanel.h" #include "UI/ToolIcons.h" #include #include #include #include #include #include #include #include class LayersPanel; class MaskAloneBadge; class ToolButton; class ProjectWorkspace; class QFileDialog; class QMimeData; class QMessageBox; class QProgressBar; // One project's editor area: bar, rail, canvas, status. class ContentView : public QWidget { Q_OBJECT public: // Without a controller, Open project has nowhere to go. explicit ContentView(EditorSession &session, ProjectController *projects = nullptr, QWidget *parent = nullptr); ~ContentView() override; // The status bar's words for a tool, by its kind. static QString hint(NavigationTool tool, ToolIconKind kind = ToolIconKind::plain, BlurToolMode smear = BlurToolMode::liquify, ShapeKind shape = ShapeKind::rectangle); // Zoom as Swift prints it: percent, one decimal at most. static QString percent(double zoom); // The Layers panel's width, remembered across launches. static double layersPanelWidth(); static void setLayersPanelWidth(double width); LayersPanel &layersPanel() const { return *m_layersPanel; } // Drops of layers from other tabs go to the workspace. void setWorkspace(ProjectWorkspace *workspace) { m_workspace = workspace; } bool acceptsDrop(const QMimeData &data) const; protected: void dragEnterEvent(QDragEnterEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; void dragLeaveEvent(QDragLeaveEvent *event) override; void dropEvent(QDropEvent *event) override; private: void synchronize(); // Swift's onChange of levels: its panel opens and closes. void synchronizePanels(); void showConversionSheet(); void showRawDevelopSheet(); ToolIconKind iconKind(NavigationTool tool) const; void showHeader(NavigationTool tool); void showWelcome(bool shown); void showImporter(); void showAlert(QPointer &alert, const QString &title, const std::optional &message, const std::function &dismiss); EditorSession &m_session; const QPointer m_projects; QVBoxLayout *const m_column; QWidget *m_header = nullptr; std::optional m_shownTool; std::vector> m_toolButtons; QGridLayout *const m_canvasSlot; CanvasView *const m_canvas; LayersPanel *const m_layersPanel; // Swift's docked panel: a slot at the window's right. QWidget *const m_dock; // An accent ring while a drop may land. QWidget *const m_dropRing; // Over the canvas's foot while a mask shows alone. MaskAloneBadge *const m_maskAloneBadge; // Swift 1.1.7's rulers: the corner, then the two strips. std::vector m_rulers; ProjectWorkspace *m_workspace = nullptr; // A document that appears hands the canvas the keys. bool m_hadDocument = false; QWidget *m_welcome = nullptr; QLabel *const m_zoom; QLabel *const m_dimensions; QLabel *const m_colour; QLabel *const m_activity; QProgressBar *const m_spinner; QPointer m_importer; // The Photoshop sheet and the request it shows. QPointer m_conversionSheet; std::optional m_conversionShown; QPointer m_rawSheet; QPointer m_importAlert; QPointer m_brushAlert; QPointer m_cropAlert; FloatingPanel m_levelsPanel{QStringLiteral("levelsPanel"), *this}; bool m_levelsShown = false; FloatingPanel m_adjustmentPanel{QStringLiteral("adjustmentPanel"), *this}; bool m_hueSaturationShown = false; FloatingPanel m_filterPanel{QStringLiteral("filterPanel"), *this}; bool m_filterShown = false; FloatingPanel m_effectsPanel{QStringLiteral("effectsPanel"), *this}; FloatingPanel m_selectionAmountPanel{QStringLiteral("selectionAmountPanel"), *this}; std::optional m_selectionAmountShown; FloatingPanel m_colorRangePanel{QStringLiteral("colorRangePanel"), *this}; bool m_colorRangeShown = false; std::optional m_effectsShown; };