mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-27 21:41:37 +00:00
Recompute minimum settings window size based on tab bar size
This commit is contained in:
parent
9d134efb4d
commit
73e9d7f315
2 changed files with 30 additions and 0 deletions
|
@ -267,6 +267,8 @@ namespace MWGui
|
||||||
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
||||||
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
||||||
|
|
||||||
|
computeMinimumWindowSize();
|
||||||
|
|
||||||
center();
|
center();
|
||||||
|
|
||||||
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
||||||
|
@ -739,6 +741,32 @@ namespace MWGui
|
||||||
layoutControlsBox();
|
layoutControlsBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsWindow::computeMinimumWindowSize()
|
||||||
|
{
|
||||||
|
auto* window = mMainWidget->castType<MyGUI::Window>();
|
||||||
|
auto minSize = window->getMinSize();
|
||||||
|
|
||||||
|
// Window should be at minimum wide enough to show all tabs.
|
||||||
|
int tabBarWidth = 0;
|
||||||
|
for (uint32_t i = 0; i < mSettingsTab->getItemCount(); i++)
|
||||||
|
{
|
||||||
|
tabBarWidth += mSettingsTab->getButtonWidthAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to include window margins
|
||||||
|
int margins = mMainWidget->getWidth() - mSettingsTab->getWidth();
|
||||||
|
int minimumWindowWidth = tabBarWidth + margins;
|
||||||
|
|
||||||
|
if (minimumWindowWidth > minSize.width)
|
||||||
|
{
|
||||||
|
minSize.width = minimumWindowWidth;
|
||||||
|
window->setMinSize(minSize);
|
||||||
|
|
||||||
|
// Make a dummy call to setSize so MyGUI can apply any resize resulting from the change in MinSize
|
||||||
|
mMainWidget->setSize(mMainWidget->getSize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsWindow::resetScrollbars()
|
void SettingsWindow::resetScrollbars()
|
||||||
{
|
{
|
||||||
mResolutionList->setScrollPosition(0);
|
mResolutionList->setScrollPosition(0);
|
||||||
|
|
|
@ -76,6 +76,8 @@ namespace MWGui
|
||||||
|
|
||||||
void layoutControlsBox();
|
void layoutControlsBox();
|
||||||
|
|
||||||
|
void computeMinimumWindowSize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetScrollbars();
|
void resetScrollbars();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue