slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.7k stars 614 forks source link

Using `StyleMetrics` shows warning without alternative being available #6698

Closed Enyium closed 3 weeks ago

Enyium commented 4 weeks ago

Consider this SlintPad demo (see comments):

import { StyleMetrics, Palette } from "std-widgets.slint";

export component Demo {
    width: 200px;

    VerticalLayout {
        // Generates a deprecation warning without an alternative
        // being available.
        /*
        */
        padding: StyleMetrics.layout-padding;
        spacing: StyleMetrics.layout-spacing;

        // Not available.
        /*
        padding: Palette.layout-padding;
        spacing: Palette.layout-spacing;
        */

        Rectangle {
            height: 20px;
            background: skyblue;
        }

        Rectangle {
            height: 20px;
            background: lightpink;
        }
    }
}

I know, of course, that you don't need StyleMetrics for VerticalLayout, but can use VerticalBox instead. In my app, I need StyleMetrics.layout-padding and StyleMetrics.layout-spacing for other purposes, and have no way to get rid of the deprecation warnings without copying the literal values, which wouldn't adhere to the single-source-of-truth principle.

FloVanGH commented 3 weeks ago

Hi, and thanks again for your request :-).

There is a common issue for the public styling resources #3687.

I will start with the layout settings yet. It's true because of StylingMetrics is deprecated now we should at least provide everything public that is available by StyleMetrics.