Olive
graphview.h
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef GRAPHVIEW_H
22 #define GRAPHVIEW_H
23 
24 #include <QWidget>
25 #include <QVector>
26 
27 class EffectRow;
28 class EffectField;
29 
30 QColor get_curve_color(int index, int length);
31 
32 class GraphView : public QWidget {
33  Q_OBJECT
34 public:
35  GraphView(QWidget* parent = 0);
36 
37  void paintEvent(QPaintEvent *event);
38  void mousePressEvent(QMouseEvent *event);
39  void mouseMoveEvent(QMouseEvent *event);
40  void mouseReleaseEvent(QMouseEvent *event);
41  void wheelEvent(QWheelEvent *event);
42 
43  void set_row(EffectRow* r);
44 
45  void set_selected_keyframe_type(int type);
46  void set_field_visibility(int field, bool b);
47 
48  void delete_selected_keys();
49  void select_all();
50 signals:
51  void x_scroll_changed(int);
52  void y_scroll_changed(int);
53  void zoom_changed(double, double);
54  void selection_changed(bool, int);
55 private:
56  int x_scroll;
57  int y_scroll;
58  bool mousedown;
59  int start_x;
60  int start_y;
61 
62  double x_zoom;
63  double y_zoom;
64 
65  void set_scroll_x(int s);
66  void set_scroll_y(int s);
67  void set_zoom(double xz, double yz);
68 
69  int get_screen_x(double);
70  int get_screen_y(double);
71  long get_value_x(int);
72  double get_value_y(int);
73 
74  void selection_update();
75 
76  QVector<bool> field_visibility;
77 
78  QVector<int> selected_keys;
79  QVector<int> selected_keys_fields;
80  QVector<long> selected_keys_old_vals;
81  QVector<double> selected_keys_old_doubles;
82 
83  double old_pre_handle_x;
84  double old_pre_handle_y;
85  double old_post_handle_x;
86  double old_post_handle_y;
87 
88  int handle_field;
89  int handle_index;
90 
91  bool moved_keys;
92 
93  int current_handle;
94 
95  void draw_lines(QPainter &p, bool vert);
96  void draw_line_text(QPainter &p, bool vert, int line_no, int line_pos, int next_line_pos);
97 
98  EffectRow* row;
99 
100  bool rect_select;
101  int rect_select_x;
102  int rect_select_y;
103  int rect_select_w;
104  int rect_select_h;
105  int rect_select_offset;
106 
107  long visible_in;
108 
109  bool click_add;
110  bool click_add_proc;
111  EffectField* click_add_field;
112  int click_add_key;
113  int click_add_type;
114 private slots:
115  void show_context_menu(const QPoint& pos);
116  void reset_view();
117  void set_view_to_selection();
118  void set_view_to_all();
119  void set_view_to_rect(int x1, double y1, int x2, double y2);
120 };
121 
122 #endif // GRAPHVIEW_H
Definition: effectrow.h:37
Definition: graphview.h:32
Definition: effectfield.h:43