1 // Copyright (C) 2012-2019 The VPaint Developers.
2 // See the COPYRIGHT file at the top-level directory of this distribution
3 // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef MULTI_VIEW_H
18 #define MULTI_VIEW_H
19 
20 #include <QWidget>
21 #include <QList>
22 #include <QGridLayout>
23 
24 class Scene;
25 class View;
26 class ViewWidget;
27 class QSplitter;
28 class GLWidget;
29 
30 #include "ViewSettings.h"
31 
32 class MultiView: public QWidget
33 {
34     Q_OBJECT
35 
36 public:
37     MultiView(Scene *scene, QWidget *parent);
38     ~MultiView();
39 
40     void keyPressEvent(QKeyEvent *event);
41     void keyReleaseEvent(QKeyEvent *event);
42 
43     View * activeView() const;
44     View * hoveredView() const;
45     double zoom() const;
46     int numViews() const;
47 
48     void setActiveView(View * view);
49 
50 public slots:
51     void update();        // update only the views in MultiView (not the 3D view)
52     void updatePicking(); // update only the views in MultiView (not the 3D view)
53 
54     void zoomIn();
55     void zoomOut();
56     void fitAllInWindow();
57     void fitSelectionInWindow();
58 
59     // Splitting
60     void splitVertical();
61     void splitHorizontal();
62     void splitClose();
63     void splitOne();
64 
65     // Display mode
66     void toggleOutline();
67     void toggleOutlineOnly();
68     void setDisplayMode(ViewSettings::DisplayMode displayMode);
69 
70     void setOnionSkinningEnabled(bool enabled);
71 
72 signals:
73     void allViewsNeedToUpdate();        // update all views (including these and the 3D view)
74     void allViewsNeedToUpdatePicking(); // update all views (including these and the 3D view)
75     void activeViewChanged();
76     void hoveredViewChanged();
77     void cameraChanged();
78     void settingsChanged();
79 
80 private slots:
81     void setActive(GLWidget * w);
82     void setHovered(GLWidget * w);
83     void unsetHovered(GLWidget * w);
84 
85 private:
86     // private members
87     QList<ViewWidget*> views_;
88     View * activeView_;
89     View * hoveredView_;
90     Scene * scene_;
91 
92     // helper methods
93     View * createView_();
94     void deleteView_(View * view);
95     void split_(Qt::Orientation orientation);
96     void split_(View * view, Qt::Orientation orientation);
97     void splitClose_(View * view);
98 };
99 
100 #endif
101