From 90b7df439ff6d7b68d9a0269dd6d207158da5a5c Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 8 May 2013 13:55:15 +0200 Subject: [PATCH] Fix image buttons --- apps/openmw/mwgui/bookwindow.cpp | 21 ++++++++++ apps/openmw/mwgui/bookwindow.hpp | 1 + apps/openmw/mwgui/journalwindow.cpp | 38 +++++++++++++++++++ apps/openmw/mwgui/scrollwindow.cpp | 15 ++++++++ files/mygui/openmw_book.layout | 26 +++++++------ files/mygui/openmw_journal.layout | 59 ++++++++++++++--------------- files/mygui/openmw_scroll.layout | 2 +- 7 files changed, 118 insertions(+), 44 deletions(-) diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index 12e5b466b..3b5deb5ac 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -38,6 +38,18 @@ namespace MWGui getWidget(mLeftPage, "LeftPage"); getWidget(mRightPage, "RightPage"); + adjustButton(mCloseButton); + adjustButton(mTakeButton); + adjustButton(mNextPageButton); + adjustButton(mPrevPageButton); + + if (mNextPageButton->getSize().width == 64) + { + // english button has a 7 pixel wide strip of garbage on its right edge + mNextPageButton->setSize(64-7, mNextPageButton->getSize().height); + mNextPageButton->setImageCoord(MyGUI::IntCoord(0,0,64-7,mNextPageButton->getSize().height)); + } + center(); } @@ -174,4 +186,13 @@ namespace MWGui } } + void BookWindow::adjustButton (MWGui::ImageButton* button) + { + MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(); + button->setSize(button->getRequestedSize()); + + if (button->getAlign().isRight()) + button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0)); + } + } diff --git a/apps/openmw/mwgui/bookwindow.hpp b/apps/openmw/mwgui/bookwindow.hpp index 9123969e0..c6ea486d4 100644 --- a/apps/openmw/mwgui/bookwindow.hpp +++ b/apps/openmw/mwgui/bookwindow.hpp @@ -27,6 +27,7 @@ namespace MWGui void updatePages(); void clearPages(); + void adjustButton(MWGui::ImageButton* button); private: MWGui::ImageButton* mCloseButton; diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index d0332c943..e463bf0ba 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -137,10 +137,47 @@ namespace getPage (QuestsPage)->adviseLinkClicked (callback); } + adjustButton(OptionsBTN); + adjustButton(PrevPageBTN); + adjustButton(NextPageBTN); + adjustButton(CloseBTN); + adjustButton(CancelBTN); + adjustButton(ShowAllBTN); + adjustButton(ShowActiveBTN); + adjustButton(JournalBTN); + + MWGui::ImageButton* nextButton = getWidget(NextPageBTN); + if (nextButton->getSize().width == 64) + { + // english button has a 7 pixel wide strip of garbage on its right edge + nextButton->setSize(64-7, nextButton->getSize().height); + nextButton->setImageCoord(MyGUI::IntCoord(0,0,64-7,nextButton->getSize().height)); + } + + adjustButton(TopicsBTN); + adjustButton(QuestsBTN); + int width = getWidget(TopicsBTN)->getSize().width + getWidget(QuestsBTN)->getSize().width; + int topicsWidth = getWidget(TopicsBTN)->getSize().width; + int pageWidth = getWidget(RightBookPage)->getSize().width; + + getWidget(TopicsBTN)->setPosition((pageWidth - width)/2, getWidget(TopicsBTN)->getPosition().top); + getWidget(QuestsBTN)->setPosition((pageWidth - width)/2 + topicsWidth, getWidget(QuestsBTN)->getPosition().top); + mQuestMode = false; mAllQuests = false; } + void adjustButton (char const * name) + { + MWGui::ImageButton* button = getWidget(name); + + MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(); + button->setSize(button->getRequestedSize()); + + if (button->getAlign().isRight()) + button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0)); + } + void open() { mModel->load (); @@ -391,6 +428,7 @@ namespace void notifyClose(MyGUI::Widget* _sender) { + MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); MWBase::Environment::get().getWindowManager ()->popGuiMode (); } diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index b44c21c6e..eb46b9c1e 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -10,6 +10,18 @@ #include "formatting.hpp" +namespace +{ + void adjustButton (MWGui::ImageButton* button) + { + MyGUI::IntSize diff = button->getSize() - button->getRequestedSize(); + button->setSize(button->getRequestedSize()); + + if (button->getAlign().isRight()) + button->setPosition(button->getPosition() + MyGUI::IntPoint(diff.width,0)); + } +} + namespace MWGui { @@ -26,6 +38,9 @@ namespace MWGui getWidget(mTakeButton, "TakeButton"); mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ScrollWindow::onTakeButtonClicked); + adjustButton(mCloseButton); + adjustButton(mTakeButton); + center(); } diff --git a/files/mygui/openmw_book.layout b/files/mygui/openmw_book.layout index 96d1153f0..d9ac2f43a 100644 --- a/files/mygui/openmw_book.layout +++ b/files/mygui/openmw_book.layout @@ -8,25 +8,27 @@ - - - - - + + + + + + - - - - - + + + + + + + - - + diff --git a/files/mygui/openmw_journal.layout b/files/mygui/openmw_journal.layout index 1b440b833..58d2c2690 100644 --- a/files/mygui/openmw_journal.layout +++ b/files/mygui/openmw_journal.layout @@ -8,6 +8,21 @@ + + + + + + + + + + + + + + + @@ -17,29 +32,16 @@ - - - - - - - - - - - - + - - + - @@ -62,46 +64,41 @@ - - - - - - - - - - - - - - + + + + + + + + + + + - - diff --git a/files/mygui/openmw_scroll.layout b/files/mygui/openmw_scroll.layout index 6315c0241..194700f36 100644 --- a/files/mygui/openmw_scroll.layout +++ b/files/mygui/openmw_scroll.layout @@ -13,7 +13,7 @@ - +