From 26bd2a5301d5b75e70c7c21f0abff4546bd5899c Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 5 Jul 2013 20:28:46 +0200 Subject: [PATCH] use the new scrollbar; range dependent step size; fix --- apps/openmw/mwgui/widgets.cpp | 46 +++++++++++++++++++---- apps/openmw/mwgui/widgets.hpp | 3 ++ files/mygui/openmw_chargen_race.layout | 2 +- files/mygui/openmw_count_window.layout | 2 +- files/mygui/openmw_dialogue_window.layout | 2 +- files/mygui/openmw_edit.skin.xml | 2 +- files/mygui/openmw_edit_effect.layout | 8 ++-- files/mygui/openmw_list.skin.xml | 4 +- files/mygui/openmw_map_window_skin.xml | 4 +- files/mygui/openmw_scroll_skin.xml | 4 +- files/mygui/openmw_settings_window.layout | 22 +++++------ 11 files changed, 67 insertions(+), 32 deletions(-) diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index d147b28b1..c57630f08 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -899,6 +899,7 @@ namespace MWGui : mEnableRepeat(true) , mRepeatTriggerTime(0.5) , mRepeatStepTime(0.1) + , mStepSize(0) { } @@ -908,12 +909,18 @@ namespace MWGui void MWScrollBar::initialiseOverride() { - Base::initialiseOverride(); + ScrollBar::initialiseOverride(); - mWidgetStart->eventMouseButtonPressed += MyGUI::newDelegate(this, &MWScrollBar::onDecreaseButtonPressed); - mWidgetStart->eventMouseButtonReleased += MyGUI::newDelegate(this, &MWScrollBar::onDecreaseButtonReleased); - mWidgetEnd->eventMouseButtonPressed += MyGUI::newDelegate(this, &MWScrollBar::onIncreaseButtonPressed); - mWidgetEnd->eventMouseButtonReleased += MyGUI::newDelegate(this, &MWScrollBar::onIncreaseButtonReleased); + if(mWidgetStart) + { + mWidgetStart->eventMouseButtonPressed += MyGUI::newDelegate(this, &MWScrollBar::onDecreaseButtonPressed); + mWidgetStart->eventMouseButtonReleased += MyGUI::newDelegate(this, &MWScrollBar::onDecreaseButtonReleased); + } + if(mWidgetEnd) + { + mWidgetEnd->eventMouseButtonPressed += MyGUI::newDelegate(this, &MWScrollBar::onIncreaseButtonPressed); + mWidgetEnd->eventMouseButtonReleased += MyGUI::newDelegate(this, &MWScrollBar::onIncreaseButtonReleased); + } } void MWScrollBar::setEnableRepeat(bool enable) @@ -938,17 +945,42 @@ namespace MWGui mRepeatStepTime = step; } + void MWScrollBar::setStepSize(int step) + { + mStepSize = step; + } + + int MWScrollBar::getStepSize() + { + return mStepSize; + } + void MWScrollBar::repeatClick(MyGUI::Widget* _widget, MyGUI::ControllerItem* _controller) { + int stepSize = mStepSize; + if(stepSize == 0) + stepSize = mScrollRange/20; + if(mIsIncreasing && mScrollPosition < mScrollRange-1) { - mScrollPosition += 1; + if(mScrollPosition + stepSize > mScrollRange-1) + mScrollPosition = mScrollRange-1; + else + mScrollPosition += stepSize; + eventScrollChangePosition(this, mScrollPosition); + updateTrack(); } else if(!mIsIncreasing && mScrollPosition > 0) { - mScrollPosition -= 1; + int newPos = mScrollPosition - stepSize; + if(newPos < 0) + mScrollPosition = 0; + else + mScrollPosition -= stepSize; + eventScrollChangePosition(this, mScrollPosition); + updateTrack(); } } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 1630ab3c9..136056bf4 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -422,6 +422,8 @@ namespace MWGui bool getEnableRepeat(); void getRepeat(float &trigger, float &step); void setRepeat(float trigger, float step); + void setStepSize(int step); + int getStepSize(); protected: virtual void initialiseOverride(); @@ -431,6 +433,7 @@ namespace MWGui float mRepeatTriggerTime; float mRepeatStepTime; bool mIsIncreasing; + int mStepSize; private: void onDecreaseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id); diff --git a/files/mygui/openmw_chargen_race.layout b/files/mygui/openmw_chargen_race.layout index c569abb86..55dbe3218 100644 --- a/files/mygui/openmw_chargen_race.layout +++ b/files/mygui/openmw_chargen_race.layout @@ -14,7 +14,7 @@ - + diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index 5812ec7fd..4e24277af 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -16,7 +16,7 @@ - + diff --git a/files/mygui/openmw_dialogue_window.layout b/files/mygui/openmw_dialogue_window.layout index 46090d000..a314ba312 100644 --- a/files/mygui/openmw_dialogue_window.layout +++ b/files/mygui/openmw_dialogue_window.layout @@ -10,7 +10,7 @@ - + diff --git a/files/mygui/openmw_edit.skin.xml b/files/mygui/openmw_edit.skin.xml index da21385e2..1f14f6f66 100644 --- a/files/mygui/openmw_edit.skin.xml +++ b/files/mygui/openmw_edit.skin.xml @@ -45,7 +45,7 @@ - + diff --git a/files/mygui/openmw_edit_effect.layout b/files/mygui/openmw_edit_effect.layout index cad22c064..fa1e58b9d 100644 --- a/files/mygui/openmw_edit_effect.layout +++ b/files/mygui/openmw_edit_effect.layout @@ -31,7 +31,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -56,7 +56,7 @@ - + @@ -72,7 +72,7 @@ - + diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index a5065c7ca..d680f80d2 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -120,7 +120,7 @@ - + @@ -150,7 +150,7 @@ - + diff --git a/files/mygui/openmw_map_window_skin.xml b/files/mygui/openmw_map_window_skin.xml index 13f18c6d3..2f5bb4faf 100644 --- a/files/mygui/openmw_map_window_skin.xml +++ b/files/mygui/openmw_map_window_skin.xml @@ -5,7 +5,7 @@ - - + + diff --git a/files/mygui/openmw_scroll_skin.xml b/files/mygui/openmw_scroll_skin.xml index 1b94f0c29..76e22c69f 100644 --- a/files/mygui/openmw_scroll_skin.xml +++ b/files/mygui/openmw_scroll_skin.xml @@ -4,12 +4,12 @@ - + - + diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout index 3c65bb690..b4ac8a247 100644 --- a/files/mygui/openmw_settings_window.layout +++ b/files/mygui/openmw_settings_window.layout @@ -15,7 +15,7 @@ - + @@ -30,7 +30,7 @@ - + @@ -64,35 +64,35 @@ - + - + - + - + - + @@ -117,7 +117,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -207,7 +207,7 @@ - + @@ -215,7 +215,7 @@ - +