From 15065009cecb5fd47f081929cd1c4e67ac78db13 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Fri, 24 Jan 2014 00:26:24 -0500 Subject: [PATCH] Allow ControlPanel to collapse gracefully --- Source/MainWindow.cpp | 6 ++- Source/UI/ControlPanel.cpp | 81 +++++++++++++++++++++++++++------ Source/UI/UIComponent.cpp | 93 ++++++++++++++++++++++++++++---------- 3 files changed, 138 insertions(+), 42 deletions(-) diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index 232ca741d..fe84eeedc 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -35,8 +35,7 @@ MainWindow::MainWindow() setResizable(true, // isResizable 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. // Callbacks will be set by the play button in the control panel @@ -62,6 +61,9 @@ MainWindow::MainWindow() // button from randomly disappearing setVisible(true); + // Constraining the window's size doesn't seem to work: + setResizeLimits(300, 200, 10000, 10000); + } MainWindow::~MainWindow() diff --git a/Source/UI/ControlPanel.cpp b/Source/UI/ControlPanel.cpp index e600b51a4..9f47aa296 100755 --- a/Source/UI/ControlPanel.cpp +++ b/Source/UI/ControlPanel.cpp @@ -478,9 +478,12 @@ void ControlPanel::updateChildComponents() void ControlPanel::createPaths() { - int w = 150; - int h1 = 32; - int h2 = 64; + int w = getWidth() - 325; + if (w > 150) + w = 150; + + int h1 = getHeight()-32; + int h2 = getHeight(); int indent = 5; p1.clear(); @@ -507,6 +510,7 @@ void ControlPanel::paint(Graphics& g) if (open) { + createPaths(); g.setColour(Colours::black); g.fillPath(p1); g.fillPath(p2); @@ -520,43 +524,88 @@ void ControlPanel::resized() int h = 32; //getHeight(); 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) - 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) - 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) - 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) - 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) - 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) - 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(); 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); - newDirectoryButton->setBounds(w-h+4, h+5, h-10, h-10); + newDirectoryButton->setBounds(w-h+4, topBound, h-10, h-10); 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); - dateText->setBounds(165+w-435, h+5, 175, h-10); + dateText->setBounds(165+w-435, topBound, 175, h-10); 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); } @@ -570,6 +619,8 @@ void ControlPanel::resized() } repaint(); + + } void ControlPanel::openState(bool os) diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp index 767ad9277..d32282cbb 100755 --- a/Source/UI/UIComponent.cpp +++ b/Source/UI/UIComponent.cpp @@ -116,6 +116,58 @@ void UIComponent::resized() int w = getWidth(); 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) { int left, top, width, height; @@ -127,10 +179,7 @@ void UIComponent::resized() else left = 6; - if (controlPanel->isOpen()) - top = 72; - else - top = 40; + top = controlPanel->getHeight()+8; if (editorViewportButton->isOpen()) height = h - top - 195; @@ -140,29 +189,12 @@ void UIComponent::resized() width = w - left - 5; 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 (controlPanel->isOpen()) - controlPanel->setBounds(201,6,w-210,64); + if (h < 200) + dataViewport->setVisible(false); else - controlPanel->setBounds(201,6,w-210,32); + dataViewport->setVisible(true); + } if (processorList != 0) @@ -174,10 +206,21 @@ void UIComponent::resized() processorList->setBounds(5,5,195,h-50); else processorList->setBounds(5,5,195,34); + + if (w < 460) + processorList->setVisible(false); + else + processorList->setVisible(true); } if (messageCenter != 0) + { messageCenter->setBounds(6,h-35,w-241,30); + if (h < 400) + messageCenter->setVisible(false); + else + messageCenter->setVisible(true); + } // for debugging qpurposes: if (false) -- GitLab