From f959a5cbeb48e23ebc67d4f8ec571e51b9849167 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Mar 2012 23:24:19 +0100 Subject: [PATCH] auto adjust size of map window title bar --- apps/openmw/mwgui/layouts.cpp | 1 + libs/openengine/gui/layout.hpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/apps/openmw/mwgui/layouts.cpp b/apps/openmw/mwgui/layouts.cpp index 5c5a977d3..9c49c62ac 100644 --- a/apps/openmw/mwgui/layouts.cpp +++ b/apps/openmw/mwgui/layouts.cpp @@ -202,6 +202,7 @@ void MapWindow::setVisible(bool b) void MapWindow::setCellName(const std::string& cellName) { static_cast(mMainWidget)->setCaption(cellName); + adjustWindowCaption(); } void MapWindow::setPlayerPos(const float x, const float y) diff --git a/libs/openengine/gui/layout.hpp b/libs/openengine/gui/layout.hpp index 3c03423c3..e73b2d1ce 100644 --- a/libs/openengine/gui/layout.hpp +++ b/libs/openengine/gui/layout.hpp @@ -80,6 +80,29 @@ namespace GUI mMainWidget->setCoord(x,y,w,h); } + void adjustWindowCaption() + { + // adjust the size of the window caption so that all text is visible + // NOTE: this assumes that mMainWidget is of type Window. + MyGUI::TextBox* box = static_cast(mMainWidget)->getCaptionWidget(); + box->setSize(box->getTextSize().width + 48, box->getSize().height); + + // in order to trigger alignment updates, we need to update the parent + // mygui doesn't provide a proper way of doing this, so we are just changing size + box->getParent()->setCoord(MyGUI::IntCoord( + box->getParent()->getCoord().left, + box->getParent()->getCoord().top, + box->getParent()->getCoord().width, + box->getParent()->getCoord().height+1 + )); + box->getParent()->setCoord(MyGUI::IntCoord( + box->getParent()->getCoord().left, + box->getParent()->getCoord().top, + box->getParent()->getCoord().width, + box->getParent()->getCoord().height-1 + )); + } + void setVisible(bool b) { mMainWidget->setVisible(b);