forked from mirror/openmw-tes3mp
fix for Bug #509
This commit is contained in:
parent
1132032599
commit
0ae48c1f83
3 changed files with 37 additions and 8 deletions
|
@ -1,9 +1,9 @@
|
|||
#include "list.hpp"
|
||||
|
||||
#include <MyGUI_ScrollView.h>
|
||||
#include <MyGUI_Gui.h>
|
||||
#include <MyGUI_Button.h>
|
||||
#include <MyGUI_ImageBox.h>
|
||||
#include <MyGUI_ScrollBar.h>
|
||||
|
||||
using namespace MWGui;
|
||||
using namespace MWGui::Widgets;
|
||||
|
@ -23,7 +23,7 @@ void MWList::initialiseOverride()
|
|||
if (mClient == 0)
|
||||
mClient = this;
|
||||
|
||||
mScrollView = mClient->createWidgetReal<MyGUI::ScrollView>(
|
||||
mScrollView = mClient->createWidgetReal<MWGui::Widgets::MWScrollView>(
|
||||
"MW_ScrollView", MyGUI::FloatCoord(0.0, 0.0, 1.0, 1.0),
|
||||
MyGUI::Align::Top | MyGUI::Align::Left | MyGUI::Align::Stretch, getName() + "_ScrollView");
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ void MWList::redraw(bool scrollbarShown)
|
|||
const int _scrollBarWidth = 24; // fetch this from skin?
|
||||
const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0;
|
||||
const int spacing = 3;
|
||||
size_t scrollbarPosition = mScrollView->getScrollPosition();
|
||||
|
||||
while (mScrollView->getChildCount())
|
||||
{
|
||||
|
@ -88,6 +89,11 @@ void MWList::redraw(bool scrollbarShown)
|
|||
|
||||
if (!scrollbarShown && mItemHeight > mClient->getSize().height)
|
||||
redraw(true);
|
||||
|
||||
size_t scrollbarRange = mScrollView->getScrollRange();
|
||||
if(scrollbarPosition > scrollbarRange)
|
||||
scrollbarPosition = scrollbarRange;
|
||||
mScrollView->setScrollPosition(scrollbarPosition);
|
||||
}
|
||||
|
||||
bool MWList::hasItem(const std::string& name)
|
||||
|
@ -138,3 +144,17 @@ MyGUI::Widget* MWList::getItemWidget(const std::string& name)
|
|||
{
|
||||
return mScrollView->findWidget (getName() + "_item_" + name);
|
||||
}
|
||||
|
||||
size_t MWScrollView::getScrollPosition()
|
||||
{
|
||||
return getVScroll()->getScrollPosition();
|
||||
}
|
||||
|
||||
void MWScrollView::setScrollPosition(size_t position)
|
||||
{
|
||||
getVScroll()->setScrollPosition(position);
|
||||
}
|
||||
size_t MWScrollView::getScrollRange()
|
||||
{
|
||||
return getVScroll()->getScrollRange();
|
||||
}
|
||||
|
|
|
@ -2,16 +2,24 @@
|
|||
#define MWGUI_LIST_HPP
|
||||
|
||||
#include <MyGUI_Widget.h>
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class ScrollView;
|
||||
}
|
||||
#include <MyGUI_ScrollView.h>
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
namespace Widgets
|
||||
{
|
||||
/**
|
||||
* \brief a custom ScrollView which has access to scrollbar properties
|
||||
*/
|
||||
class MWScrollView : public MyGUI::ScrollView
|
||||
{
|
||||
MYGUI_RTTI_DERIVED(MWScrollView)
|
||||
public:
|
||||
size_t getScrollPosition();
|
||||
void setScrollPosition(size_t);
|
||||
size_t getScrollRange();
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief a very simple list widget that supports word-wrapping entries
|
||||
* \note if the width or height of the list changes, you must call adjustSize() method
|
||||
|
@ -63,7 +71,7 @@ namespace MWGui
|
|||
void onItemSelected(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::ScrollView* mScrollView;
|
||||
MWGui::Widgets::MWScrollView* mScrollView;
|
||||
MyGUI::Widget* mClient;
|
||||
|
||||
std::vector<std::string> mItems;
|
||||
|
|
|
@ -132,6 +132,7 @@ WindowManager::WindowManager(
|
|||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::AutoSizedButton>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ImageButton>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::ExposedWindow>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWScrollView>("Widget");
|
||||
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
|
||||
MyGUI::ResourceManager::getInstance().load("core.xml");
|
||||
|
|
Loading…
Reference in a new issue