~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/mixer/TrackMixer.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2007-02-04 01:41:23 UTC
  • Revision ID: james.westby@ubuntu.com-20070204014123-9pv7okph0iaiqkvw
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.gui.mixer;
 
2
 
 
3
import org.eclipse.swt.SWT;
 
4
import org.eclipse.swt.events.SelectionAdapter;
 
5
import org.eclipse.swt.events.SelectionEvent;
 
6
import org.eclipse.swt.layout.GridData;
 
7
import org.eclipse.swt.layout.GridLayout;
 
8
import org.eclipse.swt.widgets.Button;
 
9
import org.eclipse.swt.widgets.Composite;
 
10
import org.eclipse.swt.widgets.Event;
 
11
import org.eclipse.swt.widgets.Label;
 
12
import org.eclipse.swt.widgets.Listener;
 
13
import org.eclipse.swt.widgets.Scale;
 
14
import org.eclipse.swt.widgets.Text;
 
15
import org.herac.tuxguitar.gui.TuxGuitar;
 
16
import org.herac.tuxguitar.song.models.SongTrack;
 
17
 
 
18
public class TrackMixer {
 
19
        private SongMixer mixer;
 
20
        private SongTrack track;
 
21
        private Button soloCheckBox;
 
22
        private Button muteCheckBox;
 
23
        private Scale balanceScale;
 
24
        private Scale volumeScale;
 
25
        private Text volumeText;
 
26
        private Label channelLabel;
 
27
    private Label volumeLabel;
 
28
    
 
29
        public TrackMixer(SongMixer mixer,SongTrack track){
 
30
                this.mixer = mixer;
 
31
                this.track = track;
 
32
        }
 
33
        
 
34
        public void init(final Composite parent) {
 
35
                final Composite composite = new Composite(parent, SWT.NONE);
 
36
                composite.setLayout(new GridLayout(1, true));
 
37
                composite.setLayoutData(new GridData(SWT.CENTER,SWT.FILL,true,true));
 
38
                
 
39
                this.channelLabel = new Label(composite, SWT.NULL);             
 
40
                
 
41
                this.soloCheckBox = new Button(composite,SWT.CHECK);
 
42
                this.soloCheckBox.setSelection(track.getChannel().isSolo());
 
43
                this.soloCheckBox.addSelectionListener(new SelectionAdapter() { 
 
44
                        public void widgetSelected(SelectionEvent e) {
 
45
                                track.getChannel().setSolo(soloCheckBox.getSelection());
 
46
                                if(track.getChannel().isSolo()){
 
47
                                        track.getChannel().setMute(false);
 
48
                                }
 
49
                                mixer.fireChanges(track.getChannel());
 
50
                        }               
 
51
                });
 
52
                this.muteCheckBox = new Button(composite,SWT.CHECK);
 
53
                this.muteCheckBox.setSelection(track.getChannel().isMute());
 
54
                this.muteCheckBox.addSelectionListener(new SelectionAdapter() { 
 
55
                        public void widgetSelected(SelectionEvent e) {
 
56
                                track.getChannel().setMute(muteCheckBox.getSelection());
 
57
                                if(track.getChannel().isMute()){
 
58
                                        track.getChannel().setSolo(false);
 
59
                                }                               
 
60
                                mixer.fireChanges(track.getChannel());
 
61
                        }               
 
62
                });
 
63
                
 
64
                this.balanceScale = new Scale(composite, SWT.HORIZONTAL);
 
65
                this.balanceScale.setMaximum(127);
 
66
                this.balanceScale.setMinimum(0);
 
67
                this.balanceScale.setIncrement(1);
 
68
                this.balanceScale.setPageIncrement(64);
 
69
                this.balanceScale.setSize(300,50);
 
70
                this.balanceScale.setLayoutData(getBalanceScaleData());                         
 
71
                
 
72
                this.volumeLabel = new Label(composite, SWT.NULL);
 
73
                this.volumeScale = new Scale(composite, SWT.VERTICAL);
 
74
                this.volumeScale.setMaximum(127);
 
75
                this.volumeScale.setMinimum(0);
 
76
                this.volumeScale.setIncrement(1);
 
77
                this.volumeScale.setPageIncrement(16);
 
78
                this.volumeScale.setLayoutData(new GridData(SWT.CENTER,SWT.FILL,true,true));            
 
79
                
 
80
                this.volumeText = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.CENTER);
 
81
                this.volumeText.setEditable(false);
 
82
                this.volumeText.setLayoutData(getVolumeTextData());
 
83
 
 
84
                this.balanceScale.addListener(SWT.Selection, new Listener() {
 
85
                        public void handleEvent(Event event) {
 
86
                                track.getChannel().setBalance((short)balanceScale.getSelection());
 
87
                                balanceScale.setToolTipText(TuxGuitar.getProperty("track.channel.balance") + ": " + track.getChannel().getBalance());
 
88
                                mixer.fireChanges(track.getChannel());
 
89
                        }
 
90
                });
 
91
                
 
92
                this.volumeScale.addListener(SWT.Selection, new Listener() {
 
93
                        public void handleEvent(Event event) {
 
94
                                track.getChannel().setVolume((short)(volumeScale.getMaximum() - volumeScale.getSelection()));
 
95
                                volumeScale.setToolTipText(TuxGuitar.getProperty("track.channel.volume") + ": " + track.getChannel().getVolume());
 
96
                                mixer.fireChanges(track.getChannel());
 
97
                        }
 
98
                });
 
99
 
 
100
                this.balanceScale.setSelection(track.getChannel().getBalance());
 
101
                this.balanceScale.setToolTipText("Balance: " + track.getChannel().getBalance());
 
102
                this.volumeScale.setSelection(this.volumeScale.getMaximum() - track.getChannel().getVolume());
 
103
                this.volumeText.setText(Integer.toString(this.volumeScale.getMaximum() - this.volumeScale.getSelection()));
 
104
        }
 
105
        
 
106
        private GridData getBalanceScaleData(){
 
107
                GridData data = new GridData(SWT.CENTER,SWT.NONE,false,true);           
 
108
                data.widthHint = 65;            
 
109
                return data;
 
110
        }
 
111
        
 
112
        private GridData getVolumeTextData(){
 
113
                GridData data = new GridData(SWT.CENTER,SWT.NONE,true,false);           
 
114
                data.minimumWidth = 40;         
 
115
                return data;
 
116
        }
 
117
        
 
118
        public void fireChanges(){
 
119
                this.soloCheckBox.setSelection(track.getChannel().isSolo());
 
120
                this.muteCheckBox.setSelection(track.getChannel().isMute());
 
121
                this.volumeScale.setSelection(this.volumeScale.getMaximum() - track.getChannel().getVolume());
 
122
                this.volumeText.setText(Integer.toString(this.volumeScale.getMaximum() - this.volumeScale.getSelection()));
 
123
        }
 
124
        
 
125
        public SongTrack getTrack(){
 
126
                return this.track;
 
127
        }
 
128
        
 
129
        public void loadProperties(){
 
130
                this.channelLabel.setText("CH:" + track.getChannel().getChannel() + " EC:" + track.getChannel().getEffectChannel());
 
131
                this.soloCheckBox.setText(TuxGuitar.getProperty("track.channel.solo"));
 
132
                this.muteCheckBox.setText(TuxGuitar.getProperty("track.channel.mute"));
 
133
                this.volumeLabel.setText(TuxGuitar.getProperty("track.channel.volume") + ":");
 
134
                this.volumeScale.setToolTipText(TuxGuitar.getProperty("track.channel.volume") + ": " + track.getChannel().getVolume());
 
135
                this.balanceScale.setToolTipText(TuxGuitar.getProperty("track.channel.balance") + ": " + track.getChannel().getBalance());
 
136
        }
 
137
        
 
138
}