Skip to content

Commit

Permalink
MIPP: Fix "Pan" control label cut off on the right
Browse files Browse the repository at this point in the history
  • Loading branch information
tedfelix committed Jan 27, 2025
1 parent f8daa37 commit 8a78c11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/gui/editors/parameters/MIDIInstrumentParameterPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/

#define RG_MODULE_STRING "[MIDIInstrumentParameterPanel]"

// Disable RG_DEBUG output. Must be defined prior to including Debug.h.
// Warnings are currently done with std::cerr to make sure they appear
// even in a release build.
#define RG_NO_DEBUG_PRINT
Expand Down Expand Up @@ -486,7 +484,9 @@ MIDIInstrumentParameterPanel::setupControllers(MidiDevice *md)
QCoreApplication::translate("MIDI_CONTROLLER",
it->getName().c_str()), hbox);

// ??? This has no effect on the font.
label->setFont(font());

hboxLayout->addWidget(label);

RG_DEBUG << "setupControllers(): Adding new widget at " << (count / 2) << "," << (count % 2);
Expand Down
17 changes: 11 additions & 6 deletions src/gui/widgets/SqueezedLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,21 @@ QSize SqueezedLabel::sizeHint() const
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QScreen* screen = this->screen();
int dw = screen->availableGeometry().width();
const int displayWidth = screen->availableGeometry().width();
#else
int dw = QApplication::desktop()->availableGeometry(QPoint(0, 0)).width();
const int displayWidth = QApplication::desktop()->availableGeometry(QPoint(0, 0)).width();
#endif
int maxWidth = dw * 3 / 4;
// 3/4 of the display width.
const int maxWidth = displayWidth * 3 / 4;

QFontMetrics fm(fontMetrics());
int textWidth = fm.boundingRect(d->fullText).width();
if (textWidth > maxWidth) {

// ??? This has problems with "Pan". It returns 18, but Pan needs more.
// Adding 1 here fixes "Pan".
int textWidth = fm.boundingRect(d->fullText).width() + 1;
if (textWidth > maxWidth)
textWidth = maxWidth;
}

return QSize(textWidth, QLabel::sizeHint().height());
}

Expand Down

0 comments on commit 8a78c11

Please sign in to comment.