I’m building a multi fx processor and have a ListBox to list each effect. As far as I understand, the ListBoxModel can use an XML file for that list. However, when compiling the XML file doesn’t get used. How does the ListBox parse the XML data?
I currently have a GUI JUCE project (no audio) set up like this:
MainComponent.h:
class MainComponent : public juce::Component, public juce::ListBoxModel
{
public:
//==============================================================================
MainComponent();
~MainComponent() override;
//==============================================================================
void paint (juce::Graphics&) override;
void resized() override;
int getNumRows() override;
void paintListBoxItem(int rowNumber, juce::Graphics& g,
int width, int height, bool rowIsSelected) override;
void selectedRowsChanged(int rowNumber, juce::Graphics& g,
int width, int height, bool rowIsSelected);
private:
//==============================================================================
// Your private member variables go here…
juce::ListBox listBox;
juce::File fxList { "/path/to/fxlist.xml" };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
MainComponent.cpp:
MainComponent::MainComponent()
{
// ListBox method for listing effects
addAndMakeVisible(listBox);
listBox.setRowHeight(50);
listBox.setModel(this);
listBox.setColour(juce::ListBox::textColourId, juce::Colours::orange);
listBox.setColour(juce::ListBox::backgroundColourId, juce::Colours::grey);
setSize (600, 480);
}
MainComponent::~MainComponent()
{
}
//==============================================================================
void MainComponent::paint (juce::Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (juce::Colours::grey);
g.setFont (juce::FontOptions (30.0f));
g.setColour(juce::Colours::orange);
g.drawLine(10, 50, 590, 50); //top horizontal line
g.drawLine(10, 460, 590, 460); //bottom horizontal line
g.drawLine(155, 70, 155, 440); //left vertical line
g.drawText("Global Parameters", getLocalBounds(), juce::Justification::centredTop, true);
}
void MainComponent::resized()
{
// This is called when the MainComponent is resized.
// If you add any child components, this is where you should
// update their positions.
listBox.setBounds(0, 60, 148, 395);
}
int MainComponent::getNumRows()
{
return 40; //you should probably derive this from whatever source data you end up using
}
void MainComponent::paintListBoxItem (int rowNumber, juce::Graphics& g,
int width, int height, bool rowIsSelected)
{
if (rowIsSelected)
{
g.fillAll (juce::Colours::lightgrey);
}
g.setColour (juce::Colours::orange);
g.setFont (height * 0.4f);
g.drawText ("Row Number " + juce::String (rowNumber + 1), 5, 0, width, height,
juce::Justification::centredLeft, true);
}
What else needs to happen in order to read the XML file? I read through JUCE’s TableListBox tutorial, but that’s more elaborate than I need (and I also don’t like the look of TableListBox). If there’s a simpler solution to making a list then I’m open to it.

