This repository has been archived by the owner on Sep 15, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working architecture for oscillator control panel
- Loading branch information
Showing
4 changed files
with
120 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package modulatorp5; | ||
|
||
import controlP5.Slider; | ||
|
||
public interface ControlPanel { | ||
|
||
public static final int SLIDER_WIDTH = 200; | ||
public static final int SLIDER_HEIGHT = 20; | ||
public static final int SLIDER_VERTICAL_SPACER = new Float(SLIDER_HEIGHT * 0.66).intValue(); | ||
|
||
public void buildInterface(); | ||
|
||
public void addInitialControls(); | ||
|
||
public Slider addSlider(String name, float minVal, float maxVal, float curVal); | ||
|
||
public void advanceCursorForSlider(); | ||
|
||
public void rateSlider(float newRate); | ||
|
||
public void amountSlider(float newAmount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package modulatorp5; | ||
|
||
import java.util.ArrayList; | ||
|
||
import processing.core.PApplet; | ||
import controlP5.*; | ||
|
||
public class OscillatorControlPanel implements ControlPanel { | ||
|
||
private PApplet parent; | ||
private ControlP5 controlP5; | ||
private int x, y; | ||
private int yCursor; | ||
private String groupName; | ||
|
||
private ControlGroup controlGroup; | ||
|
||
Oscillator oscillator; | ||
|
||
OscillatorControlPanel(PApplet parent_, ControlP5 controlP5_, Oscillator oscillator_) { | ||
this(parent_, controlP5_, 0, 0, "Entity", oscillator_); | ||
} | ||
|
||
OscillatorControlPanel(PApplet parent_, ControlP5 controlP5_, int x_, int y_, Oscillator oscillator_) { | ||
this(parent_, controlP5_, x_, y_, "Entity", oscillator_); | ||
} | ||
|
||
OscillatorControlPanel(PApplet parent_, ControlP5 controlP5_, int x_, int y_, String groupName_, Oscillator oscillator_) { | ||
parent = parent_; | ||
controlP5 = controlP5_; | ||
x = x_; | ||
y = y_; | ||
yCursor = 0; | ||
groupName = groupName_; | ||
|
||
oscillator = oscillator_; | ||
|
||
buildInterface(); | ||
addInitialControls(); | ||
} | ||
|
||
public void buildInterface() { | ||
controlGroup = controlP5.addGroup(groupName, x, y); | ||
} | ||
|
||
public void addInitialControls() { | ||
addSlider("rateSlider", oscillator.getMinRate(), oscillator.getMaxRate(), oscillator.getRate()); | ||
addSlider("amountSlider", oscillator.MIN_AMOUNT, oscillator.MAX_AMOUNT, oscillator.getAmount()); | ||
} | ||
|
||
public Slider addSlider(String name, float minVal, float maxVal, float curVal) { | ||
Slider slider = controlP5.addSlider(name, minVal, maxVal, curVal, 0, yCursor, SLIDER_WIDTH, SLIDER_HEIGHT); | ||
advanceCursorForSlider(); | ||
slider.setLabel(controlGroup.name() + " " + name); | ||
slider.setGroup(controlGroup.name()); | ||
slider.plugTo(this); | ||
return slider; | ||
} | ||
|
||
public void advanceCursorForSlider() { | ||
yCursor = yCursor + (SLIDER_HEIGHT + SLIDER_VERTICAL_SPACER); | ||
} | ||
|
||
public void rateSlider(float newRate) { | ||
oscillator.setRate(newRate); | ||
} | ||
|
||
public void amountSlider(float newAmount) { | ||
oscillator.setAmount(newAmount); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.