Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opacity inoperative for item drawn outside of an clipped item #7234

Open
fluolite opened this issue Dec 30, 2024 · 2 comments
Open

opacity inoperative for item drawn outside of an clipped item #7234

fluolite opened this issue Dec 30, 2024 · 2 comments
Labels
a:builtin elements The runtime data structures related to the items (mO,bT) bug Something isn't working

Comments

@fluolite
Copy link

Bug Description

HorizontalLayout opacity inoperative when swipe to next view with SwipeGestureHandler.
wrap a Rectangle contains HorizontalLayout can solve the problem.

Reproducible Code (if applicable)

export component AppWindow inherits Window {
    width: 480px;
    height: 480px;

    sgrx := SwipeGestureHandler {
        HorizontalLayout {
            x: -root.width * home_tab_index;
            opacity: 0.2;   // inoperative when changed to next tab
            Rectangle {
                width: parent.width;
                height: parent.height;
                background: #ff0000;
                Text {
                    font-size: 40px;
                    color: #000000;
                    text: "R";
                }
            }

            Rectangle {
                width: parent.width;
                height: parent.height;
                background: #00ff00;
                Text {
                    font-size: 40px;
                    color: #000000;
                    text: "G";
                }
            }

            Rectangle {
                width: parent.width;
                height: parent.height;
                background: #0000ff;
                Text {
                    font-size: 40px;
                    color: #000000;
                    text: "B";
                }
            }
        }

        Timer {
            interval: 1000ms;
            running: true;
            triggered => {
                home_tab_index += 1;
                if home_tab_index >= 3 {
                    home_tab_index = 0;
                }
            }
        }

        property <int> home_tab_index;
    }
}

Environment Details

  • Slint Version: 1.91
  • Platform/OS: linux
  • Programming Language: Rust + slint
  • Backend/Renderer: Linuxkms renderer-software

Product Impact

No response

@fluolite fluolite added bug Something isn't working need triaging Issue that the owner of the area still need to triage labels Dec 30, 2024
@fluolite
Copy link
Author

video.5.mp4

@ogoffart
Copy link
Member

Thanks for the bug report.

One thing is that the G and B rectangle in the example are "outside" of the layout.
The correct way to do what you want is this:

export component AppWindow inherits Window {
    width: 480px;
    height: 480px;

    sgrx := SwipeGestureHandler {
        HorizontalLayout {
            x: -root.width * home_tab_index;
            width: self.preferred-width;
            opacity: 0.2;   // inoperative when changed to next tab
            Rectangle {
                width: root.width;
                height: parent.height;
                background: #ff0000;
                Text {
                    font-size: 40px;
                    color: #000000;
                    text: "R";
                }
            }

            Rectangle {
                width: root.width;
                height: parent.height;
                background: #00ff00;
                Text {
                    font-size: 40px;
                    color: #000000;
                    text: "G";
                }
            }

            Rectangle {
                width: root.width;
                height: parent.height;
                background: #0000ff;
                Text {
                    font-size: 40px;
                    color: #000000;
                    text: "B";
                }
            }
        }

        Timer {
            interval: 1000ms;
            running: true;
            triggered => {
                home_tab_index += 1;
                if home_tab_index >= 3 {
                    home_tab_index = 0;
                }
            }
        }

        property <int> home_tab_index;
    }
}

But it is indeed strange that the opacity is not applied for item outside of the layout. Probably because the layout is entirely clipped and we don't call the set_opacity in that case.

@ogoffart ogoffart added a:builtin elements The runtime data structures related to the items (mO,bT) and removed need triaging Issue that the owner of the area still need to triage labels Dec 30, 2024
@ogoffart ogoffart changed the title HorizontalLayout opacity inoperative when swipe to next view with SwipeGestureHandler opacity inoperative for item drawn outside of an clipped item Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:builtin elements The runtime data structures related to the items (mO,bT) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants