1
package org.herac.tuxguitar.gui.mixer;
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;
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;
29
public TrackMixer(SongMixer mixer,SongTrack track){
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));
39
this.channelLabel = new Label(composite, SWT.NULL);
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);
49
mixer.fireChanges(track.getChannel());
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);
60
mixer.fireChanges(track.getChannel());
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());
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));
80
this.volumeText = new Text(composite, SWT.BORDER | SWT.SINGLE | SWT.CENTER);
81
this.volumeText.setEditable(false);
82
this.volumeText.setLayoutData(getVolumeTextData());
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());
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());
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()));
106
private GridData getBalanceScaleData(){
107
GridData data = new GridData(SWT.CENTER,SWT.NONE,false,true);
112
private GridData getVolumeTextData(){
113
GridData data = new GridData(SWT.CENTER,SWT.NONE,true,false);
114
data.minimumWidth = 40;
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()));
125
public SongTrack getTrack(){
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());