Mouse wheel now scrolls horizontally in piano roll.
[epichord.git] / src / trackinfo.cpp
blob75fc483533c0940baacaf2c45af84e6d0dcb0f46
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 scroll = 0;
56 settings = 0;
60 int TrackInfo::handle(int event){
61 switch(event){
62 case fltk::SHORTCUT:
63 return 0;
65 return Group::handle(event);
68 void TrackInfo::draw(){
69 fltk::push_clip(0,0,w(),h());
70 for(int i=0; i<children(); i++){
71 child(i)->y(i*30 - scroll);
73 Group::draw();
74 fltk::pop_clip();
77 void TrackInfo::layout(){
78 for(int i=0; i<children(); i++){
79 child(i)->h(30);
83 void TrackInfo::toggle_controls(){
84 if(settings==0){settings=1;}
85 else{settings=0;}
86 for(int i=0; i<children(); i++){
87 ((TrackModule*)child(i))->toggle_controls(settings);
92 void TrackInfo::dynamic_update(){
93 //for each child cast to TrackModule and call update
94 for(int i=0; i<children(); i++){
95 ((TrackModule*)child(i))->dynamic_update();
99 void TrackInfo::update(){
100 //for each child cast to TrackModule and call update
101 for(int i=0; i<children(); i++){
102 ((TrackModule*)child(i))->update();
106 void TrackInfo::unset_solo(){
107 for(int i=0; i<children(); i++){
108 ((TrackModule*)child(i))->unset_solo();
112 void TrackInfo::set_rec(int t){
113 for(int i=0; i<children(); i++){
114 if(t==i){
115 ((TrackModule*)child(i))->set_rec();
117 else{
118 ((TrackModule*)child(i))->unset_rec();
125 void TrackInfo::clear_tracks(){
126 clear();
129 void TrackInfo::add_track(){
130 int i = tracks.size()-1;
131 TrackModule* mod = new TrackModule(0,30*i,255,30,i);
133 mod->box(fltk::UP_BOX);
134 mod->index = i;
135 mod->set_channel(i%16);
137 add(mod);
139 mod->toggle_controls(settings);
142 void TrackInfo::del_track(int n){