From 6e3245d5b011da102e367feee7e851fef8fe42b8 Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:46:35 +0200 Subject: [PATCH 1/5] Create 0000-new-theming.md --- text/0000-new-theming.md | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 text/0000-new-theming.md diff --git a/text/0000-new-theming.md b/text/0000-new-theming.md new file mode 100644 index 0000000..bad13a0 --- /dev/null +++ b/text/0000-new-theming.md @@ -0,0 +1,77 @@ +# Feature Name + +## Summary + +One paragraph explanation of the feature. + + +## Motivation + +Why are we doing this? What use cases does it support? What is the expected outcome? + + +## Guide-level explanation + +Explain the proposal as if it was already included in the library and you were teaching it to another iced programmer. That generally means: + +- Introducing new named concepts. +- Explaining the feature largely in terms of examples. +- Explaining how iced programmers should *think* about the feature, and how it should impact the way they use iced. It should explain the impact as concretely as possible. + +For implementation-oriented RFCs (e.g. for compiler internals), this section should focus on how compiler contributors should think about the change, and give examples of its concrete impact. For policy RFCs, this section should provide an example-driven introduction to the policy, and explain its impact in concrete terms. + + +## Implementation strategy + +This is the technical portion of the RFC. Explain the design in sufficient detail that: + +- Its interaction with other features is clear. +- It is reasonably clear how the feature would be implemented. +- Corner cases are dissected by example. + +The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work. + + +## Drawbacks + +Why should we *not* do this? + + +## Rationale and alternatives + +- Why is this design the best in the space of possible designs? +- What other designs have been considered and what is the rationale for not choosing them? +- What is the impact of not doing this? + + +## [Optional] Prior art + +Discuss prior art, both the good and the bad, in relation to this proposal. +A few examples of what this can include are: + +- Does this feature exist in other GUI toolkits and what experience have their community had? +- Are there any published papers or great posts that discuss this? If you have some relevant papers to refer to, this can serve as a more detailed theoretical background. + +This section is intended to encourage you as an author to think about the lessons from other toolkits, provide readers of your RFC with a fuller picture. +If there is no prior art, that is fine - your ideas are interesting to us whether they are brand new or if it is an adaptation from other languages. + +Note that while precedent set by other languages is some motivation, it does not on its own motivate an RFC. +Please also take into consideration that iced sometimes intentionally diverges from common toolkit features. + + +## Unresolved questions + +- What parts of the design do you expect to resolve through the RFC process before this gets merged? +- What parts of the design do you expect to resolve through the implementation of this feature before stabilization? +- What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC? + + +## [Optional] Future possibilities + +Think about what the natural extension and evolution of your proposal would be and how it would affect the toolkit and project as a whole in a holistic way. Try to use this section as a tool to more fully consider all possible interactions with the project and language in your proposal. Also consider how this all fits into the roadmap for the project. + +This is also a good place to "dump ideas", if they are out of scope for the RFC you are writing but otherwise related. + +If you have tried and cannot think of any future possibilities, you may simply state that you cannot think of anything. + +Note that having something written down in the future-possibilities section is not a reason to accept the current or a future RFC; such notes should be in the section on motivation or rationale in this or subsequent RFCs. The section merely provides additional information. From 9f2f40aa42ef884bae195dbe213f7b96742dad44 Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Mon, 24 Apr 2023 17:26:19 +0200 Subject: [PATCH 2/5] Update 0000-new-theming.md --- text/0000-new-theming.md | 114 ++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 42 deletions(-) diff --git a/text/0000-new-theming.md b/text/0000-new-theming.md index bad13a0..06349f3 100644 --- a/text/0000-new-theming.md +++ b/text/0000-new-theming.md @@ -1,63 +1,100 @@ -# Feature Name +# New theme system ## Summary -One paragraph explanation of the feature. +The idea is to get rid of Style Sheet and simplify the custom widget implementation. +- the library will take a color sheme (Light and Dark), that we define at launch. +- we can tell the library if it should use the light or dark theme +- we don't have to specifie the theme, it should have default themes ## Motivation -Why are we doing this? What use cases does it support? What is the expected outcome? +Because right now, if we want for example, 2 containers with 2 differents colors, we need to create our own ContainerType, and then implement `container::StyleSheet` for our custom theme. +This bring a lot of new concept for new users. ## Guide-level explanation -Explain the proposal as if it was already included in the library and you were teaching it to another iced programmer. That generally means: - -- Introducing new named concepts. -- Explaining the feature largely in terms of examples. -- Explaining how iced programmers should *think* about the feature, and how it should impact the way they use iced. It should explain the impact as concretely as possible. - -For implementation-oriented RFCs (e.g. for compiler internals), this section should focus on how compiler contributors should think about the change, and give examples of its concrete impact. For policy RFCs, this section should provide an example-driven introduction to the policy, and explain its impact in concrete terms. - +Iced will have a type Palette: +``` +/// A color palette type interne to the library +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct Palette { + /// The background [`Color`] of the [`Palette`]. + pub background: Color, + /// The text [`Color`] of the [`Palette`]. + pub text: Color, + /// The primary [`Color`] of the [`Palette`]. + pub primary: Color, + /// The success [`Color`] of the [`Palette`]. + pub success: Color, + /// The danger [`Color`] of the [`Palette`]. + pub danger: Color, +} +``` +When we start the program, we can give our own implementation of DarkPalette and LightPalette to Iced. +We also need a mechanism to tell iced when to use DarkPalette or LightPalette. + +There will be no custom theme. The apparence of the widgets will be created from the shemes colors. + +If, we wan't more than 2 themes, or if we need more customisation (for example, if we need 2 container with 2 differents colors): +- we could define our own colors sheme to fit our need: + +``` +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct CustomPalette { + pub primary: Color, + pub onPrimary: Color, + pub thertiary: Color, + pub onTertiary: Color, + pub secondary: Color, + pub onSecondary: Color, + pub background: Color, + pub text: Color, + pub primary: Color, + pub success: Color, + pub danger: Color, +} +``` +And then we could just overide properties like that: +``` +Container::new() + .background(self.theme.primary) + .border_color(self.theme.onPrimary) + .border_width(2f32) +``` + +Notice we could set border_width, that way, we don't need style sheet anymore. + +If we want to provide different style of Container: + +``` +Container::new() + +ContainerBoxed::new() // two separate function +``` ## Implementation strategy -This is the technical portion of the RFC. Explain the design in sufficient detail that: - -- Its interaction with other features is clear. -- It is reasonably clear how the feature would be implemented. -- Corner cases are dissected by example. - -The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work. - +I don't know how to do it yet. Maybe there is some reasons why we can't set some widget properties directly in our code. However, this seems to be the easiest way. ## Drawbacks -Why should we *not* do this? - +- it would break the api +- maybe other things that I'm not aware of (I'm new to Rust) ## Rationale and alternatives -- Why is this design the best in the space of possible designs? -- What other designs have been considered and what is the rationale for not choosing them? -- What is the impact of not doing this? - +If we continue with the current style symstem, we force ourself to make the implementation of a widget style sheet in one place. +With this approach, we could easily make a custom view function with whatever widget we wan't, and it will have no effect with other fonctionnaly that we have declared in other files. +Also, it will make small scale customization easier for new users. ## [Optional] Prior art -Discuss prior art, both the good and the bad, in relation to this proposal. -A few examples of what this can include are: - - Does this feature exist in other GUI toolkits and what experience have their community had? -- Are there any published papers or great posts that discuss this? If you have some relevant papers to refer to, this can serve as a more detailed theoretical background. - -This section is intended to encourage you as an author to think about the lessons from other toolkits, provide readers of your RFC with a fuller picture. -If there is no prior art, that is fine - your ideas are interesting to us whether they are brand new or if it is an adaptation from other languages. - -Note that while precedent set by other languages is some motivation, it does not on its own motivate an RFC. -Please also take into consideration that iced sometimes intentionally diverges from common toolkit features. +All my ideas come from Jetpack Compose. That's exactly how it manages customization and I find it easier, with less boiler plate. ## Unresolved questions @@ -65,13 +102,6 @@ Please also take into consideration that iced sometimes intentionally diverges f - What parts of the design do you expect to resolve through the implementation of this feature before stabilization? - What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC? - ## [Optional] Future possibilities -Think about what the natural extension and evolution of your proposal would be and how it would affect the toolkit and project as a whole in a holistic way. Try to use this section as a tool to more fully consider all possible interactions with the project and language in your proposal. Also consider how this all fits into the roadmap for the project. - -This is also a good place to "dump ideas", if they are out of scope for the RFC you are writing but otherwise related. - -If you have tried and cannot think of any future possibilities, you may simply state that you cannot think of anything. -Note that having something written down in the future-possibilities section is not a reason to accept the current or a future RFC; such notes should be in the section on motivation or rationale in this or subsequent RFCs. The section merely provides additional information. From 9948f7e295de9e37546f95e1366b094aa2a3c8bd Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Mon, 24 Apr 2023 17:46:08 +0200 Subject: [PATCH 3/5] Rename 0000-new-theming.md to 0022-new-theming.md --- text/{0000-new-theming.md => 0022-new-theming.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename text/{0000-new-theming.md => 0022-new-theming.md} (100%) diff --git a/text/0000-new-theming.md b/text/0022-new-theming.md similarity index 100% rename from text/0000-new-theming.md rename to text/0022-new-theming.md From d14f295b200fe52c91194b62657eeec70596884e Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:43:05 +0200 Subject: [PATCH 4/5] Update 0022-new-theming.md --- text/0022-new-theming.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/text/0022-new-theming.md b/text/0022-new-theming.md index 06349f3..5e487b1 100644 --- a/text/0022-new-theming.md +++ b/text/0022-new-theming.md @@ -67,17 +67,16 @@ Container::new() Notice we could set border_width, that way, we don't need style sheet anymore. -If we want to provide different style of Container: +If we want to provide different style of Container, we could simply give an enumetation to `new()` ``` -Container::new() - -ContainerBoxed::new() // two separate function +Container::new(iced::Container::Boxed) ``` ## Implementation strategy -I don't know how to do it yet. Maybe there is some reasons why we can't set some widget properties directly in our code. However, this seems to be the easiest way. +Just define more method for each widget. The default attributes will be set according to the theme of the application. +The style parameter will be removed and replaced by the self attributes of the structure in question. ## Drawbacks @@ -86,9 +85,10 @@ I don't know how to do it yet. Maybe there is some reasons why we can't set some ## Rationale and alternatives -If we continue with the current style symstem, we force ourself to make the implementation of a widget style sheet in one place. +If we continue with the current style system, we force ourself to make the implementation of a widget style sheet in one place. With this approach, we could easily make a custom view function with whatever widget we wan't, and it will have no effect with other fonctionnaly that we have declared in other files. Also, it will make small scale customization easier for new users. +This brings quick widget configuration, while leaving the possibility of creating your own widget if you really want a lot of customization. ## [Optional] Prior art @@ -99,6 +99,9 @@ All my ideas come from Jetpack Compose. That's exactly how it manages customizat ## Unresolved questions - What parts of the design do you expect to resolve through the RFC process before this gets merged? + +I have already done a test with Container and I am able to change the background color + - What parts of the design do you expect to resolve through the implementation of this feature before stabilization? - What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC? From 0c301bcf811973a56e96cd9c2862f000366e87e9 Mon Sep 17 00:00:00 2001 From: wiiznokes <78230769+wiiznokes@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:47:41 +0200 Subject: [PATCH 5/5] Update 0022-new-theming.md --- text/0022-new-theming.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0022-new-theming.md b/text/0022-new-theming.md index 5e487b1..77c639f 100644 --- a/text/0022-new-theming.md +++ b/text/0022-new-theming.md @@ -76,7 +76,7 @@ Container::new(iced::Container::Boxed) ## Implementation strategy Just define more method for each widget. The default attributes will be set according to the theme of the application. -The style parameter will be removed and replaced by the self attributes of the structure in question. +The style parameter of the draw function will be removed and replaced by the self attributes of the structure in question. ## Drawbacks