Skip to content
Alexandre Bury edited this page Aug 2, 2019 · 1 revision

Use-cases

Apply a custom theme to a subtree only (for example a window/tab with a different color scheme)

This can be solved with a special wrapper view that gives a differently themed printer to the child.

Define custom views with different/more color/styles than the basic ones.

This can be solved by enabling custom entries in the palette. We probably want type indexing rather than literal. Eg:

# In cursive
trait CustomEntry {
    const NAME: &str;
}

# In some 3rd-party lib
struct MyCoolColor;
impl cursive::CustomEntry for MyCoolColor {
    const NAME: &str = "my_cool_color";
}

struct MyCoolView;

impl cursive::View for MyCoolView {
    fn draw(&self, printer: &cursive::Printer) {
        printer.with_color(cursive::theme::ColorStyle::custom(MyCoolColor), |printer| {
            printer.print((0, 0), "Cool!");
        });
    }
}