diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 6ad20d83c..825750ce8 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -62,6 +62,9 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row) m_item_count_hint = 0; m_max_label_width = 0; + + m_scroll_callback.callback = NULL; + m_scroll_callback.data = NULL; } // ----------------------------------------------------------------------------- DynamicRibbonWidget::~DynamicRibbonWidget() @@ -821,6 +824,11 @@ void DynamicRibbonWidget::scroll(int x_delta, bool evenIfDeactivated) updateItemDisplay(); + if (m_scroll_callback.callback != NULL) + { + m_scroll_callback.callback(m_scroll_callback.data); + } + // update selection markers in child ribbon if (m_combo) { diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.hpp b/src/guiengine/widgets/dynamic_ribbon_widget.hpp index fa05a7c61..2754619e0 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.hpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.hpp @@ -64,6 +64,12 @@ namespace GUIEngine unsigned int m_badges; }; + struct DynamicRibbonScrollCallback + { + void* data; + void (*callback)(void* data); + }; + /** * \brief An extended version of RibbonWidget, with more capabilities. * A dynamic ribbon builds upon RibbonWidget, adding dynamic contents creation and sizing, @@ -191,6 +197,7 @@ namespace GUIEngine /** Max length of a label, in characters */ unsigned int m_max_label_length; + DynamicRibbonScrollCallback m_scroll_callback; public: LEAK_CHECK() @@ -313,6 +320,12 @@ namespace GUIEngine /** Set max length of displayed text. */ void setMaxLabelLength(int length) { m_max_label_length = length; } + + void registerScrollCallback(void (*callback)(void* data), void* data) + { + m_scroll_callback.callback = callback; + m_scroll_callback.data = data; + } }; } diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index 63a610d4d..74ef03ab9 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -191,11 +191,10 @@ void OptionsScreenVideo::init() assert( vsync != NULL ); vsync->setState( UserConfigParams::m_vsync ); - // ---- video modes DynamicRibbonWidget* res = getWidget("resolutions"); - assert( res != NULL ); - + assert(res != NULL); + res->registerScrollCallback(onScrollResolutionsList, this); CheckBoxWidget* full = getWidget("fullscreen"); assert( full != NULL ); @@ -398,6 +397,14 @@ void OptionsScreenVideo::updateResolutionsList() // ---------------------------------------------------------------------------- +void OptionsScreenVideo::onScrollResolutionsList(void* data) +{ + OptionsScreenVideo* screen = (OptionsScreenVideo*)data; + screen->updateResolutionsList(); +} + +// ---------------------------------------------------------------------------- + void OptionsScreenVideo::updateGfxSlider() { GUIEngine::SpinnerWidget* gfx = diff --git a/src/states_screens/options/options_screen_video.hpp b/src/states_screens/options/options_screen_video.hpp index 1fc5f09cc..eee79b146 100644 --- a/src/states_screens/options/options_screen_video.hpp +++ b/src/states_screens/options/options_screen_video.hpp @@ -89,8 +89,8 @@ private: void updateTooltip(); void updateResolutionsList(); - void initPresets(); + static void onScrollResolutionsList(void* data); public: friend class GUIEngine::ScreenSingleton;