summaryrefslogtreecommitdiff
path: root/src/gui/elems/ge_actionChannel.h
blob: 67413fdfc8f6c3557a0db273171c65f361ce9eb8 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* ---------------------------------------------------------------------
 *
 * Giada - Your Hardcore Loopmachine
 *
 * ge_actionChannel
 *
 * ---------------------------------------------------------------------
 *
 * Copyright (C) 2010-2015 Giovanni A. Zuliani | Monocasual
 *
 * This file is part of Giada - Your Hardcore Loopmachine.
 *
 * Giada - Your Hardcore Loopmachine is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *
 * Giada - Your Hardcore Loopmachine is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Giada - Your Hardcore Loopmachine. If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------ */

#ifndef GE_ACTIONCHANNEL_H
#define GE_ACTIONCHANNEL_H

#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include "../../utils/gui_utils.h"
#include "../../core/mixer.h"
#include "../../core/recorder.h"
#include "ge_actionWidget.h"


class gAction : public Fl_Box {

private:

	bool                  selected;
	unsigned              index;
  class gdActionEditor *parent;   // pointer to parent (gActionEditor)
	class SampleChannel  *ch;
  char                  type;     // type of action

public:
	gAction(int x, int y, int h, int frame_a, unsigned index,
				  gdActionEditor *parent, class SampleChannel *ch, bool record,
			    char type);
	void draw();
	int  handle(int e);
	void addAction();
	void delAction();

	/* moveAction
	 * shift the action on the x-axis and update Recorder. If frame_a != -1
	 * use the new frame in input (used while snapping) */

	void moveAction(int frame_a=-1);

	/* absx
	 * x() is relative to scrolling position. absx() returns the absolute
	 * x value of the action, from the leftmost edge. */

	int  absx();

	/* xToFrame_a,b
	 * return the real frames of x() position */

	int xToFrame_a();
	int xToFrame_b();

	int frame_a;  // initial frame (KEYPRESS for singlemode.press)
	int frame_b;  // terminal frame (KEYREL for singlemode.press, null for others)

	bool onRightEdge;
	bool onLeftEdge;

	static const int MIN_WIDTH;
};


/* ------------------------------------------------------------------ */


class gActionChannel : public gActionWidget {

private:

	class SampleChannel *ch;

	/* getSelectedAction
	 * get the action under the mouse. NULL if nothing found. */

	gAction *getSelectedAction();

	/* selected
	 * pointer to the selected action. Useful when dragging around. */

	gAction *selected;

	/* actionOriginalX, actionOriginalW
	 * x and w of the action, when moved. Useful for checking if the action
	 * overlaps another one: in that case the moved action returns to
	 * actionOriginalX (and to actionOriginalW if resized). */

	int actionOriginalX;
	int actionOriginalW;

	/* actionPickPoint
	 * the precise x point in which the action has been picked with the mouse,
	 * before a dragging action. */

	int actionPickPoint;


	/* actionCollides
	 * true if an action collides with another. Used while adding new points
	 * with snap active.*/

	bool actionCollides(int frame);

public:
	gActionChannel(int x, int y, gdActionEditor *pParent, class SampleChannel *ch);
	void draw();
	int  handle(int e);
	void updateActions();
};


#endif