From bc6a1979b0fdafdc32ae3958b13b3fcfc483889f Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 10 Sep 2012 13:39:22 +0200 Subject: [PATCH] replaced everything with the new method --- apps/openmw/mwgui/alchemywindow.cpp | 8 - apps/openmw/mwgui/birth.cpp | 9 - apps/openmw/mwgui/class.cpp | 38 ----- apps/openmw/mwgui/confirmationdialog.cpp | 12 -- apps/openmw/mwgui/container.cpp | 6 - apps/openmw/mwgui/countdialog.cpp | 12 -- apps/openmw/mwgui/itemselection.cpp | 6 - apps/openmw/mwgui/map_window.cpp | 4 - apps/openmw/mwgui/quickkeysmenu.cpp | 14 +- apps/openmw/mwgui/race.cpp | 9 - apps/openmw/mwgui/review.cpp | 67 ++------ apps/openmw/mwgui/review.hpp | 7 +- apps/openmw/mwgui/settingswindow.cpp | 5 - apps/openmw/mwgui/text_input.cpp | 4 - apps/openmw/mwgui/tradewindow.cpp | 34 ---- apps/openmw/mwgui/widgets.cpp | 52 +++++- apps/openmw/mwgui/widgets.hpp | 8 + files/mygui/openmw_alchemy_window.layout | 8 +- files/mygui/openmw_chargen_birth.layout | 13 +- files/mygui/openmw_chargen_class.layout | 13 +- .../openmw_chargen_class_description.layout | 3 +- .../mygui/openmw_chargen_create_class.layout | 19 ++- ...penmw_chargen_generate_class_result.layout | 13 +- files/mygui/openmw_chargen_race.layout | 13 +- files/mygui/openmw_chargen_review.layout | 16 +- .../openmw_chargen_select_attribute.layout | 3 +- .../mygui/openmw_chargen_select_skill.layout | 3 +- ...penmw_chargen_select_specialization.layout | 3 +- files/mygui/openmw_confirmation_dialog.layout | 13 +- files/mygui/openmw_container_window.layout | 14 +- files/mygui/openmw_count_window.layout | 14 +- .../mygui/openmw_itemselection_dialog.layout | 3 +- .../mygui/openmw_magicselection_dialog.layout | 3 +- files/mygui/openmw_map_window.layout | 4 +- files/mygui/openmw_quickkeys_menu.layout | 3 +- files/mygui/openmw_settings_window.layout | 156 +++++++++++------- files/mygui/openmw_text_input.layout | 3 +- files/mygui/openmw_trade_window.layout | 28 ++-- 38 files changed, 280 insertions(+), 363 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 804ccb2ba..308029810 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -48,14 +48,6 @@ namespace MWGui mIngredient3->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); mIngredient4->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); - MyGUI::Widget* buttonBox = mCancelButton->getParent(); - int cancelButtonWidth = mCancelButton->getTextSize().width + 24; - mCancelButton->setCoord(buttonBox->getWidth() - cancelButtonWidth, - mCancelButton->getTop(), cancelButtonWidth, mCancelButton->getHeight()); - int createButtonWidth = mCreateButton->getTextSize().width + 24; - mCreateButton->setCoord(buttonBox->getWidth() - createButtonWidth - cancelButtonWidth - 4, - mCreateButton->getTop(), createButtonWidth, mCreateButton->getHeight()); - mCreateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCreateButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCancelButtonClicked); diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 1a5c2d0f6..043fcd62c 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -45,9 +45,6 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) void BirthDialog::setNextButtonShow(bool shown) { - MyGUI::ButtonPtr backButton; - getWidget(backButton, "BackButton"); - MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); @@ -55,12 +52,6 @@ void BirthDialog::setNextButtonShow(bool shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); - - int okButtonWidth = okButton->getTextSize().width + 24; - int backButtonWidth = backButton->getTextSize().width + 24; - - okButton->setCoord(473 - okButtonWidth, 340, okButtonWidth, 23); - backButton->setCoord(473 - okButtonWidth - backButtonWidth - 6, 340, backButtonWidth, 23); } void BirthDialog::open() diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 9ea7b8052..309aa5a5d 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -39,11 +39,6 @@ GenerateClassResultDialog::GenerateClassResultDialog(MWBase::WindowManager& parW getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); - - int okButtonWidth = okButton->getTextSize().width + 24; - int backButtonWidth = backButton->getTextSize().width + 24; - okButton->setCoord(315 - okButtonWidth, 219, okButtonWidth, 23); - backButton->setCoord(315 - okButtonWidth - backButtonWidth - 6, 219, backButtonWidth, 23); } std::string GenerateClassResultDialog::getClassId() const @@ -116,9 +111,6 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager) void PickClassDialog::setNextButtonShow(bool shown) { - MyGUI::ButtonPtr backButton; - getWidget(backButton, "BackButton"); - MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); @@ -126,12 +118,6 @@ void PickClassDialog::setNextButtonShow(bool shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); - - int okButtonWidth = okButton->getTextSize().width + 24; - int backButtonWidth = backButton->getTextSize().width + 24; - - okButton->setCoord(476 - okButtonWidth, 265, okButtonWidth, 23); - backButton->setCoord(476 - okButtonWidth - backButtonWidth - 6, 265, backButtonWidth, 23); } void PickClassDialog::open() @@ -422,7 +408,6 @@ CreateClassDialog::CreateClassDialog(MWBase::WindowManager& parWindowManager) MyGUI::ButtonPtr descriptionButton; getWidget(descriptionButton, "DescriptionButton"); - descriptionButton->setCaption(mWindowManager.getGameSettingString("sCreateClassMenu1", "")); descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked); MyGUI::ButtonPtr backButton; @@ -519,27 +504,13 @@ std::vector CreateClassDialog::getMinorSkills() const void CreateClassDialog::setNextButtonShow(bool shown) { - MyGUI::ButtonPtr backButton; - getWidget(backButton, "BackButton"); - MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - MyGUI::ButtonPtr descriptionButton; - getWidget(descriptionButton, "DescriptionButton"); - if (shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); - - int okButtonWidth = okButton->getTextSize().width + 24; - int backButtonWidth = backButton->getTextSize().width + 24; - int descriptionButtonWidth = descriptionButton->getTextSize().width + 24; - - okButton->setCoord(459 - okButtonWidth, 158, okButtonWidth, 23); - backButton->setCoord(459 - okButtonWidth - backButtonWidth - 6, 158, backButtonWidth, 23); - descriptionButton->setCoord(459 - okButtonWidth - backButtonWidth - descriptionButtonWidth - 12, 158, descriptionButtonWidth, 23); } // widget controls @@ -713,8 +684,6 @@ SelectSpecializationDialog::SelectSpecializationDialog(MWBase::WindowManager& pa getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); - int buttonWidth = cancelButton->getTextSize().width + 24; - cancelButton->setCoord(216 - buttonWidth, 90, buttonWidth, 21); } SelectSpecializationDialog::~SelectSpecializationDialog() @@ -768,8 +737,6 @@ SelectAttributeDialog::SelectAttributeDialog(MWBase::WindowManager& parWindowMan getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); - int buttonWidth = cancelButton->getTextSize().width + 24; - cancelButton->setCoord(186 - buttonWidth, 180, buttonWidth, 21); } SelectAttributeDialog::~SelectAttributeDialog() @@ -863,9 +830,6 @@ SelectSkillDialog::SelectSkillDialog(MWBase::WindowManager& parWindowManager) getWidget(cancelButton, "CancelButton"); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); - int buttonWidth = cancelButton->getTextSize().width + 24; - cancelButton->setCoord(447 - buttonWidth, 218, buttonWidth, 21); - } SelectSkillDialog::~SelectSkillDialog() @@ -899,8 +863,6 @@ DescriptionDialog::DescriptionDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", "")); - int buttonWidth = okButton->getTextSize().width + 24; - okButton->setCoord(234 - buttonWidth, 214, buttonWidth, 24); // Make sure the edit box has focus MyGUI::InputManager::getInstance().setKeyFocusWidget(mTextEdit); diff --git a/apps/openmw/mwgui/confirmationdialog.cpp b/apps/openmw/mwgui/confirmationdialog.cpp index d22181d60..31f4989e0 100644 --- a/apps/openmw/mwgui/confirmationdialog.cpp +++ b/apps/openmw/mwgui/confirmationdialog.cpp @@ -31,18 +31,6 @@ namespace MWGui mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height+24); center(); - - int okButtonWidth = mOkButton->getTextSize().width + 24; - mOkButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth, - mOkButton->getTop(), - okButtonWidth, - mOkButton->getHeight()); - - int cancelButtonWidth = mCancelButton->getTextSize().width + 24; - mCancelButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth - cancelButtonWidth - 8, - mCancelButton->getTop(), - cancelButtonWidth, - mCancelButton->getHeight()); } void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 8454094c1..93ec71343 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -607,12 +607,6 @@ ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAnd mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked); mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked); - // adjust buttons size to fit text - int closeButtonWidth = mCloseButton->getTextSize().width+24; - int takeButtonWidth = mTakeButton->getTextSize().width+24; - mCloseButton->setCoord(600-20-closeButtonWidth, mCloseButton->getCoord().top, closeButtonWidth, mCloseButton->getCoord().height); - mTakeButton->setCoord(600-20-closeButtonWidth-takeButtonWidth-8, mTakeButton->getCoord().top, takeButtonWidth, mTakeButton->getCoord().height); - static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ContainerWindow::onWindowResize); setCoord(200,0,600,300); diff --git a/apps/openmw/mwgui/countdialog.cpp b/apps/openmw/mwgui/countdialog.cpp index 0ed9cf8ca..baf14e3fb 100644 --- a/apps/openmw/mwgui/countdialog.cpp +++ b/apps/openmw/mwgui/countdialog.cpp @@ -44,18 +44,6 @@ namespace MWGui mSlider->setScrollPosition(maxCount-1); mItemEdit->setCaption(boost::lexical_cast(maxCount)); - - int okButtonWidth = mOkButton->getTextSize().width + 24; - mOkButton->setCoord(width - 30 - okButtonWidth, - mOkButton->getTop(), - okButtonWidth, - mOkButton->getHeight()); - - int cancelButtonWidth = mCancelButton->getTextSize().width + 24; - mCancelButton->setCoord(width - 30 - okButtonWidth - cancelButtonWidth - 8, - mCancelButton->getTop(), - cancelButtonWidth, - mCancelButton->getHeight()); } void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/itemselection.cpp b/apps/openmw/mwgui/itemselection.cpp index d93a621ac..14b1cf8ee 100644 --- a/apps/openmw/mwgui/itemselection.cpp +++ b/apps/openmw/mwgui/itemselection.cpp @@ -23,12 +23,6 @@ namespace MWGui getWidget(cancelButton, "CancelButton"); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked); - int dx = (cancelButton->getTextSize().width + 24) - cancelButton->getWidth(); - cancelButton->setCoord(cancelButton->getLeft() - dx, - cancelButton->getTop(), - cancelButton->getTextSize ().width + 24, - cancelButton->getHeight()); - center(); } diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index 0d6300baa..f92e4ee4f 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -259,8 +259,6 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager) : getWidget(mButton, "WorldButton"); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); mButton->setCaptionWithReplacing("#{sWorld}"); - int width = mButton->getTextSize().width + 24; - mButton->setCoord(mMainWidget->getSize().width - width - 22, mMainWidget->getSize().height - 64, width, 22); MyGUI::Button* eventbox; getWidget(eventbox, "EventBox"); @@ -303,8 +301,6 @@ void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender) mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}"); - int width = mButton->getTextSize().width + 24; - mButton->setCoord(mMainWidget->getSize().width - width - 22, mMainWidget->getSize().height - 64, width, 22); } void MapWindow::onPinToggled() diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 5b7115dbe..c46445465 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -52,13 +52,8 @@ namespace MWGui mMainWidget->setSize(mMainWidget->getWidth(), mMainWidget->getHeight() + (mInstructionLabel->getTextSize().height - mInstructionLabel->getHeight())); - int okButtonWidth = mOkButton->getTextSize ().width + 24; - mOkButton->setCoord(mOkButton->getLeft() - (okButtonWidth - mOkButton->getWidth()), - mOkButton->getTop(), - okButtonWidth, - mOkButton->getHeight()); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &QuickKeysMenu::onOkButtonClicked); - + std::cout << "real ok button is : " << mOkButton->getName() << std::endl; center(); @@ -72,7 +67,6 @@ namespace MWGui unassign(button, i); mQuickKeyButtons.push_back(button); - } } @@ -407,12 +401,6 @@ namespace MWGui getWidget(mMagicList, "MagicList"); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MagicSelectionDialog::onCancelButtonClicked); - int dx = (mCancelButton->getTextSize().width + 24) - mCancelButton->getWidth(); - mCancelButton->setCoord(mCancelButton->getLeft() - dx, - mCancelButton->getTop(), - mCancelButton->getTextSize ().width + 24, - mCancelButton->getHeight()); - center(); } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index a597dcadb..370b30733 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -90,9 +90,6 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) void RaceDialog::setNextButtonShow(bool shown) { - MyGUI::ButtonPtr backButton; - getWidget(backButton, "BackButton"); - MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); @@ -100,12 +97,6 @@ void RaceDialog::setNextButtonShow(bool shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); - - int okButtonWidth = okButton->getTextSize().width + 24; - int backButtonWidth = backButton->getTextSize().width + 24; - - okButton->setCoord(574 - okButtonWidth, 397, okButtonWidth, 23); - backButton->setCoord(574 - okButtonWidth - backButtonWidth - 6, 397, backButtonWidth, 23); } void RaceDialog::open() diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index b1925178d..76b211b18 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -77,12 +77,8 @@ ReviewDialog::ReviewDialog(MWBase::WindowManager& parWindowManager) } // Setup skills - getWidget(mSkillAreaWidget, "Skills"); - getWidget(mSkillClientWidget, "SkillClient"); - getWidget(mSkillScrollerWidget, "SkillScroller"); - mSkillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - mSkillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); - updateScroller(); + getWidget(mSkillView, "SkillView"); + mSkillView->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); for (int i = 0; i < ESM::Skill::Length; ++i) { @@ -90,21 +86,13 @@ ReviewDialog::ReviewDialog(MWBase::WindowManager& parWindowManager) mSkillWidgetMap.insert(std::make_pair(i, static_cast (0))); } - static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); - MyGUI::ButtonPtr backButton; getWidget(backButton, "BackButton"); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); - - int backButtonWidth = backButton->getTextSize().width + 24; - int okButtonWidth = okButton->getTextSize().width + 24; - okButton->setCoord(502 - okButtonWidth, 372, okButtonWidth, 23); - backButton->setCoord(502 - okButtonWidth - backButtonWidth - 6, 372, backButtonWidth, 23); } void ReviewDialog::open() @@ -112,26 +100,6 @@ void ReviewDialog::open() updateSkillArea(); } -void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos) -{ - int diff = mLastPos - pos; - // Adjust position of all widget according to difference - if (diff == 0) - return; - mLastPos = pos; - - std::vector::const_iterator end = mSkillWidgets.end(); - for (std::vector::const_iterator it = mSkillWidgets.begin(); it != end; ++it) - { - (*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff)); - } -} - -void ReviewDialog::onWindowResize(MyGUI::Window* window) -{ - updateScroller(); -} - void ReviewDialog::setPlayerName(const std::string &name) { mNameWidget->setCaption(name); @@ -239,7 +207,7 @@ void ReviewDialog::configureSkills(const std::vector& major, const std::vec void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::ImageBox* separator = mSkillClientWidget->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); + MyGUI::ImageBox* separator = mSkillView->createWidget("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); separator->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); mSkillWidgets.push_back(separator); @@ -250,7 +218,7 @@ void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2 void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) { - MyGUI::TextBox* groupWidget = mSkillClientWidget->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); + MyGUI::TextBox* groupWidget = mSkillView->createWidget("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); groupWidget->setCaption(label); mSkillWidgets.push_back(groupWidget); @@ -264,11 +232,11 @@ MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::s MyGUI::TextBox* skillNameWidget; MyGUI::TextBox* skillValueWidget; - skillNameWidget = mSkillClientWidget->createWidget("SandText", coord1, MyGUI::Align::Default); + skillNameWidget = mSkillView->createWidget("SandText", coord1, MyGUI::Align::Default); skillNameWidget->setCaption(text); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); - skillValueWidget = mSkillClientWidget->createWidget("SandTextRight", coord2, MyGUI::Align::Top | MyGUI::Align::Right); + skillValueWidget = mSkillView->createWidget("SandTextRight", coord2, MyGUI::Align::Top | MyGUI::Align::Right); skillValueWidget->setCaption(value); skillValueWidget->_setWidgetState(state); skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); @@ -286,7 +254,7 @@ void ReviewDialog::addItem(const std::string& text, MyGUI::IntCoord &coord1, MyG { MyGUI::TextBox* skillNameWidget; - skillNameWidget = mSkillClientWidget->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); + skillNameWidget = mSkillView->createWidget("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget->setCaption(text); skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &ReviewDialog::onMouseWheel); @@ -343,7 +311,7 @@ void ReviewDialog::updateSkillArea() mSkillWidgets.clear(); const int valueSize = 40; - MyGUI::IntCoord coord1(10, 0, mSkillClientWidget->getWidth() - (10 + valueSize), 18); + MyGUI::IntCoord coord1(10, 0, mSkillView->getWidth() - (10 + valueSize) - 24, 18); MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height); if (!mMajorSkills.empty()) @@ -356,15 +324,8 @@ void ReviewDialog::updateSkillArea() addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); mClientHeight = coord1.top; - updateScroller(); -} -void ReviewDialog::updateScroller() -{ - mSkillScrollerWidget->setScrollRange(std::max(mClientHeight - mSkillClientWidget->getHeight(), 0)); - mSkillScrollerWidget->setScrollPage(std::max(mSkillClientWidget->getHeight() - sLineHeight, 0)); - if (mClientHeight != 0) - mSkillScrollerWidget->setTrackSize( (mSkillAreaWidget->getHeight() / float(mClientHeight)) * mSkillScrollerWidget->getLineSize() ); + mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight)); } // widget controls @@ -401,12 +362,8 @@ void ReviewDialog::onBirthSignClicked(MyGUI::Widget* _sender) void ReviewDialog::onMouseWheel(MyGUI::Widget* _sender, int _rel) { - if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 < 0) - mSkillScrollerWidget->setScrollPosition(0); - else if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 > mSkillScrollerWidget->getScrollRange()-1) - mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollRange()-1); + if (mSkillView->getViewOffset().top + _rel*0.3 > 0) + mSkillView->setViewOffset(MyGUI::IntPoint(0, 0)); else - mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollPosition() - _rel*0.3); - - onScrollChangePosition(mSkillScrollerWidget, mSkillScrollerWidget->getScrollPosition()); + mSkillView->setViewOffset(MyGUI::IntPoint(0, mSkillView->getViewOffset().top + _rel*0.3)); } diff --git a/apps/openmw/mwgui/review.hpp b/apps/openmw/mwgui/review.hpp index 5685d194a..058e3cff3 100644 --- a/apps/openmw/mwgui/review.hpp +++ b/apps/openmw/mwgui/review.hpp @@ -74,17 +74,12 @@ namespace MWGui void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); MyGUI::TextBox* addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string& text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); - void updateScroller(); void updateSkillArea(); - void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos); - void onWindowResize(MyGUI::Window* window); - static const int sLineHeight; MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget; - MyGUI::WidgetPtr mSkillAreaWidget, mSkillClientWidget; - MyGUI::ScrollBar* mSkillScrollerWidget; + MyGUI::ScrollView* mSkillView; int mLastPos, mClientHeight; Widgets::MWDynamicStatPtr mHealth, mMagicka, mFatigue; diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 2599ea0b2..d1e206a95 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -160,11 +160,6 @@ namespace MWGui center(); - int okSize = mOkButton->getTextSize().width + 24; - mOkButton->setCoord(mMainWidget->getWidth()-16-okSize, mOkButton->getTop(), - okSize, mOkButton->getHeight()); - - mResetControlsButton->setSize (mResetControlsButton->getTextSize ().width + 24, mResetControlsButton->getHeight()); mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings); // fill resolution list diff --git a/apps/openmw/mwgui/text_input.cpp b/apps/openmw/mwgui/text_input.cpp index b724bab15..9d5ba9896 100644 --- a/apps/openmw/mwgui/text_input.cpp +++ b/apps/openmw/mwgui/text_input.cpp @@ -30,10 +30,6 @@ void TextInputDialog::setNextButtonShow(bool shown) okButton->setCaption(mWindowManager.getGameSettingString("sNext", "")); else okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); - - int okButtonWidth = okButton->getTextSize().width + 24; - - okButton->setCoord(306 - okButtonWidth, 60, okButtonWidth, 23); } void TextInputDialog::setTextLabel(const std::string &label) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 9abd97bb7..b980b834e 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -42,26 +42,6 @@ namespace MWGui getWidget(mTotalBalanceLabel, "TotalBalanceLabel"); getWidget(mBottomPane, "BottomPane"); - // adjust size of buttons to fit text - int curX = 0; - mFilterAll->setSize( mFilterAll->getTextSize().width + 24, mFilterAll->getSize().height ); - curX += mFilterAll->getTextSize().width + 24 + 4; - - mFilterWeapon->setPosition(curX, mFilterWeapon->getPosition().top); - mFilterWeapon->setSize( mFilterWeapon->getTextSize().width + 24, mFilterWeapon->getSize().height ); - curX += mFilterWeapon->getTextSize().width + 24 + 4; - - mFilterApparel->setPosition(curX, mFilterApparel->getPosition().top); - mFilterApparel->setSize( mFilterApparel->getTextSize().width + 24, mFilterApparel->getSize().height ); - curX += mFilterApparel->getTextSize().width + 24 + 4; - - mFilterMagic->setPosition(curX, mFilterMagic->getPosition().top); - mFilterMagic->setSize( mFilterMagic->getTextSize().width + 24, mFilterMagic->getSize().height ); - curX += mFilterMagic->getTextSize().width + 24 + 4; - - mFilterMisc->setPosition(curX, mFilterMisc->getPosition().top); - mFilterMisc->setSize( mFilterMisc->getTextSize().width + 24, mFilterMisc->getSize().height ); - mFilterAll->setStateSelected(true); mFilterAll->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onFilterChanged); @@ -73,20 +53,6 @@ namespace MWGui mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked); mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked); - mMaxSaleButton->setSize(MyGUI::IntSize(mMaxSaleButton->getTextSize().width + 24, mMaxSaleButton->getHeight())); - - int cancelButtonWidth = mCancelButton->getTextSize().width + 24; - mCancelButton->setCoord(mBottomPane->getWidth()-cancelButtonWidth, - mCancelButton->getTop(), - cancelButtonWidth, - mCancelButton->getHeight()); - - int offerButtonWidth = mOfferButton->getTextSize().width + 24; - mOfferButton->setCoord(mBottomPane->getWidth()-cancelButtonWidth-offerButtonWidth-8, - mOfferButton->getTop(), - offerButtonWidth, - mOfferButton->getHeight()); - setCoord(400, 0, 400, 300); static_cast(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &TradeWindow::onWindowResize); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 66488adf0..97a5b2eb5 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -803,6 +803,15 @@ void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w) Box* b = dynamic_cast(w->getParent()); if (b) b->notifyChildrenSizeChanged (); + else + { + if (mExpandDirection == MyGUI::Align::Left) + { + int hdiff = getRequestedSize ().width - w->getSize().width; + w->setPosition(w->getPosition() - MyGUI::IntPoint(hdiff, 0)); + } + w->setSize(getRequestedSize ()); + } } } @@ -819,10 +828,24 @@ void AutoSizedTextBox::setCaption(const MyGUI::UString& _value) notifySizeChange (this); } +void AutoSizedTextBox::setPropertyOverride(const std::string& _key, const std::string& _value) +{ + if (_key == "ExpandDirection") + { + mExpandDirection = MyGUI::Align::parse (_value); + } + else + { + TextBox::setPropertyOverride (_key, _value); + } +} + MyGUI::IntSize AutoSizedButton::getRequestedSize() { - return getTextSize() + MyGUI::IntSize(24,0); + MyGUI::IntSize size = getTextSize() + MyGUI::IntSize(24,0); + size.height = std::max(24, size.height); + return size; } void AutoSizedButton::setCaption(const MyGUI::UString& _value) @@ -832,6 +855,17 @@ void AutoSizedButton::setCaption(const MyGUI::UString& _value) notifySizeChange (this); } +void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::string& _value) +{ + if (_key == "ExpandDirection") + { + mExpandDirection = MyGUI::Align::parse (_value); + } + else + { + Button::setPropertyOverride (_key, _value); + } +} Box::Box() : mSpacing(4) @@ -870,11 +904,15 @@ void HBox::align () { sizes.push_back(std::make_pair(aw->getRequestedSize (), hstretch)); total_width += aw->getRequestedSize ().width; - if (i != count-1) - total_width += mSpacing; } else - sizes.push_back (std::make_pair(MyGUI::IntSize(0,0), hstretch)); + { + if (!hstretch) h_stretched_count ++; + sizes.push_back (std::make_pair(MyGUI::IntSize(0,0), true)); + } + + if (i != count-1) + total_width += mSpacing; } int curX = 0; @@ -883,11 +921,11 @@ void HBox::align () MyGUI::Widget* w = getChildAt(i); MyGUI::IntCoord widgetCoord; widgetCoord.left = curX; - widgetCoord.top = 0; /// \todo + widgetCoord.top = (getSize().height - sizes[i].first.height) / 2; int width = sizes[i].second ? sizes[i].first.width + (getSize().width - total_width)/h_stretched_count : sizes[i].first.width; widgetCoord.width = width; - widgetCoord.height = getSize().height; /// \todo + widgetCoord.height = sizes[i].first.height; w->setCoord(widgetCoord); curX += width; @@ -925,7 +963,7 @@ MyGUI::IntSize HBox::getRequestedSize () void VBox::align () { - + // not yet implemented } void VBox::setSize (const MyGUI::IntSize& _value) diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index d7cc4afcf..16c2adec9 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -315,6 +315,8 @@ namespace MWGui protected: void notifySizeChange(MyGUI::Widget* w); + + MyGUI::Align mExpandDirection; }; class AutoSizedTextBox : public AutoSizedWidget, public MyGUI::TextBox @@ -324,6 +326,9 @@ namespace MWGui public: virtual MyGUI::IntSize getRequestedSize(); virtual void setCaption(const MyGUI::UString& _value); + + protected: + virtual void setPropertyOverride(const std::string& _key, const std::string& _value); }; class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button @@ -333,6 +338,9 @@ namespace MWGui public: virtual MyGUI::IntSize getRequestedSize(); virtual void setCaption(const MyGUI::UString& _value); + + protected: + virtual void setPropertyOverride(const std::string& _key, const std::string& _value); }; /** diff --git a/files/mygui/openmw_alchemy_window.layout b/files/mygui/openmw_alchemy_window.layout index 68df748b1..458d24b2c 100644 --- a/files/mygui/openmw_alchemy_window.layout +++ b/files/mygui/openmw_alchemy_window.layout @@ -76,11 +76,13 @@ - - + + + + - + diff --git a/files/mygui/openmw_chargen_birth.layout b/files/mygui/openmw_chargen_birth.layout index 0599ab863..5edec72d3 100644 --- a/files/mygui/openmw_chargen_birth.layout +++ b/files/mygui/openmw_chargen_birth.layout @@ -14,11 +14,14 @@ - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_class.layout b/files/mygui/openmw_chargen_class.layout index 613143d54..baa36b24a 100644 --- a/files/mygui/openmw_chargen_class.layout +++ b/files/mygui/openmw_chargen_class.layout @@ -60,11 +60,14 @@ - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_class_description.layout b/files/mygui/openmw_chargen_class_description.layout index 2ffc7d707..11031eb4e 100644 --- a/files/mygui/openmw_chargen_class_description.layout +++ b/files/mygui/openmw_chargen_class_description.layout @@ -11,7 +11,8 @@ - + + diff --git a/files/mygui/openmw_chargen_create_class.layout b/files/mygui/openmw_chargen_create_class.layout index dde74a6a2..5e08db6e5 100644 --- a/files/mygui/openmw_chargen_create_class.layout +++ b/files/mygui/openmw_chargen_create_class.layout @@ -58,14 +58,17 @@ - - - - - - - - + + + + + + + + + + + diff --git a/files/mygui/openmw_chargen_generate_class_result.layout b/files/mygui/openmw_chargen_generate_class_result.layout index 1cef9c9ce..65dbf016c 100644 --- a/files/mygui/openmw_chargen_generate_class_result.layout +++ b/files/mygui/openmw_chargen_generate_class_result.layout @@ -20,11 +20,14 @@ - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_race.layout b/files/mygui/openmw_chargen_race.layout index df0d29f78..3d32ffd9a 100644 --- a/files/mygui/openmw_chargen_race.layout +++ b/files/mygui/openmw_chargen_race.layout @@ -54,11 +54,14 @@ - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_review.layout b/files/mygui/openmw_chargen_review.layout index 2071cac88..dbe7a4780 100644 --- a/files/mygui/openmw_chargen_review.layout +++ b/files/mygui/openmw_chargen_review.layout @@ -107,16 +107,18 @@ - - + - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_select_attribute.layout b/files/mygui/openmw_chargen_select_attribute.layout index e1ab4d888..09c2a4aae 100644 --- a/files/mygui/openmw_chargen_select_attribute.layout +++ b/files/mygui/openmw_chargen_select_attribute.layout @@ -20,7 +20,8 @@ - + + diff --git a/files/mygui/openmw_chargen_select_skill.layout b/files/mygui/openmw_chargen_select_skill.layout index 2c7dae80c..2cf81e6c6 100644 --- a/files/mygui/openmw_chargen_select_skill.layout +++ b/files/mygui/openmw_chargen_select_skill.layout @@ -55,7 +55,8 @@ - + + diff --git a/files/mygui/openmw_chargen_select_specialization.layout b/files/mygui/openmw_chargen_select_specialization.layout index 1b5295bc9..e9cb76825 100644 --- a/files/mygui/openmw_chargen_select_specialization.layout +++ b/files/mygui/openmw_chargen_select_specialization.layout @@ -22,7 +22,8 @@ - + + diff --git a/files/mygui/openmw_confirmation_dialog.layout b/files/mygui/openmw_confirmation_dialog.layout index 7b8bd2a1f..ba98d3220 100644 --- a/files/mygui/openmw_confirmation_dialog.layout +++ b/files/mygui/openmw_confirmation_dialog.layout @@ -13,11 +13,14 @@ - - - - - + + + + + + + + diff --git a/files/mygui/openmw_container_window.layout b/files/mygui/openmw_container_window.layout index ae9b0bfdf..896566fdd 100644 --- a/files/mygui/openmw_container_window.layout +++ b/files/mygui/openmw_container_window.layout @@ -11,12 +11,14 @@ - - - - - - + + + + + + + + diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index ae6635dff..59b0a9c30 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -20,11 +20,15 @@ - - - - - + + + + + + + + + diff --git a/files/mygui/openmw_itemselection_dialog.layout b/files/mygui/openmw_itemselection_dialog.layout index 81376d6d5..39c048303 100644 --- a/files/mygui/openmw_itemselection_dialog.layout +++ b/files/mygui/openmw_itemselection_dialog.layout @@ -11,7 +11,8 @@ - + + diff --git a/files/mygui/openmw_magicselection_dialog.layout b/files/mygui/openmw_magicselection_dialog.layout index 31ad7b4c9..a89795473 100644 --- a/files/mygui/openmw_magicselection_dialog.layout +++ b/files/mygui/openmw_magicselection_dialog.layout @@ -11,7 +11,8 @@ - + + diff --git a/files/mygui/openmw_map_window.layout b/files/mygui/openmw_map_window.layout index 63fd03b14..8b64de22e 100644 --- a/files/mygui/openmw_map_window.layout +++ b/files/mygui/openmw_map_window.layout @@ -19,7 +19,9 @@ - + + + diff --git a/files/mygui/openmw_quickkeys_menu.layout b/files/mygui/openmw_quickkeys_menu.layout index a45f2896f..dcb10404d 100644 --- a/files/mygui/openmw_quickkeys_menu.layout +++ b/files/mygui/openmw_quickkeys_menu.layout @@ -30,7 +30,8 @@ - + + diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 077dbac2d..38d2786e5 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -103,16 +103,17 @@ - + - - - + + + + + - @@ -157,26 +158,35 @@ - - - - - - + + + + + + - - - + + + + + - + + + + + + - - + + + + + - @@ -200,7 +210,7 @@ - + @@ -230,74 +240,99 @@ - - + + + + + + - + - - + + + + + - - - + + + + + - - - + + + + + - - - - + + + + + - - - + + + + + - - - - - - - + + + + + - - - + + + + + - - - + + + + + - - - + + + + + - - - + + + + + + + + + + + + - - @@ -307,8 +342,9 @@ - - + + + diff --git a/files/mygui/openmw_text_input.layout b/files/mygui/openmw_text_input.layout index c8f76b257..a2ed94c67 100644 --- a/files/mygui/openmw_text_input.layout +++ b/files/mygui/openmw_text_input.layout @@ -10,7 +10,8 @@ - + + diff --git a/files/mygui/openmw_trade_window.layout b/files/mygui/openmw_trade_window.layout index c8a9f2523..7de6c85e6 100644 --- a/files/mygui/openmw_trade_window.layout +++ b/files/mygui/openmw_trade_window.layout @@ -5,20 +5,20 @@ - - + + - + - + - + - + @@ -51,14 +51,18 @@ - + - - - - - + + + + + + + + +