Update active widgets on resolutions list when ribbon widget is scrolled
This commit is contained in:
parent
ebde419566
commit
cdff36f840
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -191,11 +191,10 @@ void OptionsScreenVideo::init()
|
||||
assert( vsync != NULL );
|
||||
vsync->setState( UserConfigParams::m_vsync );
|
||||
|
||||
|
||||
// ---- video modes
|
||||
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
|
||||
assert( res != NULL );
|
||||
|
||||
assert(res != NULL);
|
||||
res->registerScrollCallback(onScrollResolutionsList, this);
|
||||
|
||||
CheckBoxWidget* full = getWidget<CheckBoxWidget>("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 =
|
||||
|
@ -89,8 +89,8 @@ private:
|
||||
|
||||
void updateTooltip();
|
||||
void updateResolutionsList();
|
||||
|
||||
void initPresets();
|
||||
static void onScrollResolutionsList(void* data);
|
||||
public:
|
||||
friend class GUIEngine::ScreenSingleton<OptionsScreenVideo>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user