Skip to content
Browse files

Add scroll bar to ProcessorList. Closes #127

  • Loading branch information...
1 parent 416a9ce commit eb916d5e1823a575c459e0e4b94db6ef89a0da91 jsiegle committed Jan 30, 2014
Showing with 40 additions and 13 deletions.
  1. +12 −2 Source/UI/ProcessorList.cpp
  2. +7 −3 Source/UI/ProcessorList.h
  3. +19 −8 Source/UI/UIComponent.cpp
  4. +2 −0 Source/UI/UIComponent.h
View
14 Source/UI/ProcessorList.cpp
@@ -118,6 +118,11 @@ ProcessorList::~ProcessorList()
}
+void ProcessorList::resized()
+{
+ setBounds(0,0,195,getTotalHeight());
+}
+
bool ProcessorList::isOpen()
@@ -137,7 +142,7 @@ void ProcessorList::paint(Graphics& g)
void ProcessorList::drawItems(Graphics& g)
{
- totalHeight = yBuffer;
+ totalHeight = yBuffer + itemHeight;
category = baseItem->getName();
@@ -167,6 +172,11 @@ void ProcessorList::drawItems(Graphics& g)
}
}
+ if (isOpen())
+ setSize(getWidth(),totalHeight);
+
+ //resized();
+
}
void ProcessorList::drawItem(Graphics& g, ProcessorListItem* item)
@@ -451,7 +461,7 @@ void ProcessorList::mouseDown(const MouseEvent& e)
else
{
getUIComponent()->childComponentChanged();
- totalHeight = itemHeight + 2*yBuffer;
+ // totalHeight = itemHeight + 2*yBuffer;
}
}
View
10 Source/UI/ProcessorList.h
@@ -82,6 +82,12 @@ class ProcessorList : public Component,
/** Loads the ProcessorList state. */
void loadStateFromXml(XmlElement*);
+ void resized();
+
+ /** Returns the height requested by the ProcessorList. Determines whether or not
+ to draw scroll bars.*/
+ int getTotalHeight();
+
private:
/** The main method for drawing the ProcessorList.*/
@@ -104,9 +110,7 @@ class ProcessorList : public Component,
int currentColor;
- /** Returns the height requested by the ProcessorList. Determines whether or not
- to draw scroll bars.*/
- int getTotalHeight();
+
/** Deselects all items within the ProcessorList.*/
void clearSelectionState();
View
27 Source/UI/UIComponent.cpp
@@ -59,8 +59,11 @@ UIComponent::UIComponent(MainWindow* mainWindow_, ProcessorGraph* pgraph, AudioC
std::cout << "Created control panel." << std::endl;
processorList = new ProcessorList();
- addAndMakeVisible(processorList);
-
+ processorListViewport.setViewedComponent(processorList,false);
+ processorListViewport.setScrollBarsShown(true,false);
+ addAndMakeVisible(&processorListViewport);
+ processorList->setVisible(true);
+ processorList->setBounds(0,0,195,processorList->getTotalHeight());
std::cout << "Created filter list." << std::endl;
messageCenter = new MessageCenter();
@@ -171,15 +174,23 @@ void UIComponent::resized()
if (processorList != 0)
{
if (processorList->isOpen())
+ {
if (editorViewportButton->isOpen())
- processorList->setBounds(5,5,195,h-200);
+ processorListViewport.setBounds(5,5,195,h-200);
else
- processorList->setBounds(5,5,195,h-50);
- else
- processorList->setBounds(5,5,195,34);
+ processorListViewport.setBounds(5,5,195,h-50);
+
+ processorListViewport.setScrollBarsShown(true,false);
+
+ }
+ else{
+ processorListViewport.setBounds(5,5,195,34);
+ processorListViewport.setScrollBarsShown(false,false);
+ processorListViewport.setViewPosition (0, 0);
+ }
if (w < 460)
- processorList->setBounds(5-460+getWidth(),5,195,processorList->getHeight());
+ processorListViewport.setBounds(5-460+getWidth(),5,195,processorList->getHeight());
}
if (dataViewport != 0)
@@ -189,7 +200,7 @@ void UIComponent::resized()
top = 40;
if (processorList->isOpen())
- left = processorList->getX()+processorList->getWidth()+2;
+ left = processorListViewport.getX()+processorListViewport.getWidth()+2;
else
left = 6;
View
2 Source/UI/UIComponent.h
@@ -174,6 +174,8 @@ class UIComponent : public Component,
ScopedPointer<MessageCenter> messageCenter;
ScopedPointer<InfoLabel> infoLabel;
ScopedPointer<GraphViewer> graphViewer;
+
+ Viewport processorListViewport;
/** Pointer to the GUI's MainWindow, which owns the UIComponent. */
MainWindow* mainWindow;

0 comments on commit eb916d5

Please sign in to comment.
Something went wrong with that request. Please try again.