From de995e3a69f60c9bff28c15ccfe3f9cd4c3fcc67 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 10 May 2012 11:19:22 +0200 Subject: [PATCH] adjust topic list on window resize --- apps/openmw/mwgui/dialogue.cpp | 7 +++++++ apps/openmw/mwgui/dialogue.hpp | 1 + apps/openmw/mwgui/list.cpp | 5 +++++ apps/openmw/mwgui/list.hpp | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 3d47aa7dc..2e7429055 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -67,6 +67,8 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager) getWidget(pDispositionBar, "Disposition"); getWidget(pDispositionText,"DispositionText"); + + static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); } void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) @@ -88,6 +90,11 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) } } +void DialogueWindow::onWindowResize(MyGUI::Window* _sender) +{ + topicsList->adjustSize(); +} + void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) { if (history->getVScrollPosition() - _rel*0.3 < 0) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index ac29e9ec8..a8fed7d31 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -51,6 +51,7 @@ namespace MWGui void onByeClicked(MyGUI::Widget* _sender); void onHistoryClicked(MyGUI::Widget* _sender); void onMouseWheel(MyGUI::Widget* _sender, int _rel); + void onWindowResize(MyGUI::Window* _sender); private: void updateOptions(); diff --git a/apps/openmw/mwgui/list.cpp b/apps/openmw/mwgui/list.cpp index 733654b8c..d66cc6f89 100644 --- a/apps/openmw/mwgui/list.cpp +++ b/apps/openmw/mwgui/list.cpp @@ -32,6 +32,11 @@ void MWList::addItem(const std::string& name) redraw(); } +void MWList::adjustSize() +{ + redraw(); +} + void MWList::redraw(bool scrollbarShown) { const int _scrollBarWidth = 24; // fetch this from skin? diff --git a/apps/openmw/mwgui/list.hpp b/apps/openmw/mwgui/list.hpp index eedcae066..a2e9afcd1 100644 --- a/apps/openmw/mwgui/list.hpp +++ b/apps/openmw/mwgui/list.hpp @@ -9,7 +9,7 @@ namespace MWGui { /** * \brief a very simple list widget that supports word-wrapping entries - * \note does not handle changing the width of the list at runtime + * \note if the width or height of the list changes, you must call adjustSize() method */ class MWList : public MyGUI::Widget { @@ -25,6 +25,11 @@ namespace MWGui */ EventHandle_String eventItemSelected; + /** + * Call after the size of the list changed + */ + void adjustSize(); + void addItem(const std::string& name); void removeItem(const std::string& name); bool hasItem(const std::string& name);