slint icon indicating copy to clipboard operation
slint copied to clipboard

State inheritance / substates

Open ogoffart opened this issue 1 year ago • 1 comments

As discussed in https://github.com/slint-ui/slint/issues/2047, we would need a way to have states to share common properties.

Two ways are considered:

1. inherit states

component Foo {
    property <string> status;
    states [ 
        common : { 
            some_button.some_property: something; 
           /* ... more common properties */ 
          }
          open inherits common when self.status=="open":{
             some_button.text: "Open";        
          }
          close inherits common when self.status=="close":{
             some_button.text: "Close";        
          }
         // ...
     ]

2. sub-states

component Foo {
    property <string> status;
    states [ 
        common when self.status != "" : { 
              some_button.some_property: something; 
              /* ... more common properties */ 
              states [ // sub states
                  open when self.status=="open":{
                       some_button.text: "Open";        
                   }
                  close when self.status=="close":{
                      some_button.text: "Close";        
                  }
             ]
        }
         // ...
     ]

ogoffart avatar Jan 20 '23 08:01 ogoffart