update MenuLayer ids

This commit is contained in:
HJfod 2023-02-11 19:34:40 +02:00
parent f4a3258586
commit 3f64b98cf1

View file

@ -35,28 +35,27 @@ $register_ids(MenuLayer) {
auto playBtn = setIDSafe(menu, 0, "play-button"); auto playBtn = setIDSafe(menu, 0, "play-button");
auto iconBtn = setIDSafe(menu, 1, "icon-kit-button"); auto iconBtn = setIDSafe(menu, 1, "icon-kit-button");
// the buttons are added in order play, icon, editor which doesn't work
// well with setLayout that deals with children in order
menu->swapChildIndices(playBtn, iconBtn);
setIDSafe(menu, 2, "editor-button"); setIDSafe(menu, 2, "editor-button");
if (auto pfp = setIDSafe(menu, 3, "profile-button")) { if (auto pfp = setIDSafe(menu, 3, "profile-button")) {
auto profileMenu = detachAndCreateMenu( auto profileMenu = detachAndCreateMenu(
this, "profile-menu", this, "profile-menu",
ColumnLayout::create() RowLayout::create()
->setAxisAlignment(AxisAlignment::Start) ->setAxisAlignment(AxisAlignment::Start),
->setAxisReverse(true),
pfp pfp
); );
profileMenu->setContentSize({ 50.f, 200.f }); profileMenu->setContentSize({ 200.f, 50.f });
profileMenu->setPositionY( profileMenu->setPositionX(
profileMenu->getPositionY() + 200.f / 2 - profileMenu->getPositionX() + 200.f / 2 -
pfp->getScaledContentSize().height / 2 pfp->getScaledContentSize().height / 2
); );
profileMenu->updateLayout(); profileMenu->updateLayout();
} }
// the buttons are added in order play, icon, editor which doesn't work
// well with setLayout that deals with children in order
menu->swapChildIndices(playBtn, iconBtn);
menu->setContentSize({ 400.f, 65.f }); menu->setContentSize({ 400.f, 65.f });
menu->setLayout( menu->setLayout(
RowLayout::create() RowLayout::create()