LookAndFeel issue with AudioDeviceSelectorComponent


#1

Using an AudioDeviceSelectorComponent with a custom LookAndFeel, I ended up with missing labels for the sample rate and buffer size comboboxes, or to be more precise they were set to a very small size, see image.

Setting the label size in AudioDeviceSettingsPanel after attaching to the respective combobox, e.g.

            sampleRateLabel.reset (new Label ({}, TRANS("Sample rate:")));
            sampleRateLabel->attachToComponent (sampleRateDropDown.get(), true);
            sampleRateLabel->setSize (200, 50); // <-- Added

has fixed the issue, but I’d rather not hack the JUCE code like this so wondering if anyone has a clue as to why this might have happened.

My L&F class not overridden drawLabel.


#2

Are you using a custom font? My guess would be that something is going wrong detecting the width of a string, but I’m not sure why the other bits of text are unaffected…


#3

Yes it’s a custom font. Strange, I’ll have another look next time I’m working on that project.


#4

EDIT: I just realized you were not speaking to the actual ComboBox. Still this might be useful info for someone.

This is one of the changes I make in my local repo because I have some small ComboBox’s. It doesn’t seem to effect the normal size combos.
.withStandardItemHeight (label->getHeight()) around line 550 in juce_ComboBox.cpp is the issue. I have no idea if this would break things for other people.

     menu.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
                                             .withItemThatMustBeVisible (getSelectedId())
                                             .withMinimumWidth (getWidth())
                                            .withMaximumNumColumns (1)
                                            .withStandardItemHeight (label->getHeight()),
                                            .withMaximumNumColumns (1),
// This was making labels on small combo boxes too small:   .withStandardItemHeight (label->getHeight()),
                         ModalCallbackFunction::forComponent (comboBoxPopupMenuFinishedCallback, this));
 }