1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Enumerate: Replace some non-ranged loops

This commit is contained in:
reuk 2023-09-21 14:34:52 +01:00
parent cb44d72b78
commit 94ee60041f
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
9 changed files with 45 additions and 54 deletions

View file

@ -221,16 +221,15 @@ private:
{
RadioButtonsGroupComponent()
{
int index = 1;
for (auto& b : radioButtons)
for (const auto [n, b] : enumerate (radioButtons, 1))
{
b.setRadioGroupId (1);
b.setButtonText ("Button " + String (index++));
b.setButtonText ("Button " + String (n));
b.setHasFocusOutline (true);
addAndMakeVisible (b);
}
radioButtons[(size_t) Random::getSystemRandom().nextInt (numRadioButtons)].setToggleState (true, dontSendNotification);
radioButtons[(size_t) Random::getSystemRandom().nextInt ((int) radioButtons.size())].setToggleState (true, dontSendNotification);
setTitle ("Radio Buttons Group");
setFocusContainerType (FocusContainerType::focusContainer);
@ -239,14 +238,13 @@ private:
void resized() override
{
auto bounds = getLocalBounds();
const auto height = bounds.getHeight() / numRadioButtons;
const auto height = bounds.getHeight() / (int) radioButtons.size();
for (auto& b : radioButtons)
b.setBounds (bounds.removeFromTop (height).reduced (2));
}
static constexpr int numRadioButtons = 3;
std::array<ToggleButton, numRadioButtons> radioButtons;
std::array<ToggleButton, 3> radioButtons;
};
//==============================================================================