Open ids1024 opened 1 year ago
You can make a static function for each color variant. May need a helper function for creating a custom variant in this way, as some other widgets currently have to make it easier to define.
As currently implemented the colors are specified as RGB values per-key per-keyboard (to match the look of keyboards like Launch). In json files.
Then yeah, there are some widgets already using a Box
Hm. Currently all of these types in cosmic::theme
are Clone + Copy
. A boxed trait can be neither. Most Iced widgets don't require their style types to be clonable, but the iced_style::text::StyleSheet::Style
requires Style: Default + Copy
.
Arc<dyn Fn()>
or Rc<dyn Fn()>
would be Clone
but not Copy
.
Having to use boxing here (every time view
is called), or reference counting, doesn't seem ideal. Though the overhead is probably not really significant...
If the Color itself is Copy, then you can just use a move closure to avoid capturing a reference to it.
Prototyping an Iced version of the keyboard view for the Configurator, it's necessary to set the background color for each key to a certain RGB value. But
cosmic::theme::Button::Custom
usesfn(_: &Theme) -> Appearance
, so it can't just be passed anAppearance
, or a closure that captures the color for the button.Not sure how to best do this:
Appearance
. Though it should probably be possible to make this dependent on light/dark theme.Fn
instead of plainfn
Fn
bound would fit here.This is perhaps a limitation of Iced's theming system, since as far as I'm aware it doesn't provide a way to completely override the theme for specialized elements other than with a custom widget.