From 5dc6cdeb99907385c7ca9cf513aa46f251595e8b Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Mon, 1 Jun 2015 01:14:11 +0300 Subject: [PATCH 1/4] Scroll to the top of the topic list when dialog is started --- apps/openmw/mwgui/dialogue.cpp | 2 ++ components/widgets/list.cpp | 4 ++++ components/widgets/list.hpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 692cea952..48b9be17d 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -364,6 +364,7 @@ namespace MWGui bool sameActor = (mPtr == actor); mPtr = actor; mTopicsList->setEnabled(true); + mTopicsList->scrollToFirstItem(); setTitle(npcName); clearChoices(); @@ -455,6 +456,7 @@ namespace MWGui mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t)); } mTopicsList->adjustSize(); + mTopicsList->scrollToFirstItem(); updateHistory(); } diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 5a79de3d1..e1d80f022 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -157,4 +157,8 @@ namespace Gui return mScrollView->findWidget (getName() + "_item_" + name)->castType(); } + void MWList::scrollToFirstItem() + { + mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); + } } diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp index 72c8a733c..1c24af6a4 100644 --- a/components/widgets/list.hpp +++ b/components/widgets/list.hpp @@ -46,6 +46,8 @@ namespace Gui MyGUI::Button* getItemWidget(const std::string& name); ///< get widget for an item name, useful to set up tooltip + void scrollToFirstItem(); + virtual void setPropertyOverride(const std::string& _key, const std::string& _value); protected: From 5350ce59efec0beee86f0637e5f6412631e31b79 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Mon, 1 Jun 2015 22:42:41 +0300 Subject: [PATCH 2/4] MWList doesn't scroll to the very bottom when it's shown for first time --- components/widgets/list.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index e1d80f022..535a3cad3 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -48,7 +48,7 @@ namespace Gui const int _scrollBarWidth = 20; // fetch this from skin? const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; const int spacing = 3; - size_t viewPosition = -mScrollView->getViewOffset().top; + int viewPosition = mScrollView->getViewOffset().top; while (mScrollView->getChildCount()) { @@ -99,10 +99,10 @@ namespace Gui if (!scrollbarShown && mItemHeight > mClient->getSize().height) redraw(true); - size_t viewRange = mScrollView->getCanvasSize().height; + int viewRange = mScrollView->getCanvasSize().height; if(viewPosition > viewRange) viewPosition = viewRange; - mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition * -1)); + mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition)); } void MWList::setPropertyOverride(const std::string &_key, const std::string &_value) From 959fe3eb8773be66219575ae161e625f03536f69 Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Mon, 1 Jun 2015 23:49:40 +0300 Subject: [PATCH 3/4] Reset the scrollbar position in the topic list when DialogueWindow is closed --- apps/openmw/mwgui/dialogue.cpp | 5 +++-- components/widgets/list.cpp | 2 +- components/widgets/list.hpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 48b9be17d..0cb0475c9 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -291,7 +291,10 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu); } else + { MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); + mTopicsList->scrollToTop(); + } } void DialogueWindow::onWindowResize(MyGUI::Window* _sender) @@ -364,7 +367,6 @@ namespace MWGui bool sameActor = (mPtr == actor); mPtr = actor; mTopicsList->setEnabled(true); - mTopicsList->scrollToFirstItem(); setTitle(npcName); clearChoices(); @@ -456,7 +458,6 @@ namespace MWGui mKeywordSearch.seed(Misc::StringUtils::lowerCase(*it), intptr_t(t)); } mTopicsList->adjustSize(); - mTopicsList->scrollToFirstItem(); updateHistory(); } diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 535a3cad3..db4092b3f 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -157,7 +157,7 @@ namespace Gui return mScrollView->findWidget (getName() + "_item_" + name)->castType(); } - void MWList::scrollToFirstItem() + void MWList::scrollToTop() { mScrollView->setViewOffset(MyGUI::IntPoint(0, 0)); } diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp index 1c24af6a4..3efe1ff75 100644 --- a/components/widgets/list.hpp +++ b/components/widgets/list.hpp @@ -46,7 +46,7 @@ namespace Gui MyGUI::Button* getItemWidget(const std::string& name); ///< get widget for an item name, useful to set up tooltip - void scrollToFirstItem(); + void scrollToTop(); virtual void setPropertyOverride(const std::string& _key, const std::string& _value); From 6cb221f8d09cce21ccdba5cae6e3fac0f0e49b1b Mon Sep 17 00:00:00 2001 From: Stanislav Bas Date: Tue, 2 Jun 2015 11:55:09 +0300 Subject: [PATCH 4/4] Some minor changes to MWList --- components/widgets/list.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index db4092b3f..df7e7d61d 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -48,7 +48,7 @@ namespace Gui const int _scrollBarWidth = 20; // fetch this from skin? const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; const int spacing = 3; - int viewPosition = mScrollView->getViewOffset().top; + int viewPosition = -mScrollView->getViewOffset().top; while (mScrollView->getChildCount()) { @@ -102,7 +102,7 @@ namespace Gui int viewRange = mScrollView->getCanvasSize().height; if(viewPosition > viewRange) viewPosition = viewRange; - mScrollView->setViewOffset(MyGUI::IntPoint(0, viewPosition)); + mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition)); } void MWList::setPropertyOverride(const std::string &_key, const std::string &_value)