From 449d68282f23f348be5840a5210191871eee53a7 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 20 Mar 2014 12:44:39 -0400 Subject: [PATCH] KeyMap: Fix alignment of role labels ... by setting all labels to take up the width of the longest label. Fixes #10693 --- src/preferences/keymap/ModifierKeysWindow.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/preferences/keymap/ModifierKeysWindow.cpp b/src/preferences/keymap/ModifierKeysWindow.cpp index 875d82374b..9c9adefa8b 100644 --- a/src/preferences/keymap/ModifierKeysWindow.cpp +++ b/src/preferences/keymap/ModifierKeysWindow.cpp @@ -292,7 +292,27 @@ ModifierKeysWindow::ModifierKeysWindow() // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); - float forcedMinWidth = be_plain_font->StringWidth("XXX") * 4; + // find the minimum width to fit the labels + float shiftLabelWidth + = shiftMenuField->StringWidth(shiftMenuField->Label()); + float controlLabelWidth + = controlMenuField->StringWidth(controlMenuField->Label()); + float optionLabelWidth + = optionMenuField->StringWidth(optionMenuField->Label()); + float commandLabelWidth + = commandMenuField->StringWidth(commandMenuField->Label()); + + float forcedMinWidth = shiftLabelWidth; + if (controlLabelWidth > forcedMinWidth) + forcedMinWidth = controlLabelWidth; + + if (optionLabelWidth > forcedMinWidth) + forcedMinWidth = optionLabelWidth; + + if (commandLabelWidth > forcedMinWidth) + forcedMinWidth = commandLabelWidth; + + forcedMinWidth += be_plain_font->StringWidth("XXX"); keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem();