Skip to content

Commit 2600d1d

Browse files
committed
Song length is now unlimited.
1 parent 4e3c698 commit 2600d1d

File tree

11 files changed

+114
-8
lines changed

11 files changed

+114
-8
lines changed

MainWindow.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f8c090" height="32.0" layoutX="4.0" layoutY="4.0" stroke="TRANSPARENT" strokeType="INSIDE" width="390.0" />
6060
<StackPane id="StackPane" layoutY="2.0">
6161
<children>
62-
<TextField fx:id="songName" prefHeight="30.0" prefWidth="390.0" promptText="Song Name" />
62+
<TextField fx:id="songName" focusTraversable="false" prefHeight="30.0" prefWidth="390.0" promptText="Song Name" />
6363
<Rectangle fill="#1e90ff00" height="30.0" mouseTransparent="true" stroke="#d09048" strokeType="INSIDE" strokeWidth="2.0" width="390.0" />
6464
</children>
6565
</StackPane>
@@ -927,7 +927,7 @@
927927
<Point3D />
928928
</rotationAxis>
929929
</Rectangle>
930-
<Slider fx:id="scrollbar" blockIncrement="1.0" majorTickUnit="4.0" max="374.0" minorTickCount="1" prefWidth="660.0">
930+
<Slider fx:id="scrollbar" blockIncrement="1.0" majorTickUnit="4.0" max="390.0" minorTickCount="1" prefWidth="660.0">
931931
<rotationAxis>
932932
<Point3D />
933933
</rotationAxis>

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ Tasklist:
4242
* Release to a test group (v0.9 - **Alpha Release** - December 25, 2013)
4343
* Measure line numbers (done - December 27, 2013)
4444
* Tempo selector interface (done - December 27, 2013)
45+
* Remove limit on song length (done - January 1, 2014)
4546
* Options dialog
4647
* Import MPC songs
4748
* Arranger mode
48-
* [optional] Staff extension lines
49+
* [optional] Staff ledger lines
50+
* Copy-paste sections / MPCTxtTools functionality
51+
* Test run on more operating systems
4952
* Release to a test group (v0.95 - **Beta Release** - Release date unknown)
53+
* Undo/redo
5054
* Bookmarks
5155
* Speedmarks
5256
* Import AMS songs

src/smp/components/controls/ArrowButton.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package smp.components.controls;
22

