Giter Site home page Giter Site logo

Comments (2)

EternityX avatar EternityX commented on July 17, 2024 1

Controls are only redrawn/updated when required (changing position, size, etc)

void CheckBox::SetChecked( bool checked ) {
    if( checked_ != checked ) {
        checked_ = checked;
        checkedChangedEvent_.Invoke( this );
        Invalidate(); // tells the renderer to redraw the control.
    }
}

Lets say you have a checkbox that is initialized with the variable epic_bool from your settings struct, when and if the epic_bool is updated, the checkbox will not reflect this change automatically.

You can manually update the checkbox by calling SetChecked( epic_bool ) which in return will redraw the checkbox. If you want something more automated you could use OSHGui::Timer to call
the SetChecked( epic_bool ) function every 250 milliseconds or so.

auto timer = new OSHGui::Timer();
timer->SetInterval( 250 );
timer->Start();
parent->AddControl( timer );

timer->GetTickEvent() += OSHGui::TickEventHandler( [ this, epic_bool ]( Control *sender ) {
    this->SetChecked( epic_bool );
});

However this isn't the best approach simply for the fact it's needlessly redrawing the control. Perhaps you can think of something better so you only need to redraw the checkbox when needed.

If you have any further questions, don't hesitate to ask.

from deadcell-oshgui.

johnj0hn avatar johnj0hn commented on July 17, 2024

Hello, I ended up doing what you suggested

Manually updating the components

It seems to be quite dirty but oh well, atleast it works.
Thanks for the help.

from deadcell-oshgui.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.