Horizon
Loading...
Searching...
No Matches
drag_selection.hpp
1#pragma once
2#include "clipper/clipper.hpp"
3#include "common/common.hpp"
4#include <epoxy/gl.h>
5#include <gtkmm.h>
6
7namespace horizon {
9 friend class CanvasGL;
10 friend class Box;
11
12public:
13 DragSelection(class CanvasGL &c);
14 void realize();
15 void render();
16 void push();
17 void drag_begin(GdkEventButton *button_event);
18 void drag_end(GdkEventButton *button_event);
19 void drag_move(GdkEventMotion *motion_event);
20
21private:
22 CanvasGL &ca;
23
24 int active;
25 Coordf sel_o;
26
27 class Box {
28 public:
29 Box(class CanvasGL &c) : ca(c)
30 {
31 }
32 void realize();
33 void render();
34 CanvasGL &ca;
35
36 GLuint program;
37 GLuint vao;
38 GLuint vbo;
39
40 GLuint screenmat_loc;
41 GLuint viewmat_loc;
42 GLuint scale_loc;
43 GLuint a_loc;
44 GLuint b_loc;
45 GLuint fill_loc;
46 GLuint color_loc;
47
48 Coordf sel_a;
49 Coordf sel_b;
50 bool fill = true;
51
52 void update();
53 };
54 Box box;
55
56 class Line {
57 public:
58 Line(class CanvasGL &c) : ca(c)
59 {
60 }
61 void realize();
62 void render();
63 void push();
64 void create_vao();
65 CanvasGL &ca;
66
67 GLuint program;
68 GLuint vao;
69 GLuint vbo;
70
71 GLuint screenmat_loc;
72 GLuint viewmat_loc;
73 GLuint scale_loc;
74 GLuint color_loc;
75
76 class Vertex {
77 public:
78 Vertex(float ix, float iy) : x(ix), y(iy)
79 {
80 }
81
82 float x, y;
83 };
84
85 std::vector<Vertex> vertices;
86 size_t n_vertices = 0;
87 ClipperLib::Path path;
88
89 void update();
90 };
91 Line line;
92};
93} // namespace horizon
Definition canvas_gl.hpp:20
Definition drag_selection.hpp:76
Definition drag_selection.hpp:8