Import text events as song info.
[epichord.git] / src / trackinfo.cpp
blob880496ffce8d3430a07787c67f204569e3071cf1
1 /*
2 Epichord - a midi sequencer
3 Copyright (C) 2008 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
23 #include <stdio.h>
24 #include <unistd.h>
26 #include <fltk/Group.h>
27 #include <fltk/Widget.h>
28 #include <fltk/events.h>
30 #include <vector>
31 #include "ui.h"
35 extern UI* ui;
37 extern std::vector<track*> tracks;
39 TrackInfo::TrackInfo(int x, int y, int w, int h, const char* label = 0) : fltk::Group(x, y, w, h, label)
41 //begin();
43 //TrackModule* mod;
44 //for(int i=0; i<16; i++){
45 //mod = new TrackModule(0,30*i,255,30,i);
46 //mod->box(fltk::UP_BOX);
47 //mod->index = i;
48 //mod->set_channel(i);
49 //add(mod);
50 // }
52 //end();
55 int TrackInfo::handle(int event){
56 switch(event){
57 case fltk::SHORTCUT:
58 return 0;
60 return Group::handle(event);
63 void TrackInfo::draw(){
64 fltk::push_clip(0,0,w(),h());
65 for(int i=0; i<children(); i++){
66 child(i)->y(i*30 - scroll);
68 Group::draw();
69 fltk::pop_clip();
72 void TrackInfo::layout(){
73 for(int i=0; i<children(); i++){
74 child(i)->h(30);
78 void TrackInfo::toggle_controls(){
79 for(int i=0; i<children(); i++){
80 ((TrackModule*)child(i))->toggle();
85 void TrackInfo::update(){
86 //for each child cast to TrackModule and call update
87 for(int i=0; i<children(); i++){
88 ((TrackModule*)child(i))->update();
92 void TrackInfo::unset_solo(){
93 for(int i=0; i<children(); i++){
94 ((TrackModule*)child(i))->unset_solo();
98 void TrackInfo::set_rec(int t){
99 for(int i=0; i<children(); i++){
100 if(t==i){
101 ((TrackModule*)child(i))->set_rec();
103 else{
104 ((TrackModule*)child(i))->unset_rec();
111 void TrackInfo::clear_tracks(){
112 clear();
115 void TrackInfo::add_track(){
116 int i = tracks.size()-1;
117 TrackModule* mod = new TrackModule(0,30*i,255,30,i);
119 mod->box(fltk::UP_BOX);
120 mod->index = i;
121 mod->set_channel(i%16);
123 add(mod);
126 void TrackInfo::del_track(int n){