Giter Site home page Giter Site logo

color_picker color change about iced_aw HOT 3 CLOSED

iced-rs avatar iced-rs commented on July 18, 2024
color_picker color change

from iced_aw.

Comments (3)

latidoremi avatar latidoremi commented on July 18, 2024 1

The color picker stores the color alongside with some caches in the overlay state and those don't react to color changes from the outside

Here's a dirty fix which is recreating the overlay state when show_picker is false, the problem is that show_picker will be false for most of the time, and Widget::overlay() is called on every update and draw, multiple times even, meaning that it's a waste of computation to update the overlay state this often

A better solution would be to update the overlay state exactly when show_picker changes, like maybe on click or on hover, but this is a limitation of the color picker that it hands the show_picker flag over to the lib users, it has no idea when show_picker will change and the lib users have no way to update the overlay state by themselves

   fn overlay<'b>(
        &'b mut self,
        state: &'b mut Tree,
        layout: Layout<'_>,
        renderer: &Renderer<B, Theme>,
    ) -> Option<overlay::Element<'b, Message, Renderer<B, Theme>>> {
        let picker_state: &mut State = state.state.downcast_mut();

        if !self.show_picker {
            // new lines begin
            let overlay_state = super::overlay::color_picker::State::new(self.color);
            picker_state.overlay_state = overlay_state;
            // new lines end

            return self
                .underlay
                .as_widget_mut()
                .overlay(&mut state.children[0], layout, renderer);
        }
        ...

from iced_aw.

genusistimelord avatar genusistimelord commented on July 18, 2024 1

yeah I do think there is a way to fix this but it probably requires an additional function to update internals to let the system know to redraw it. currently been pondering this.

from iced_aw.

jeffreyrosenbluth avatar jeffreyrosenbluth commented on July 18, 2024

The dirty fix works. Doesn't seem to impact performance too badly. Let me know if I can help with a more permanent fix.

from iced_aw.

Related Issues (20)

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.