Skip to content
Snippets Groups Projects
Commit 15065009 authored by jsiegle's avatar jsiegle
Browse files

Allow ControlPanel to collapse gracefully

parent fccf06c2
No related branches found
No related tags found
No related merge requests found
...@@ -35,8 +35,7 @@ MainWindow::MainWindow() ...@@ -35,8 +35,7 @@ MainWindow::MainWindow()
setResizable(true, // isResizable setResizable(true, // isResizable
false); // useBottomCornerRisizer -- doesn't work very well false); // useBottomCornerRisizer -- doesn't work very well
// Constraining the window's size doesn't seem to work:
// setResizeLimits(500, 400, 10000, 10000);
// Create ProcessorGraph and AudioComponent, and connect them. // Create ProcessorGraph and AudioComponent, and connect them.
// Callbacks will be set by the play button in the control panel // Callbacks will be set by the play button in the control panel
...@@ -62,6 +61,9 @@ MainWindow::MainWindow() ...@@ -62,6 +61,9 @@ MainWindow::MainWindow()
// button from randomly disappearing // button from randomly disappearing
setVisible(true); setVisible(true);
// Constraining the window's size doesn't seem to work:
setResizeLimits(300, 200, 10000, 10000);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
......
...@@ -478,9 +478,12 @@ void ControlPanel::updateChildComponents() ...@@ -478,9 +478,12 @@ void ControlPanel::updateChildComponents()
void ControlPanel::createPaths() void ControlPanel::createPaths()
{ {
int w = 150; int w = getWidth() - 325;
int h1 = 32; if (w > 150)
int h2 = 64; w = 150;
int h1 = getHeight()-32;
int h2 = getHeight();
int indent = 5; int indent = 5;
p1.clear(); p1.clear();
...@@ -507,6 +510,7 @@ void ControlPanel::paint(Graphics& g) ...@@ -507,6 +510,7 @@ void ControlPanel::paint(Graphics& g)
if (open) if (open)
{ {
createPaths();
g.setColour(Colours::black); g.setColour(Colours::black);
g.fillPath(p1); g.fillPath(p1);
g.fillPath(p2); g.fillPath(p2);
...@@ -520,43 +524,88 @@ void ControlPanel::resized() ...@@ -520,43 +524,88 @@ void ControlPanel::resized()
int h = 32; //getHeight(); int h = 32; //getHeight();
if (playButton != 0) if (playButton != 0)
playButton->setBounds(w-h*10,5,h-5,h-10); {
if (w > 350)
playButton->setBounds(w-h*10,5,h-5,h-10);\
else
playButton->setBounds(5,5,h-5,h-10);\
}
if (recordButton != 0) if (recordButton != 0)
recordButton->setBounds(w-h*9,5,h-5,h-10); {
if (w > 350)
recordButton->setBounds(w-h*9,5,h-5,h-10);
else
recordButton->setBounds(5+h,5,h-5,h-10);
}
if (masterClock != 0) if (masterClock != 0)
masterClock->setBounds(w-h*7-15,0,h*7-15,h); {
if (w > 350)
masterClock->setBounds(w-h*7-15,0,h*7-15,h);
else
masterClock->setBounds(5+h*2+15,0,h*7-15,h);
}
if (cpuMeter != 0) if (cpuMeter != 0)
cpuMeter->setBounds(8,h/4,h*3,h/2); {
if (getWidth() < 750 && getWidth() >= 570)
cpuMeter->setBounds(8,h/4+h,h*3,h/2);
else if (getWidth() < 570)
cpuMeter->setBounds(8,h/4+h*2,h*3,h/2);
else
cpuMeter->setBounds(8,h/4,h*3,h/2);
}
if (diskMeter != 0) if (diskMeter != 0)
diskMeter->setBounds(16+h*3,h/4,h*3,h/2); {
if (getWidth() < 750 && getWidth() >= 570)
diskMeter->setBounds(16+h*3,h/4+h,h*3,h/2);
else if (getWidth() < 570)
diskMeter->setBounds(16+h*3,h/4+h*2,h*3,h/2);
else
diskMeter->setBounds(16+h*3,h/4,h*3,h/2);
}
if (audioEditor != 0) if (audioEditor != 0)
audioEditor->setBounds(h*7,5,h*8,h-10); {
if (getWidth() < 750 && getWidth() >= 570)
audioEditor->setBounds(w-526,5,h*8,h-10);
else if (getWidth() < 570)
audioEditor->setBounds(8,5+h,h*8,h-10);
else
audioEditor->setBounds(h*7,5,h*8,h-10);
}
if (cpb != 0) if (cpb != 0)
cpb->setBounds(w-28,5,h-10,h-10); {
if (open)
cpb->setBounds(w-28,getHeight()-5-h*2+10,h-10,h-10);
else
cpb->setBounds(w-28,getHeight()-5-h+10,h-10,h-10);
}
createPaths(); createPaths();
if (open) if (open)
{ {
filenameComponent->setBounds(165, h+5, w-500, h-10); int topBound = getHeight()-h+10-5;
filenameComponent->setBounds(165, topBound, w-500, h-10);
filenameComponent->setVisible(true); filenameComponent->setVisible(true);
newDirectoryButton->setBounds(w-h+4, h+5, h-10, h-10); newDirectoryButton->setBounds(w-h+4, topBound, h-10, h-10);
newDirectoryButton->setVisible(true); newDirectoryButton->setVisible(true);
prependText->setBounds(165+w-490, h+5, 50, h-10); prependText->setBounds(165+w-490, topBound, 50, h-10);
prependText->setVisible(true); prependText->setVisible(true);
dateText->setBounds(165+w-435, h+5, 175, h-10); dateText->setBounds(165+w-435, topBound, 175, h-10);
dateText->setVisible(true); dateText->setVisible(true);
appendText->setBounds(165+w-255, h+5, 50, h-10); appendText->setBounds(165+w-255, topBound, 50, h-10);
appendText->setVisible(true); appendText->setVisible(true);
} }
...@@ -570,6 +619,8 @@ void ControlPanel::resized() ...@@ -570,6 +619,8 @@ void ControlPanel::resized()
} }
repaint(); repaint();
} }
void ControlPanel::openState(bool os) void ControlPanel::openState(bool os)
......
...@@ -116,6 +116,58 @@ void UIComponent::resized() ...@@ -116,6 +116,58 @@ void UIComponent::resized()
int w = getWidth(); int w = getWidth();
int h = getHeight(); int h = getHeight();
if (editorViewportButton != 0)
{
editorViewportButton->setBounds(w-230, h-40, 225, 35);
if (h < 400)
editorViewportButton->setVisible(false);
else
editorViewportButton->setVisible(true);
}
if (editorViewport != 0)
{
if (editorViewportButton->isOpen() && !editorViewport->isVisible())
editorViewport->setVisible(true);
else if (!editorViewportButton->isOpen() && editorViewport->isVisible())
editorViewport->setVisible(false);
editorViewport->setBounds(6,h-190,w-11,150);
if (h < 400)
editorViewport->setVisible(false);
else
editorViewport->setVisible(true);
}
if (controlPanel != 0)
{
int controlPanelWidth = w-210;
int addHeight = 0;
int leftBound;
if (w >= 460){
leftBound = 210;
}
else {
leftBound = w-250;
controlPanelWidth = w-leftBound;
}
if (controlPanelWidth < 750)
addHeight += 32;
if (controlPanelWidth < 570)
addHeight += 32;
if (controlPanel->isOpen())
controlPanel->setBounds(leftBound,6,controlPanelWidth,64+addHeight);
else
controlPanel->setBounds(leftBound,6,controlPanelWidth,32+addHeight);
}
if (dataViewport != 0) if (dataViewport != 0)
{ {
int left, top, width, height; int left, top, width, height;
...@@ -127,10 +179,7 @@ void UIComponent::resized() ...@@ -127,10 +179,7 @@ void UIComponent::resized()
else else
left = 6; left = 6;
if (controlPanel->isOpen()) top = controlPanel->getHeight()+8;
top = 72;
else
top = 40;
if (editorViewportButton->isOpen()) if (editorViewportButton->isOpen())
height = h - top - 195; height = h - top - 195;
...@@ -140,29 +189,12 @@ void UIComponent::resized() ...@@ -140,29 +189,12 @@ void UIComponent::resized()
width = w - left - 5; width = w - left - 5;
dataViewport->setBounds(left, top, width, height); dataViewport->setBounds(left, top, width, height);
}
if (editorViewportButton != 0)
{
editorViewportButton->setBounds(w-230, h-40, 225, 35);
}
if (editorViewport != 0)
{
if (editorViewportButton->isOpen() && !editorViewport->isVisible())
editorViewport->setVisible(true);
else if (!editorViewportButton->isOpen() && editorViewport->isVisible())
editorViewport->setVisible(false);
editorViewport->setBounds(6,h-190,w-11,150);
}
if (controlPanel != 0) if (h < 200)
{ dataViewport->setVisible(false);
if (controlPanel->isOpen())
controlPanel->setBounds(201,6,w-210,64);
else else
controlPanel->setBounds(201,6,w-210,32); dataViewport->setVisible(true);
} }
if (processorList != 0) if (processorList != 0)
...@@ -174,10 +206,21 @@ void UIComponent::resized() ...@@ -174,10 +206,21 @@ void UIComponent::resized()
processorList->setBounds(5,5,195,h-50); processorList->setBounds(5,5,195,h-50);
else else
processorList->setBounds(5,5,195,34); processorList->setBounds(5,5,195,34);
if (w < 460)
processorList->setVisible(false);
else
processorList->setVisible(true);
} }
if (messageCenter != 0) if (messageCenter != 0)
{
messageCenter->setBounds(6,h-35,w-241,30); messageCenter->setBounds(6,h-35,w-241,30);
if (h < 400)
messageCenter->setVisible(false);
else
messageCenter->setVisible(true);
}
// for debugging qpurposes: // for debugging qpurposes:
if (false) if (false)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment