A canceled load or import does not erase the song.
[epichord.git] / src / trackinfo.cpp
blobcddecafa94809c30cc15637f0ee4ca3048b69169
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();
54 settings = 0;
58 int TrackInfo::handle(int event){
59 switch(event){
60 case fltk::SHORTCUT:
61 return 0;
63 return Group::handle(event);
66 void TrackInfo::draw(){
67 fltk::push_clip(0,0,w(),h());
68 for(int i=0; i<children(); i++){
69 child(i)->y(i*30 - scroll);
71 Group::draw();
72 fltk::pop_clip();
75 void TrackInfo::layout(){
76 for(int i=0; i<children(); i++){
77 child(i)->h(30);
81 void TrackInfo::toggle_controls(){
82 if(settings==0){settings=1;}
83 else{settings=0;}
84 for(int i=0; i<children(); i++){
85 ((TrackModule*)child(i))->toggle_controls(settings);
90 void TrackInfo::update(){
91 //for each child cast to TrackModule and call update
92 for(int i=0; i<children(); i++){
93 ((TrackModule*)child(i))->update();
97 void TrackInfo::unset_solo(){
98 for(int i=0; i<children(); i++){
99 ((TrackModule*)child(i))->unset_solo();
103 void TrackInfo::set_rec(int t){
104 for(int i=0; i<children(); i++){
105 if(t==i){
106 ((TrackModule*)child(i))->set_rec();
108 else{
109 ((TrackModule*)child(i))->unset_rec();
116 void TrackInfo::clear_tracks(){
117 clear();
120 void TrackInfo::add_track(){
121 int i = tracks.size()-1;
122 TrackModule* mod = new TrackModule(0,30*i,255,30,i);
124 mod->box(fltk::UP_BOX);
125 mod->index = i;
126 mod->set_channel(i%16);
128 add(mod);
130 mod->toggle_controls(settings);
133 void TrackInfo::del_track(int n){