Added basic metronome. Fixed a bug. Scope works.
[epichord.git] / src / trackinfo.cpp
blob347136cbd4c052584935a06d693561cbe17d1910
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 static std::vector<TrackModule*> modules;
39 extern std::vector<track*> tracks;
41 TrackInfo::TrackInfo(int x, int y, int w, int h, const char* label = 0) : fltk::Group(x, y, w, h, label)
43 begin();
45 TrackModule* mod;
46 for(int i=0; i<16; i++){
47 mod = new TrackModule(0,30*i,255,30,i);
48 mod->box(fltk::UP_BOX);
49 mod->index = i;
50 mod->set_channel(i);
51 modules.push_back(mod);
52 add(mod);
55 end();
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 for(int i=0; i<modules.size(); i++){
83 modules[i]->toggle();
85 //fltk::Group::redraw();
89 void TrackInfo::update(){
90 //for each child cast to TrackModule and call update
91 for(int i=0; i<children(); i++){
92 ((TrackModule*)child(i))->update();
96 void TrackInfo::unset_solo(){
97 for(int i=0; i<children(); i++){
98 ((TrackModule*)child(i))->unset_solo();
102 void TrackInfo::set_rec(int t){
103 for(int i=0; i<children(); i++){
104 if(t==i){
105 ((TrackModule*)child(i))->set_rec();
107 else{
108 ((TrackModule*)child(i))->unset_rec();