mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 10:15:38 +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);
|
||||
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
||||
|
||||
computeMinimumWindowSize();
|
||||
|
||||
center();
|
||||
|
||||
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
||||
|
@ -739,6 +741,32 @@ namespace MWGui
|
|||
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()
|
||||
{
|
||||
mResolutionList->setScrollPosition(0);
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace MWGui
|
|||
void updateSliderLabel(MyGUI::ScrollBar* scroller, const std::string& value);
|
||||
|
||||
void layoutControlsBox();
|
||||
|
||||
void computeMinimumWindowSize();
|
||||
|
||||
private:
|
||||
void resetScrollbars();
|
||||
|
|
Loading…
Reference in a new issue