Horizon
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 
7 namespace horizon {
8 class DragSelection {
9  friend class CanvasGL;
10  friend class Box;
11 
12 public:
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 
21 private:
22  CanvasGL *ca;
23 
24  int active;
25  Coordf sel_o;
26 
27  class Box {
28  public:
29  Box(class DragSelection *s) : parent(s), ca(parent->ca)
30  {
31  }
32  void realize();
33  void render();
34  class DragSelection *parent;
35  CanvasGL *ca;
36 
37  GLuint program;
38  GLuint vao;
39  GLuint vbo;
40 
41  GLuint screenmat_loc;
42  GLuint viewmat_loc;
43  GLuint scale_loc;
44  GLuint a_loc;
45  GLuint b_loc;
46  GLuint fill_loc;
47  GLuint color_loc;
48 
49  Coordf sel_a;
50  Coordf sel_b;
51  bool fill = true;
52 
53  void update();
54  };
55  Box box;
56 
57  class Line {
58  public:
59  Line(class DragSelection *s) : parent(s), ca(parent->ca)
60  {
61  }
62  void realize();
63  void render();
64  void push();
65  void create_vao();
66  class DragSelection *parent;
67  CanvasGL *ca;
68 
69  GLuint program;
70  GLuint vao;
71  GLuint vbo;
72 
73  GLuint screenmat_loc;
74  GLuint viewmat_loc;
75  GLuint scale_loc;
76  GLuint color_loc;
77 
78  class Vertex {
79  public:
80  Vertex(float ix, float iy) : x(ix), y(iy)
81  {
82  }
83 
84  float x, y;
85  };
86 
87  std::vector<Vertex> vertices;
88  ClipperLib::Path path;
89 
90  void update();
91  };
92  Line line;
93 };
94 } // namespace horizon
horizon::CanvasGL
Definition: canvas_gl.hpp:15
horizon::DragSelection
Definition: drag_selection.hpp:8
horizon::DragSelection::Line::Vertex
Definition: drag_selection.hpp:78
horizon::Coord< float >