Styles revisited

Some more changes..
Added by Christoph Kappel over 4 years ago

I did it again, Styles have changed slightly. This time without any breakage of existing configs, just expect some deprecation warnings and adopt your configs over the next weeks.

Why more changes?

The styles are a bit odd, there are some real classes and some other are mere states of a existing class. Yes, I am talking about the view styles. We have :focus, :occupied, :unoccupied and :urgent: Each inherits from :views and :views from :all and makes no sense as standalone style. So what we really need is a way to define nested styles.

Also the foreground, background, text_fg and icon_fg config option mess requires a sane solution with styles.

What has changed?

Styles can contain substyles and have a new property now, the icon property to set the color of icons in panel items using this specific style.

When there is a matching style with the name of the Sublets it uses the style and allows to style each sublet individually.

Subtle::Sublet, Subtlext::View and Subtlext::Sublet have a #style= method to set these styles.

Long story short

Overall the extended use of styles may look more complex but allows the usage of all properties.

What Before Since 2979
Nested styles
 1 style :focus do
 2   foreground "#fecf35" 
 3   background "#202020" 
 4 end
 6 style :urgent do
 7   foreground "#ff9800" 
 8   background "#202020" 
 9 end
 1 style :views do
 2   background "#202020" 
 4   style :focus do
 5     foreground "#fecf35" 
 6   end
 8   style :urgent do
 9     foreground "#ff9800" 
10   end
11 end
Styles for sublets
1 sublet :clock do
2   interval   30
3   foreground "#ff9800" 
4   icon_fg    "#777777" 
5 end
 1 style :sublets do
 2   style :clock do
 3     foreground "#ff9800" 
 4     icon       "#777777" 
 5   end
 6 end
 8 sublet :clock do
 9   interval   30
10 end
Update sublet colors
1 Subtlext::Sublet[0].foreground = "#ff0000"
 1 # Config
 2 style :sublets do
 3   style :test1 do
 4     foreground "#ff0000" 
 5   end
 7   style :test2 do
 8     foreground "#ff0000" 
 9   end
10 end
12 # Code
13 Subtlext::Sublet[0].style = :test1