From 5cd04af3fa5239c2c548a43a465ec905438bde0a Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Tue, 1 Nov 2016 16:37:00 +0100 Subject: [PATCH 1/4] Fix horrible performance when resizing/moving the settings window Resize widgets instead of reconstructing them. --- apps/openmw/mwgui/settingswindow.cpp | 28 ++++++++++++++++++++-------- apps/openmw/mwgui/settingswindow.hpp | 2 ++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index a0833194b..3211473e2 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -466,9 +466,6 @@ namespace MWGui else actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting(); - const int h = 18; - const int w = mControlsBox->getWidth() - 28; - int curH = 0; for (std::vector::const_iterator it = actions.begin(); it != actions.end(); ++it) { std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (*it); @@ -481,16 +478,15 @@ namespace MWGui else binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(*it); - Gui::SharedStateButton* leftText = mControlsBox->createWidget("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default); + Gui::SharedStateButton* leftText = mControlsBox->createWidget("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default); leftText->setCaptionWithReplacing(desc); - Gui::SharedStateButton* rightText = mControlsBox->createWidget("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default); + Gui::SharedStateButton* rightText = mControlsBox->createWidget("SandTextButton", MyGUI::IntCoord(), MyGUI::Align::Default); rightText->setCaptionWithReplacing(binding); rightText->setTextAlign (MyGUI::Align::Right); rightText->setUserData(*it); // save the action id for callbacks rightText->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onRebindAction); rightText->eventMouseWheel += MyGUI::newDelegate(this, &SettingsWindow::onInputTabMouseWheel); - curH += h; Gui::ButtonGroup group; group.push_back(leftText); @@ -498,9 +494,25 @@ namespace MWGui Gui::SharedStateButton::createButtonGroup(group); } + layoutControlsBox(); + } + + void SettingsWindow::layoutControlsBox() + { + const int h = 18; + const int w = mControlsBox->getWidth() - 28; + const int noWidgetsInRow = 2; + const int totalH = mControlsBox->getChildCount() / noWidgetsInRow * h; + + for (size_t i = 0; i < mControlsBox->getChildCount(); i++) + { + MyGUI::Widget * widget = mControlsBox->getChildAt(i); + widget->setCoord(0, i / noWidgetsInRow * h, w, h); + } + // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mControlsBox->setVisibleVScroll(false); - mControlsBox->setCanvasSize (mControlsBox->getWidth(), std::max(curH, mControlsBox->getHeight())); + mControlsBox->setCanvasSize (mControlsBox->getWidth(), std::max(totalH, mControlsBox->getHeight())); mControlsBox->setVisibleVScroll(true); } @@ -556,7 +568,7 @@ namespace MWGui void SettingsWindow::onWindowResize(MyGUI::Window *_sender) { - updateControlsBox(); + layoutControlsBox(); } void SettingsWindow::resetScrollbars() diff --git a/apps/openmw/mwgui/settingswindow.hpp b/apps/openmw/mwgui/settingswindow.hpp index 5b12cc557..2ac06dcaa 100644 --- a/apps/openmw/mwgui/settingswindow.hpp +++ b/apps/openmw/mwgui/settingswindow.hpp @@ -66,6 +66,8 @@ namespace MWGui void configureWidgets(MyGUI::Widget* widget); void updateSliderLabel(MyGUI::ScrollBar* scroller, const std::string& value); + + void layoutControlsBox(); private: void resetScrollbars(); From 0c4dd05118527bbc51e690edf8497c8690e6e86d Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 5 Nov 2016 12:09:47 +0100 Subject: [PATCH 2/4] Link OpenMW with libz on macOS --- CI/before_script.osx.sh | 1 - apps/openmw/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CI/before_script.osx.sh b/CI/before_script.osx.sh index 32bdd41ae..00a948c65 100755 --- a/CI/before_script.osx.sh +++ b/CI/before_script.osx.sh @@ -10,7 +10,6 @@ mkdir build cd build cmake \ --D CMAKE_EXE_LINKER_FLAGS="-lz" \ -D CMAKE_PREFIX_PATH="$DEPENDENCIES_ROOT;$QT_PATH" \ -D CMAKE_OSX_DEPLOYMENT_TARGET="10.8" \ -D CMAKE_OSX_SYSROOT="macosx10.11" \ diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 58dc2e8e5..c349e3fef 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -181,7 +181,7 @@ endif() if(APPLE) find_library(COCOA_FRAMEWORK Cocoa) find_library(IOKIT_FRAMEWORK IOKit) - target_link_libraries(openmw ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) + target_link_libraries(openmw z ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) if (FFmpeg_FOUND) find_library(COREVIDEO_FRAMEWORK CoreVideo) From 0115a3a87437d4da33b8162776e6149cbe5de236 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 5 Nov 2016 12:11:04 +0100 Subject: [PATCH 3/4] Revert "Link OpenMW with libz on macOS" This reverts commit 0c4dd05118527bbc51e690edf8497c8690e6e86d. --- CI/before_script.osx.sh | 1 + apps/openmw/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CI/before_script.osx.sh b/CI/before_script.osx.sh index 00a948c65..32bdd41ae 100755 --- a/CI/before_script.osx.sh +++ b/CI/before_script.osx.sh @@ -10,6 +10,7 @@ mkdir build cd build cmake \ +-D CMAKE_EXE_LINKER_FLAGS="-lz" \ -D CMAKE_PREFIX_PATH="$DEPENDENCIES_ROOT;$QT_PATH" \ -D CMAKE_OSX_DEPLOYMENT_TARGET="10.8" \ -D CMAKE_OSX_SYSROOT="macosx10.11" \ diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index c349e3fef..58dc2e8e5 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -181,7 +181,7 @@ endif() if(APPLE) find_library(COCOA_FRAMEWORK Cocoa) find_library(IOKIT_FRAMEWORK IOKit) - target_link_libraries(openmw z ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) + target_link_libraries(openmw ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) if (FFmpeg_FOUND) find_library(COREVIDEO_FRAMEWORK CoreVideo) From 3adf4cb97f0f986c3a19fafc42b53555ed8c80b2 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Sat, 5 Nov 2016 12:09:47 +0100 Subject: [PATCH 4/4] Link OpenMW with libz on macOS --- CI/before_script.osx.sh | 1 - apps/openmw/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CI/before_script.osx.sh b/CI/before_script.osx.sh index 32bdd41ae..00a948c65 100755 --- a/CI/before_script.osx.sh +++ b/CI/before_script.osx.sh @@ -10,7 +10,6 @@ mkdir build cd build cmake \ --D CMAKE_EXE_LINKER_FLAGS="-lz" \ -D CMAKE_PREFIX_PATH="$DEPENDENCIES_ROOT;$QT_PATH" \ -D CMAKE_OSX_DEPLOYMENT_TARGET="10.8" \ -D CMAKE_OSX_SYSROOT="macosx10.11" \ diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 58dc2e8e5..332a6f0ac 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -186,7 +186,7 @@ if(APPLE) if (FFmpeg_FOUND) find_library(COREVIDEO_FRAMEWORK CoreVideo) find_library(VDA_FRAMEWORK VideoDecodeAcceleration) - target_link_libraries(openmw ${COREVIDEO_FRAMEWORK} ${VDA_FRAMEWORK}) + target_link_libraries(openmw z ${COREVIDEO_FRAMEWORK} ${VDA_FRAMEWORK}) endif() endif(APPLE)