blob: cbd34823d1c06adaab444c08d67aa167ee79f025 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#ifndef __gtk_ardour_matrix_h__
#define __gtk_ardour_matrix_h__
#include <list>
#include <vector>
#include <string>
#include <stdint.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/widget.h>
#include "port_group.h"
class OtherPort {
public:
OtherPort (const std::string& n, PortGroup& g)
: _name (n), _group (g) {}
std::string name() const { return _name; }
PortGroup& group() const { return _group; }
bool visible() const { return _group.visible; }
public:
std::string _name;
PortGroup& _group;
};
class MatrixNode {
public:
MatrixNode (std::string a, OtherPort o, int32_t x, int32_t y)
: _name (a), them (o), _connected (random()%3), _x(x), _y(y) {}
~MatrixNode() {}
PortGroup& get_group() const { return them.group(); }
std::string our_name() const { return _name; }
std::string their_name() const { return them.name(); }
bool connected() const { return _connected; }
void set_connected (bool yn) { _connected = yn; }
int32_t x() const { return _x; }
int32_t y() const { return _y; }
private:
std::string _name;
OtherPort them;
bool _connected;
int32_t _x;
int32_t _y;
};
class Matrix : public Gtk::EventBox
{
public:
Matrix();
void set_ports (const std::list<std::string>&);
void add_group (PortGroup&);
void remove_group (PortGroup&);
void hide_group (PortGroup&);
void show_group (PortGroup&);
void clear ();
int row_spacing () const { return xstep; }
protected:
bool on_button_press_event (GdkEventButton* ev);
bool on_expose_event (GdkEventExpose* ev);
void on_size_allocate (Gtk::Allocation&);
void on_size_request (Gtk::Requisition*);
void on_realize ();
bool on_motion_notify_event (GdkEventMotion*);
bool on_leave_notify_event (GdkEventCrossing*);
MatrixNode* get_node (int32_t x, int32_t y);
private:
int height;
int width;
int alloc_width;
int alloc_height;
bool drawn;
int labels_y_shift;
int labels_x_shift;
float angle_radians;
int border;
int ystep;
int xstep;
uint32_t line_height;
uint32_t line_width;
int arc_radius;
int32_t motion_x;
int32_t motion_y;
std::list<std::string> ours;
std::list<OtherPort> others;
std::vector<MatrixNode*> nodes;
void reset_size ();
void redraw (GdkDrawable*, GdkRectangle*);
void alloc_pixmap ();
void setup_nodes ();
GdkPixmap* pixmap;
};
#endif /* __gtk_ardour_matrix_h__ */
|