mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-01-08 19:24:25 +01:00
Auto fit machine to window, fix tab label sizes, cycle density preview styles, hurray
This commit is contained in:
parent
70eaae51bd
commit
a1bdca895f
@ -120,9 +120,11 @@ class Panel
|
|||||||
|
|
||||||
public void draw()
|
public void draw()
|
||||||
{
|
{
|
||||||
// stroke(outlineColour);
|
if (debugPanels) {
|
||||||
// strokeWeight(2);
|
stroke(outlineColour);
|
||||||
// rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight());
|
strokeWeight(2);
|
||||||
|
rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
drawControls();
|
drawControls();
|
||||||
}
|
}
|
||||||
|
@ -727,6 +727,9 @@ void numberbox_mode_previewCordOffsetValue(int value)
|
|||||||
|
|
||||||
void button_mode_cycleDensityPreviewStyle()
|
void button_mode_cycleDensityPreviewStyle()
|
||||||
{
|
{
|
||||||
|
Controller c = cp5.getController(MODE_CYCLE_DENSITY_PREVIEW_STYLE);
|
||||||
|
c.setLabel(this.controlLabels.get(MODE_CYCLE_DENSITY_PREVIEW_STYLE) + ": " + densityPreviewStyle);
|
||||||
|
|
||||||
if (densityPreviewStyle == DENSITY_PREVIEW_STYLE_COUNT) {
|
if (densityPreviewStyle == DENSITY_PREVIEW_STYLE_COUNT) {
|
||||||
densityPreviewStyle = 0;
|
densityPreviewStyle = 0;
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,8 @@ Map<String, Panel> buildPanels() {
|
|||||||
generalPanel.setControlPositions(buildControlPositionsForPanel(generalPanel));
|
generalPanel.setControlPositions(buildControlPositionsForPanel(generalPanel));
|
||||||
generalPanel.setControlSizes(buildControlSizesForPanel(generalPanel));
|
generalPanel.setControlSizes(buildControlSizesForPanel(generalPanel));
|
||||||
panels.put(PANEL_NAME_GENERAL, generalPanel);
|
panels.put(PANEL_NAME_GENERAL, generalPanel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return panels;
|
return panels;
|
||||||
}
|
}
|
||||||
@ -967,7 +969,7 @@ Map<String, String> buildControlLabels()
|
|||||||
result.put(MODE_SEND_BUTTON_DEACTIVATE, "Deactivate button");
|
result.put(MODE_SEND_BUTTON_DEACTIVATE, "Deactivate button");
|
||||||
|
|
||||||
result.put(MODE_ADJUST_PREVIEW_CORD_OFFSET, "Cord offset");
|
result.put(MODE_ADJUST_PREVIEW_CORD_OFFSET, "Cord offset");
|
||||||
result.put(MODE_CYCLE_DENSITY_PREVIEW_STYLE, "Preview style");
|
result.put(MODE_CYCLE_DENSITY_PREVIEW_STYLE, "Cycle preview style");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -412,6 +412,7 @@ public color densityPreviewColour = color(0);
|
|||||||
|
|
||||||
public Integer previewCordOffset = 0;
|
public Integer previewCordOffset = 0;
|
||||||
|
|
||||||
|
public boolean debugPanels = false;
|
||||||
|
|
||||||
public boolean showingSummaryOverlay = true;
|
public boolean showingSummaryOverlay = true;
|
||||||
public boolean showingDialogBox = false;
|
public boolean showingDialogBox = false;
|
||||||
@ -526,9 +527,10 @@ String filePath = null;
|
|||||||
|
|
||||||
static PApplet parentPapplet = null;
|
static PApplet parentPapplet = null;
|
||||||
|
|
||||||
|
boolean rescaleDisplayMachine = true;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
size(windowWidth, windowHeight);
|
|
||||||
println("Running polargraph controller");
|
println("Running polargraph controller");
|
||||||
frame.setResizable(true);
|
frame.setResizable(true);
|
||||||
initLogging();
|
initLogging();
|
||||||
@ -547,9 +549,10 @@ void setup()
|
|||||||
}
|
}
|
||||||
loadFromPropertiesFile();
|
loadFromPropertiesFile();
|
||||||
|
|
||||||
|
size(windowWidth, windowHeight);
|
||||||
this.cp5 = new ControlP5(this);
|
this.cp5 = new ControlP5(this);
|
||||||
initTabs();
|
initTabs();
|
||||||
|
|
||||||
String[] serialPorts = Serial.list();
|
String[] serialPorts = Serial.list();
|
||||||
println("Serial ports available on your machine:");
|
println("Serial ports available on your machine:");
|
||||||
println(serialPorts);
|
println(serialPorts);
|
||||||
@ -598,6 +601,29 @@ void setup()
|
|||||||
|
|
||||||
frameRate(8);
|
frameRate(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fitDisplayMachineToWindow() {
|
||||||
|
|
||||||
|
Rectangle gr = panels.get(PANEL_NAME_GENERAL).getOutline();
|
||||||
|
println(gr);
|
||||||
|
|
||||||
|
Rectangle ir = panels.get(PANEL_NAME_INPUT).getOutline();
|
||||||
|
println(ir);
|
||||||
|
|
||||||
|
float targetHeight = ir.getBottom() - gr.getTop() - CONTROL_SPACING.y;
|
||||||
|
println("Target height is " + targetHeight + " pixels");
|
||||||
|
|
||||||
|
float machineHeight = getDisplayMachine().getOutline().getHeight();
|
||||||
|
println(machineHeight);
|
||||||
|
|
||||||
|
machineScaling = (targetHeight / machineHeight);
|
||||||
|
println(machineScaling);
|
||||||
|
|
||||||
|
getDisplayMachine().getOffset().x = ((gr.getRight() > ir.getRight()) ? gr.getRight() : ir.getRight()) + CONTROL_SPACING.x;
|
||||||
|
getDisplayMachine().getOffset().y = gr.getTop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void addEventListeners()
|
void addEventListeners()
|
||||||
{
|
{
|
||||||
frame.addComponentListener(new ComponentAdapter()
|
frame.addComponentListener(new ComponentAdapter()
|
||||||
@ -632,17 +658,20 @@ void preLoadCommandQueue()
|
|||||||
|
|
||||||
void windowResized()
|
void windowResized()
|
||||||
{
|
{
|
||||||
println("Window resized.");
|
noLoop();
|
||||||
windowWidth = frame.getWidth();
|
windowWidth = frame.getWidth();
|
||||||
windowHeight = frame.getHeight();
|
windowHeight = frame.getHeight();
|
||||||
|
println("New window size: " + windowWidth + " x " + windowHeight);
|
||||||
|
|
||||||
for (String key : getPanels().keySet())
|
for (String key : getPanels().keySet())
|
||||||
{
|
{
|
||||||
println("Panel: " + key);
|
|
||||||
Panel p = getPanels().get(key);
|
Panel p = getPanels().get(key);
|
||||||
p.setSizeByHeight(frame.getHeight() - p.getOutline().getTop() - (DEFAULT_CONTROL_SIZE.y*2));
|
p.setSizeByHeight(windowHeight - p.getOutline().getTop() - (DEFAULT_CONTROL_SIZE.y*2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Required to tell CP5 to be able to use the new sized window
|
||||||
cp5.setGraphics(this,0,0);
|
cp5.setGraphics(this,0,0);
|
||||||
|
loop();
|
||||||
}
|
}
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
@ -751,6 +780,10 @@ void drawImagePage()
|
|||||||
strokeWeight(3);
|
strokeWeight(3);
|
||||||
stroke(150);
|
stroke(150);
|
||||||
noFill();
|
noFill();
|
||||||
|
if (rescaleDisplayMachine) {
|
||||||
|
fitDisplayMachineToWindow();
|
||||||
|
rescaleDisplayMachine = false;
|
||||||
|
}
|
||||||
getDisplayMachine().draw();
|
getDisplayMachine().draw();
|
||||||
drawMoveImageOutline();
|
drawMoveImageOutline();
|
||||||
stroke(255, 0, 0);
|
stroke(255, 0, 0);
|
||||||
@ -1559,10 +1592,10 @@ boolean mouseOverPanel()
|
|||||||
for (Panel panel : getPanelsForTab(currentTab))
|
for (Panel panel : getPanelsForTab(currentTab))
|
||||||
{
|
{
|
||||||
if (panel.getOutline().surrounds(getMouseVector())) {
|
if (panel.getOutline().surrounds(getMouseVector())) {
|
||||||
println("Outline: " + panel.getOutline().toString());
|
// println("Outline: " + panel.getOutline().toString());
|
||||||
println("OVER PANEL!" + panel.getName());
|
// println("OVER PANEL!" + panel.getName());
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -3027,8 +3060,8 @@ void savePropertiesFile()
|
|||||||
props.setProperty("controller.density.preview.style", new Integer(getDensityPreviewStyle()).toString());
|
props.setProperty("controller.density.preview.style", new Integer(getDensityPreviewStyle()).toString());
|
||||||
|
|
||||||
// initial screen size
|
// initial screen size
|
||||||
props.setProperty("controller.window.width", new Integer((windowWidth < 50) ? 50 : windowWidth-16).toString());
|
props.setProperty("controller.window.width", new Integer((windowWidth < 100) ? 100 : windowWidth-16).toString());
|
||||||
props.setProperty("controller.window.height", new Integer((windowWidth < 50) ? 50 : windowHeight-38).toString());
|
props.setProperty("controller.window.height", new Integer((windowWidth < 100) ? 100 : windowHeight-38).toString());
|
||||||
|
|
||||||
props.setProperty("controller.testPenWidth.startSize", df.format(testPenWidthStartSize));
|
props.setProperty("controller.testPenWidth.startSize", df.format(testPenWidthStartSize));
|
||||||
props.setProperty("controller.testPenWidth.endSize", df.format(testPenWidthEndSize));
|
props.setProperty("controller.testPenWidth.endSize", df.format(testPenWidthEndSize));
|
||||||
|
42
tabSetup.pde
42
tabSetup.pde
@ -83,25 +83,35 @@ List<String> buildTabNames()
|
|||||||
|
|
||||||
void initTabs()
|
void initTabs()
|
||||||
{
|
{
|
||||||
cp5.getTab(TAB_NAME_INPUT).setLabel(TAB_LABEL_INPUT);
|
int tabWidth = (int)DEFAULT_CONTROL_SIZE.x;
|
||||||
cp5.getTab(TAB_NAME_INPUT).activateEvent(true);
|
int tabHeight = (int)DEFAULT_CONTROL_SIZE.y;
|
||||||
cp5.getTab(TAB_NAME_INPUT).setId(1);
|
|
||||||
|
Tab.padding = 13; // that's a weird thing to do
|
||||||
|
|
||||||
|
Tab input = cp5.getTab(TAB_NAME_INPUT);
|
||||||
|
input.setLabel(TAB_LABEL_INPUT);
|
||||||
|
input.activateEvent(true);
|
||||||
|
input.setId(1);
|
||||||
|
|
||||||
cp5.getTab(TAB_NAME_DETAILS).setLabel(TAB_LABEL_DETAILS);
|
Tab details = cp5.getTab(TAB_NAME_DETAILS);
|
||||||
cp5.getTab(TAB_NAME_DETAILS).activateEvent(true);
|
details.setLabel(TAB_LABEL_DETAILS);
|
||||||
cp5.getTab(TAB_NAME_DETAILS).setId(2);
|
details.activateEvent(true);
|
||||||
|
details.setId(2);
|
||||||
|
|
||||||
|
Tab roving = cp5.getTab(TAB_NAME_ROVING);
|
||||||
|
roving.setLabel(TAB_LABEL_ROVING);
|
||||||
|
roving.activateEvent(true);
|
||||||
|
roving.setId(3);
|
||||||
|
|
||||||
cp5.getTab(TAB_NAME_ROVING).setLabel(TAB_LABEL_ROVING);
|
Tab trace = cp5.getTab(TAB_NAME_TRACE);
|
||||||
cp5.getTab(TAB_NAME_ROVING).activateEvent(true);
|
trace.setLabel(TAB_LABEL_TRACE);
|
||||||
cp5.getTab(TAB_NAME_ROVING).setId(3);
|
trace.activateEvent(true);
|
||||||
|
trace.setId(4);
|
||||||
|
|
||||||
cp5.getTab(TAB_NAME_TRACE).setLabel(TAB_LABEL_TRACE);
|
Tab queue = cp5.getTab(TAB_NAME_QUEUE);
|
||||||
cp5.getTab(TAB_NAME_TRACE).activateEvent(true);
|
queue.setLabel(TAB_LABEL_QUEUE);
|
||||||
cp5.getTab(TAB_NAME_TRACE).setId(4);
|
queue.activateEvent(true);
|
||||||
|
queue.setId(5);
|
||||||
cp5.getTab(TAB_NAME_QUEUE).setLabel(TAB_LABEL_QUEUE);
|
|
||||||
cp5.getTab(TAB_NAME_QUEUE).activateEvent(true);
|
|
||||||
cp5.getTab(TAB_NAME_QUEUE).setId(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> buildPanelNames()
|
public Set<String> buildPanelNames()
|
||||||
|
Loading…
Reference in New Issue
Block a user