Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist sketch parameters across app relaunch #94

Merged
merged 1 commit into from
Dec 31, 2023
Merged

Conversation

abey79
Copy link
Owner

@abey79 abey79 commented Dec 31, 2023

BREAKING: this change adds the requirement for all sketches to implement serde::{Serialize, Deserialize}. To minimise the related boilerplate, new #[sketch_app] and #[sketch_widget] attributes are introduced—see below.

This PR adds persistance of the sketch parameters across relaunches of the app. Resetting the parameters to their default is now done using the reset button (see #91).

Serialising the sketch requires it to implement the serde::{Serialize, Deserialize} traits. To minimise the related boilerplate (including adding serde as dependency), a new #[sketch_app] attribute proc macro is introduced.

The following code:

#[sketch_app]
struct MySketch {
    // ...
}

is now equivalent to:

#[derive(Sketch, serde::Serialize, serde::Deserialize)]
#[serde(crate = ::whiskers::prelude::serde)]
struct MySketch {
    // ...
}

The #[serde(...)] attribute is needed to point the derive macro at the whiskers-exported serde crate.

Likewise, a new #[sketch_widget] attribute macro is introduced to derive the Widget trait along with serde's.

This PR is also a pre-requisite for saved configurations.

@abey79 abey79 added whiskers Relates to whiskers or whiskers-derive breaking Breaking change labels Dec 31, 2023
@abey79 abey79 changed the title Persist sketch parameters across relaunch Persist sketch parameters across relaunches Dec 31, 2023
@abey79 abey79 changed the title Persist sketch parameters across relaunches Persist sketch parameters across app relaunch Dec 31, 2023
@abey79 abey79 merged commit 6cc5cac into master Dec 31, 2023
12 checks passed
@abey79 abey79 deleted the persist-param branch December 31, 2023 12:21
@abey79 abey79 mentioned this pull request Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change whiskers Relates to whiskers or whiskers-derive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant