59 button->setRadioGroupId (1);
60 button->onClick = [
this] { clickedPage(); };
61 button->setClickingTogglesState (
true);
62 button->setWantsKeyboardFocus (
false);
67 if (currentPage ==
nullptr)
77 iconOver.setOverlayColour (Colours::black.withAlpha (0.12f));
80 iconDown.setOverlayColour (Colours::black.withAlpha (0.25f));
92 o.dialogTitle = dialogTitle;
93 o.dialogBackgroundColour = backgroundColour;
94 o.escapeKeyTriggersCloseButton =
false;
95 o.useNativeTitleBar =
false;
104 for (
int i = 0; i < buttons.size(); ++i)
105 buttons.getUnchecked (i)->setBounds (i * buttonSize, 0, buttonSize, buttonSize);
107 if (currentPage !=
nullptr)
108 currentPage->setBounds (
getLocalBounds().withTop (buttonSize + 5));
126 if (currentPage !=
nullptr)
129 currentPage->toBack();
133 for (
auto* b : buttons)
144void PreferencesPanel::clickedPage()
146 for (
auto* b : buttons)
148 if (b->getToggleState())
Represents a colour, also including a transparency value.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void setSize(int newWidth, int newHeight)
Changes the size of the component.
int getWidth() const noexcept
Returns the component's width in pixels.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
A drawable object which is a bitmap image.
void setImage(const Image &imageToUse)
Sets the image that this drawable will render.
The base class for objects which can draw themselves, e.g.
A graphics context, used for drawing a component or image.
void fillRect(Rectangle< int > rectangle) const
Fills a rectangle with the current colour or brush.
void setColour(Colour newColour)
Changes the current drawing colour.
static Image getFromMemory(const void *imageData, int dataSize)
Loads an image from an in-memory image file, (or just returns the image if it's already cached).
void paint(Graphics &) override
Components can override this method to draw their content.
void showInDialogBox(const String &dialogTitle, int dialogWidth, int dialogHeight, Colour backgroundColour=Colours::white)
Utility method to display this panel in a DialogWindow.
int getButtonSize() const noexcept
Returns the size of the buttons shown along the top.
~PreferencesPanel() override
Destructor.
void setCurrentPage(const String &pageName)
Changes the current page being displayed.
void resized() override
Called when this component's size has been changed.
virtual Component * createComponentForPage(const String &pageName)=0
Subclasses must override this to return a component for each preferences page.
void setButtonSize(int newSize)
Changes the size of the buttons shown along the top.
void addSettingsPage(const String &pageTitle, const Drawable *normalIcon, const Drawable *overIcon, const Drawable *downIcon)
Creates a page using a set of drawables to define the page's icon.
PreferencesPanel()
Creates an empty panel.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
This class defines a collection of settings to be used to open a DialogWindow.
OptionalScopedPointer< Component > content
The content component to show in the window.