garrynewman / GWEN

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

slider call SetFloatValue without calling onValueChanged #72

Open q-depot opened 11 years ago

q-depot commented 11 years ago

Hi,

I need to set the float value for a slider without calling the onValueChanged handler which should only be called when the value is set by the mouse click on the slider. I looked at the Slider source code and this seems not possible without changing the SetFloatValue signature to allow an extra parameter "ignoreEvent" or something like that. This would be my approach, but I want to double check if I'm the only one that needs this feature and if there is a work around with the current api.

thanks.

Wizzard033 commented 11 years ago

I recommend you add this functionality in to a fork. Other controls have a doEvents boolean in their parameters that defaults to true.

q-depot commented 11 years ago

would be nice to implement the same thing for all the controls, perhaps this should be in Controls::Base?

Wizzard033 commented 11 years ago

What? Why would all controls need to set a float value? Here is an example from Label.cpp :

void Label::SetText( const TextObject & str, bool bDoEvents )
{
    if ( m_Text->GetText() == str.GetUnicode() ) { return; }

    m_Text->SetString( str );
    Redraw();

    if ( bDoEvents )
    { OnTextChanged(); }
}

I think a lot of code encapsulation is violated by Gwen's design. Even Base::SetValue( const TextObject & ) was not a good idea in opinion because not all controls have a string value.

q-depot commented 11 years ago

I mean all the controls should have a variable to ignore the callback

Wizzard033 commented 11 years ago

I personally like the current way of just having a boolean on each function that may affect events that can be set to false to not do the event.