KeyMap: Redo modifier keys layout
... by using a group layout inside of a grid layout we can get this to layout how we want it without having to calculate the label widths manually.
This commit is contained in:
@@ -289,65 +289,34 @@ ModifierKeysWindow::ModifierKeysWindow()
|
|||||||
new BMessage(kMsgApplyModifiers));
|
new BMessage(kMsgApplyModifiers));
|
||||||
fOkButton->MakeDefault(true);
|
fOkButton->MakeDefault(true);
|
||||||
|
|
||||||
// Build the layout
|
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_SMALL_SPACING)
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
|
||||||
|
.Add(keyRole, 0, 0)
|
||||||
|
.Add(keyLabel, 1, 0)
|
||||||
|
|
||||||
// find the minimum width to fit the labels
|
.Add(shiftMenuField->CreateLabelLayoutItem(), 0, 1)
|
||||||
float shiftLabelWidth
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1)
|
||||||
= shiftMenuField->StringWidth(shiftMenuField->Label());
|
.Add(shiftMenuField->CreateMenuBarLayoutItem())
|
||||||
float controlLabelWidth
|
.Add(fShiftConflictView)
|
||||||
= controlMenuField->StringWidth(controlMenuField->Label());
|
.End()
|
||||||
float optionLabelWidth
|
|
||||||
= optionMenuField->StringWidth(optionMenuField->Label());
|
|
||||||
float commandLabelWidth
|
|
||||||
= commandMenuField->StringWidth(commandMenuField->Label());
|
|
||||||
|
|
||||||
float forcedMinWidth = shiftLabelWidth;
|
.Add(controlMenuField->CreateLabelLayoutItem(), 0, 2)
|
||||||
if (controlLabelWidth > forcedMinWidth)
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 2)
|
||||||
forcedMinWidth = controlLabelWidth;
|
.Add(controlMenuField->CreateMenuBarLayoutItem())
|
||||||
|
.Add(fControlConflictView)
|
||||||
|
.End()
|
||||||
|
|
||||||
if (optionLabelWidth > forcedMinWidth)
|
.Add(optionMenuField->CreateLabelLayoutItem(), 0, 3)
|
||||||
forcedMinWidth = optionLabelWidth;
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 3)
|
||||||
|
.Add(optionMenuField->CreateMenuBarLayoutItem())
|
||||||
|
.Add(fOptionConflictView)
|
||||||
|
.End()
|
||||||
|
|
||||||
if (commandLabelWidth > forcedMinWidth)
|
.Add(commandMenuField->CreateLabelLayoutItem(), 0, 4)
|
||||||
forcedMinWidth = commandLabelWidth;
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 4)
|
||||||
|
.Add(commandMenuField->CreateMenuBarLayoutItem())
|
||||||
forcedMinWidth += be_plain_font->StringWidth("XXX");
|
.Add(fCommandConflictView)
|
||||||
keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
|
.End()
|
||||||
|
|
||||||
BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem();
|
|
||||||
shiftLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
|
|
||||||
BLayoutItem* controlLabel = controlMenuField->CreateLabelLayoutItem();
|
|
||||||
controlLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
|
|
||||||
BLayoutItem* optionLabel = optionMenuField->CreateLabelLayoutItem();
|
|
||||||
optionLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
|
|
||||||
BLayoutItem* commandLabel = commandMenuField->CreateLabelLayoutItem();
|
|
||||||
commandLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
|
|
||||||
|
|
||||||
AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING)
|
|
||||||
.AddGroup(B_HORIZONTAL)
|
|
||||||
.Add(keyRole)
|
|
||||||
.Add(keyLabel)
|
|
||||||
.End()
|
|
||||||
.AddGroup(B_HORIZONTAL)
|
|
||||||
.Add(shiftLabel)
|
|
||||||
.Add(shiftMenuField->CreateMenuBarLayoutItem())
|
|
||||||
.Add(fShiftConflictView)
|
|
||||||
.End()
|
|
||||||
.AddGroup(B_HORIZONTAL)
|
|
||||||
.Add(controlLabel)
|
|
||||||
.Add(controlMenuField->CreateMenuBarLayoutItem())
|
|
||||||
.Add(fControlConflictView)
|
|
||||||
.End()
|
|
||||||
.AddGroup(B_HORIZONTAL)
|
|
||||||
.Add(optionLabel)
|
|
||||||
.Add(optionMenuField->CreateMenuBarLayoutItem())
|
|
||||||
.Add(fOptionConflictView)
|
|
||||||
.End()
|
|
||||||
.AddGroup(B_HORIZONTAL)
|
|
||||||
.Add(commandLabel)
|
|
||||||
.Add(commandMenuField->CreateMenuBarLayoutItem())
|
|
||||||
.Add(fCommandConflictView)
|
|
||||||
.End()
|
.End()
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
@@ -357,7 +326,7 @@ ModifierKeysWindow::ModifierKeysWindow()
|
|||||||
.Add(fOkButton)
|
.Add(fOkButton)
|
||||||
.End()
|
.End()
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
);
|
.End();
|
||||||
|
|
||||||
_MarkMenuItems();
|
_MarkMenuItems();
|
||||||
_ValidateDuplicateKeys();
|
_ValidateDuplicateKeys();
|
||||||
|
|||||||
Reference in New Issue
Block a user