33
import smp.ImageIndex;
4+
import smp.components.Values;
45
import smp.components.general.ImagePushButton;
6+
import smp.components.staff.sequences.StaffNoteLine;
7+
import smp.components.staff.sequences.StaffSequence;
58
import javafx.scene.control.Slider;
69
import javafx.scene.image.ImageView;
710
import javafx.scene.input.MouseEvent;
@@ -59,6 +62,15 @@ public double getSkipAmount() {
5962
protected void reactPressed(MouseEvent event) {
6063
super.reactPressed(event);
6164
scrollbar.adjustValue(scrollbar.getValue() + skipAmount);
65+
if (scrollbar.getMax() <= scrollbar.getValue()) {
66+
scrollbar.setMax(scrollbar.getMax()
67+
+ Values.NOTELINES_IN_THE_WINDOW * 2);
68+
StaffSequence s = theStaff.getSequence();
69+
int start = (int) scrollbar.getMax();
70+
for(int i = start; i < start
71+
+ Values.NOTELINES_IN_THE_WINDOW * 2; i++)
72+
s.addLine(new StaffNoteLine(i));
73+
}
6274
}
6375

6476
@Override

src/smp/components/controls/Controls.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class Controls {
3030
/** The pointer to the loop button on the staff. */
3131
private LoopButton loop;
3232

33+
/** The pointer to the options button on the staff. */
34+
private OptionsButton options;
35+
3336
/** The pointer to the mute button on the staff. */
3437
private MuteButton mute;
3538

@@ -128,10 +131,16 @@ private void initializeControlButtons() {
128131
loop = new LoopButton(SMPFXController.getLoopButton());
129132
mute = new MuteButton(SMPFXController.getMuteButton());
130133
muteA = new MuteInstButton(SMPFXController.getMuteAButton());
134+
options = new OptionsButton(SMPFXController.getOptionsButton());
135+
131136
mute.setMuteButton(muteA);
132137
muteA.setMuteButton(mute);
138+
mute.setStaff(theStaff);
139+
muteA.setStaff(theStaff);
140+
133141
play.link(stop);
134142
stop.link(play);
143+
135144
play.setStaff(theStaff);
136145
stop.setStaff(theStaff);
137146
}
@@ -157,6 +166,11 @@ private void initializeArrows() {
157166
rightArrow.setSkipAmount(1);
158167
rightFastArrow.setSkipAmount(Double.MAX_VALUE);
159168
leftFastArrow.setSkipAmount(-Double.MAX_VALUE);
169+
170+
leftArrow.setStaff(theStaff);
171+
rightArrow.setStaff(theStaff);
172+
rightFastArrow.setStaff(theStaff);
173+
leftFastArrow.setStaff(theStaff);
160174
}
161175

162176

src/smp/components/controls/LoadButton.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import javafx.scene.image.ImageView;
1010
import javafx.scene.input.MouseEvent;
1111
import javafx.stage.FileChooser;
12+
import smp.components.Values;
1213
import smp.components.general.ImagePushButton;
1314
import smp.components.staff.sequences.StaffSequence;
1415
import smp.fx.Dialog;
@@ -36,6 +37,11 @@ protected void reactPressed(MouseEvent event) {
3637
load();
3738
}
3839

40+
@Override
41+
protected void reactReleased(MouseEvent event) {
42+
// do nothing.
43+
}
44+
3945
/** This loads the song. */
4046
private void load() {
4147
boolean cont = true;
@@ -57,6 +63,8 @@ private void load() {
5763
theStaff.setSequence(loaded);
5864
StateMachine.setTempo(loaded.getTempo());
5965
theStaff.getControlPanel().updateCurrTempo();
66+
theStaff.getControlPanel().getScrollbar().setMax(
67+
loaded.getTheLines().size());
6068
theStaff.getNoteMatrix().redraw();
6169
o_in.close();
6270
f_in.close();

src/smp/components/controls/NewButton.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ protected void reactPressed(MouseEvent event) {
3232
newSong();
3333
}
3434

35+
@Override
36+
protected void reactReleased(MouseEvent event) {
37+
// do nothing.
38+
}
39+
3540
/**
3641
* Creates a new song and clears the staff of all notes.
3742
* Make sure you save your song first!

src/smp/components/controls/OptionsButton.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
package smp.components.controls;
22

3+
import javafx.event.ActionEvent;
4+
import javafx.event.EventHandler;
5+
import javafx.geometry.Pos;
6+
import javafx.scene.Scene;
7+
import javafx.scene.control.Button;
8+
import javafx.scene.control.Label;
39
import javafx.scene.image.ImageView;
410
import javafx.scene.input.MouseEvent;
11+
import javafx.scene.layout.FlowPane;
12+
import javafx.scene.layout.VBox;
13+
import javafx.stage.Stage;
14+
import javafx.stage.StageStyle;
515
import smp.components.general.ImagePushButton;
616

717
/**
@@ -11,6 +21,9 @@
1121
*/
1222
public class OptionsButton extends ImagePushButton {
1323

24+
/** This is the text that will be shown in the options dialog. */
25+
private String txt = "";
26+
1427
/**
1528
* Default constructor.
1629
* @param i The image that we want to link this to.
@@ -26,11 +39,37 @@ protected void reactPressed(MouseEvent event) {
2639

2740
@Override
2841
protected void reactReleased(MouseEvent event) {
29-
42+
// do nothing.
3043
}
3144

3245
/** Opens up an options dialog. */
3346
private void options() {
47+
final Stage dialog = new Stage();
48+
dialog.setHeight(150);
49+
dialog.setWidth(250);
50+
dialog.setResizable(false);
51+
dialog.initStyle(StageStyle.UTILITY);
52+
Label label = new Label(txt);
53+
Button okButton = new Button("OK");
54+
55+
okButton.setOnAction(new EventHandler<ActionEvent>() {
56+
57+
@Override
58+
public void handle(ActionEvent event) {
59+
dialog.close();
60+
}
61+
62+
});
63+
64+
FlowPane pane = new FlowPane(10, 10);
65+
pane.setAlignment(Pos.CENTER);
66+
pane.getChildren().addAll(okButton);
67+
VBox vBox = new VBox(10);
68+
vBox.setAlignment(Pos.CENTER);
69+
vBox.getChildren().addAll(label, pane);
70+
Scene scene1 = new Scene(vBox);
71+
dialog.setScene(scene1);
72+
dialog.showAndWait();
3473
updateValues();
3574
}
3675

src/smp/components/controls/SaveButton.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ protected void reactPressed(MouseEvent event) {
4848
save();
4949
}
5050

51+
@Override
52+
protected void reactReleased(MouseEvent event) {
53+
// do nothing.
54+
}
55+
5156
/** This saves the song. */
5257
private void save() {
5358
if (!saveTxt) {
@@ -68,8 +73,9 @@ private void saveObject() {
6873
FileChooser f = new FileChooser();
6974
f.setInitialDirectory(new File(System.getProperty("user.dir")));
7075
f.setInitialFileName(SMPFXController.getSongName().getText());
71-
f.getExtensionFilters().add(new ExtensionFilter(
72-
"Text file", "*.txt"));
76+
f.getExtensionFilters().addAll(
77+
new ExtensionFilter("Text file", "*.txt"),
78+
new ExtensionFilter("All files", "*"));
7379
File outputFile = f.showSaveDialog(null);
7480
if (outputFile == null)
7581
return;

src/smp/components/staff/sequences/StaffSequence.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ public StaffSequence() {
4040
* index i.
4141
*/
4242
public StaffNoteLine getLine(int i) {
43-
return theLines.get(i);
43+
try {
44+
return theLines.get(i);
45+
} catch (IndexOutOfBoundsException e) {
46+
theLines.add(new StaffNoteLine(theLines.size()));
47+
try {
48+
return theLines.get(i);
49+
} catch (IndexOutOfBoundsException e2) {
50+
return getLine(i);
51+
}
52+
}
4453
}
4554

4655
/**

src/smp/fx/SMPFXController.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public class SMPFXController implements Initializable {
105105
@FXML
106106
private static ImageView newButton;
107107

108+
/** The button that opens the options dialog. */
109+
@FXML
110+
private static ImageView optionsButton;
111+
108112
/** This is the text area that houses the song name. */
109113
@FXML
110114
private static TextField songName;
@@ -393,6 +397,11 @@ public static ImageView getNewButton() {
393397
return newButton;
394398
}
395399

400+
/** @return The options button. */
401+
public static ImageView getOptionsButton() {
402+
return optionsButton;
403+
}
404+
396405
/** @return The text area that contains the song name. */
397406
public static TextField getSongName() {
398407
return songName;

src/smp/stateMachine/StateMachine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class StateMachine {
5858
/**
5959
* This is the current tempo that the program is running at.
6060
*/
61-
private static double tempo = 400;
61+
private static double tempo = Values.DEFAULT_TEMPO;
6262

6363

6464
/**

0 commit comments

Comments
 (0)