diff options
Diffstat (limited to 'src/gui/elems/ge_envelopeChannel.h')
-rw-r--r-- | src/gui/elems/ge_envelopeChannel.h | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/src/gui/elems/ge_envelopeChannel.h b/src/gui/elems/ge_envelopeChannel.h new file mode 100644 index 0000000..0bb7039 --- /dev/null +++ b/src/gui/elems/ge_envelopeChannel.h @@ -0,0 +1,115 @@ +/* --------------------------------------------------------------------- + * + * Giada - Your Hardcore Loopmachine + * + * ge_envelopeWidget + * + * parent class of any envelope controller, from volume to VST parameter + * automations. + * + * --------------------------------------------------------------------- + * + * 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_ENVELOPECHANNEL_H__ +#define __GE_ENVELOPECHANNEL_H__ + +#include <FL/Fl.H> +#include <FL/Fl_Group.H> +#include "../../utils/utils.h" +#include "ge_actionWidget.h" + + +class gEnvelopeChannel : public gActionWidget { + + const char *l; // internal label + int type; // type of action + int range; + + /* point + * a single dot in the graph. x = relative frame, y = relative value */ + + struct point { + int frame; + int iValue; + float fValue; + int x; + int y; + }; + + /* points + * array of points, filled by fillPoints() */ + + gVector<point> points; + + /* selectedPoint + * which point we are selecting? */ + + int selectedPoint; + + /* draggedPoint + * which point we are dragging? */ + + int draggedPoint; + + /* previousXPoint + * x coordinate of point at time t-1. Used to check effective shifts */ + + int previousXPoint; + + void draw(); + + int handle(int e); + + int getSelectedPoint(); + + void sortPoints(); + + /* verticalPoint + * check if two points form a vertical line. In that case the frame value + * would be the same and recorder would go crazy, so shift by a small value + * of frames to create a minimal fadein/fadeout level. Return 0: no + * vertical points; return 1: vertical with the next one, return -1: vertical + * with the previous one. */ + + int verticalPoint(const point &p); + +public: + gEnvelopeChannel(int x, int y, gdActionEditor *pParent, int type, int range, const char *l); + ~gEnvelopeChannel(); + + /* addPoint + * add a point made of frame+value to internal points[]. */ + + void addPoint(int frame, int iValue=0, float fValue=0.0f, int x=-1, int y=-1); + + void updateActions(); + + /* fill + * parse recorder's stack and fill the widget with points. It's up to + * the caller to call this method as initialization. */ + + void fill(); + + inline void clearPoints() { points.clear(); } +}; + +#endif |