hi all !
I’m new to the forum and I JUCE test for a project.
I wanted to know how to add a toolbar simply, I searched the API and I think we should use:
Toolbar :: addItem
but it is necessary to create and I ToolbarItemFactory blocks at this level, if someone has a piece of code to unlock me I’m interested
There’s a toolbar example in the juce demo - did you look at that?
Where i can found it ?
I can not seem to find an example except:
http://code.google.com/p/juced/wiki/JuceTutorial
juce/extras/jucedemo
Or just grep the tree for “toolbar”!
I have clone Git repository with JUCEdemo and use the toolbar example , but now i have an other problem with picture resources, i want to add an icon (.png) on my toolbar, i add this icon with IntroJuicer 3.0 in source folder to generate BinaryData.cpp, but when i want to adapt the class ToolbarDemoComp i have an error :
My factory :
[code]class DemoToolbarItemFactory : public ToolbarItemFactory
{
public:
DemoToolbarItemFactory() {}
//==============================================================================
// Each type of item a toolbar can contain must be given a unique ID. These
// are the ones we'll use in this demo.
enum DemoToolbarItemIds
{
guitare_png = 1,
};
void getAllToolbarItemIds (Array <int>& ids)
{
// This returns the complete list of all item IDs that are allowed to
// go in our toolbar. Any items you might want to add must be listed here. The
// order in which they are listed will be used by the toolbar customisation panel.
ids.add (guitare_png);
// If you're going to use separators, then they must also be added explicitly
// to the list.
ids.add (separatorBarId);
ids.add (spacerId);
ids.add (flexibleSpacerId);
}
void getDefaultItemSet (Array <int>& ids)
{
// This returns an ordered list of the set of items that make up a
// toolbar's default set. Not all items need to be on this list, and
// items can appear multiple times (e.g. the separators used here).
ids.add (guitare_png);
ids.add (spacerId);
ids.add (separatorBarId);
ids.add (separatorBarId);
ids.add (flexibleSpacerId);
ids.add (flexibleSpacerId);
ids.add (separatorBarId);
}
ToolbarItemComponent* createItem (int itemId)
{
switch (itemId)
{
case guitare_png: return new ToolbarButton (itemId, "juce!", Drawable::createFromImageData (BinaryData::guitare_png, BinaryData::guitare_pngSize), 0);
default: break;
}
return 0;
}
// Demonstrates how to put a custom component into a toolbar - this one contains
// a ComboBox.
class CustomToolbarComboBox : public ToolbarItemComponent
{
public:
CustomToolbarComboBox (const int toolbarItemId)
: ToolbarItemComponent (toolbarItemId, "Custom Toolbar Item", false),
comboBox ("demo toolbar combo box")
{
addAndMakeVisible (&comboBox);
for (int i = 1; i < 20; ++i)
comboBox.addItem ("Toolbar ComboBox item " + String (i), i);
comboBox.setSelectedId (1);
comboBox.setEditableText (true);
}
bool getToolbarItemSizes (int /*toolbarDepth*/, bool isToolbarVertical,
int& preferredSize, int& minSize, int& maxSize)
{
if (isToolbarVertical)
return false;
preferredSize = 250;
minSize = 80;
maxSize = 300;
return true;
}
void paintButtonArea (Graphics&, int, int, bool, bool)
{
}
void contentAreaChanged (const Rectangle<int>& contentArea)
{
comboBox.setSize (contentArea.getWidth() - 2,
jmin (contentArea.getHeight() - 2, 22));
comboBox.setCentrePosition (contentArea.getCentreX(), contentArea.getCentreY());
}
private:
ComboBox comboBox;
};
};
DemoToolbarItemFactory factory;
};[/code]
I’m a bit confused by what you’re saying - do you mean that the BinaryData.cpp that the introjucer generated fails to compile with that error? If so, please email me a copy so I can see what it’s done wrong!