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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/items/tool/DynamicToolItems.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Created on 02-dic-2005
 
3
 *
 
4
 * TODO To change the template for this generated file go to
 
5
 * Window - Preferences - Java - Code Style - Code Templates
 
6
 */
 
7
package org.herac.tuxguitar.gui.items.tool;
 
8
 
 
9
import org.eclipse.swt.SWT;
 
10
import org.eclipse.swt.widgets.ToolBar;
 
11
import org.eclipse.swt.widgets.ToolItem;
 
12
import org.herac.tuxguitar.gui.TuxGuitar;
 
13
import org.herac.tuxguitar.gui.actions.note.ChangeVelocityAction;
 
14
import org.herac.tuxguitar.gui.editors.tab.Caret;
 
15
import org.herac.tuxguitar.gui.items.ToolItems;
 
16
import org.herac.tuxguitar.song.models.TGVelocities;
 
17
/**
 
18
 * @author julian
 
19
 *
 
20
 * TODO To change the template for this generated type comment go to
 
21
 * Window - Preferences - Java - Code Style - Code Templates
 
22
 */
 
23
public class DynamicToolItems  extends ToolItems{
 
24
        public static final String NAME = "dynamic.items";
 
25
        
 
26
        private ToolBar toolBar;
 
27
        
 
28
        private ToolItem pianoPianissimo;
 
29
        private ToolItem pianissimo;
 
30
        private ToolItem piano;
 
31
        private ToolItem mezzoPiano;
 
32
        private ToolItem mezzoForte;
 
33
        private ToolItem forte;
 
34
        private ToolItem fortissimo;
 
35
        private ToolItem forteFortissimo;
 
36
        
 
37
        
 
38
        public DynamicToolItems(){
 
39
                super(NAME);
 
40
        }
 
41
        
 
42
        public void showItems(ToolBar toolBar){
 
43
                this.toolBar = toolBar;
 
44
                //--PPP--
 
45
                this.pianoPianissimo = new ToolItem(this.toolBar, SWT.CHECK);
 
46
                this.pianoPianissimo.setData(new Integer(TGVelocities.PIANO_PIANISSIMO));
 
47
                this.pianoPianissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
48
                
 
49
                //--PP--
 
50
                this.pianissimo = new ToolItem(this.toolBar, SWT.CHECK);
 
51
                this.pianissimo.setData(new Integer(TGVelocities.PIANISSIMO));
 
52
                this.pianissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
53
                
 
54
                //--P--
 
55
                this.piano = new ToolItem(this.toolBar, SWT.CHECK);
 
56
                this.piano.setData(new Integer(TGVelocities.PIANO));
 
57
                this.piano.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
58
                
 
59
                //--MP--
 
60
                this.mezzoPiano = new ToolItem(this.toolBar, SWT.CHECK);
 
61
                this.mezzoPiano.setData(new Integer(TGVelocities.MEZZO_PIANO));
 
62
                this.mezzoPiano.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
63
                
 
64
                //--MF--
 
65
                this.mezzoForte = new ToolItem(this.toolBar, SWT.CHECK);
 
66
                this.mezzoForte.setData(new Integer(TGVelocities.MEZZO_FORTE));
 
67
                this.mezzoForte.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
68
                
 
69
                //--F--
 
70
                this.forte = new ToolItem(this.toolBar, SWT.CHECK);
 
71
                this.forte.setData(new Integer(TGVelocities.FORTE));
 
72
                this.forte.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
73
                
 
74
                //--FF--
 
75
                this.fortissimo = new ToolItem(this.toolBar, SWT.CHECK);
 
76
                this.fortissimo.setData(new Integer(TGVelocities.FORTISSIMO));
 
77
                this.fortissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
78
                
 
79
                //--FF--
 
80
                this.forteFortissimo = new ToolItem(this.toolBar, SWT.CHECK);
 
81
                this.forteFortissimo.setData(new Integer(TGVelocities.FORTE_FORTISSIMO));
 
82
                this.forteFortissimo.addSelectionListener(TuxGuitar.instance().getAction(ChangeVelocityAction.NAME));
 
83
                
 
84
                this.loadIcons();
 
85
                this.loadProperties();
 
86
        }
 
87
        
 
88
        public void update(){
 
89
                Caret caret = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret();
 
90
                int velocity = ((caret.getSelectedNote() != null)?caret.getSelectedNote().getVelocity():caret.getVelocity());
 
91
                boolean running = TuxGuitar.instance().getPlayer().isRunning();
 
92
                this.pianoPianissimo.setSelection(velocity == TGVelocities.PIANO_PIANISSIMO);
 
93
                this.pianoPianissimo.setEnabled( !running );
 
94
                this.pianissimo.setSelection(velocity == TGVelocities.PIANISSIMO);
 
95
                this.pianissimo.setEnabled( !running );
 
96
                this.piano.setSelection(velocity == TGVelocities.PIANO);
 
97
                this.piano.setEnabled( !running );
 
98
                this.mezzoPiano.setSelection(velocity == TGVelocities.MEZZO_PIANO);
 
99
                this.mezzoPiano.setEnabled( !running );
 
100
                this.mezzoForte.setSelection(velocity == TGVelocities.MEZZO_FORTE);
 
101
                this.mezzoForte.setEnabled( !running );
 
102
                this.forte.setSelection(velocity == TGVelocities.FORTE);
 
103
                this.forte.setEnabled( !running );
 
104
                this.fortissimo.setSelection(velocity == TGVelocities.FORTISSIMO);
 
105
                this.fortissimo.setEnabled( !running );
 
106
                this.forteFortissimo.setSelection(velocity == TGVelocities.FORTE_FORTISSIMO);
 
107
                this.forteFortissimo.setEnabled( !running );
 
108
        }
 
109
        
 
110
        public void loadProperties(){
 
111
                this.pianoPianissimo.setToolTipText(TuxGuitar.getProperty("dynamic.piano-pianissimo"));
 
112
                this.pianissimo.setToolTipText(TuxGuitar.getProperty("dynamic.pianissimo"));
 
113
                this.piano.setToolTipText(TuxGuitar.getProperty("dynamic.piano"));
 
114
                this.mezzoPiano.setToolTipText(TuxGuitar.getProperty("dynamic.mezzo-piano"));
 
115
                this.mezzoForte.setToolTipText(TuxGuitar.getProperty("dynamic.mezzo-forte"));
 
116
                this.forte.setToolTipText(TuxGuitar.getProperty("dynamic.forte"));
 
117
                this.fortissimo.setToolTipText(TuxGuitar.getProperty("dynamic.fortissimo"));
 
118
                this.forteFortissimo.setToolTipText(TuxGuitar.getProperty("dynamic.forte-fortissimo"));
 
119
        }
 
120
        
 
121
        public void loadIcons(){
 
122
                this.pianoPianissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicPPP());
 
123
                this.pianissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicPP());
 
124
                this.piano.setImage(TuxGuitar.instance().getIconManager().getDynamicP());
 
125
                this.mezzoPiano.setImage(TuxGuitar.instance().getIconManager().getDynamicMP());
 
126
                this.mezzoForte.setImage(TuxGuitar.instance().getIconManager().getDynamicMF());
 
127
                this.forte.setImage(TuxGuitar.instance().getIconManager().getDynamicF());
 
128
                this.fortissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicFF());
 
129
                this.forteFortissimo.setImage(TuxGuitar.instance().getIconManager().getDynamicFFF());
 
130
        }
 
131
}