garrynewman / GWEN

Abandoned: GWEN - GUI Without Extravagant Nonsense.
MIT License
428 stars 102 forks source link

Horz/Vert ScrollBar Nudge Notification #26

Open Zenroth opened 11 years ago

Zenroth commented 11 years ago

It seems like its impossible currently to get notification of a scrollbar nudge. The update chain leads to:

void VerticalScrollBar::OnBarMoved( Controls::Base* control )
{
    if ( m_Bar->IsDepressed() )
    {
        SetScrolledAmount( CalculateScrolledAmount(), false );
        BaseClass::OnBarMoved(control);
    }
    else
    {
        InvalidateParent();
    }
}

However, a nudge does not depress the bar, and as such no event is ever triggered.

My current solution is to change:

void HorizontalScrollBar::NudgeRight( Base* /*control*/ )
{
    if ( !IsDisabled() )
        SetScrolledAmount( GetScrolledAmount() + GetNudgeAmount(), true);
}

To:

void HorizontalScrollBar::NudgeRight( Base* /*control*/ )
{
    if ( !IsDisabled() )
    {
        bool result = SetScrolledAmount( GetScrolledAmount() + GetNudgeAmount(), true);

        if(result)
            BaseClass::OnBarMoved(this);
    }
}

Which seems to work fine in practice along with changing the NudgeLeft as well (And Nudges for the Vertical bar as well), but perhaps I'm missing something?

I could certainly inherit the scrollbars, and over ride the nudges myself, but that seems a bit wasteful.