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

Is ToUninstallSkinEvent usefull ? #217

Open
Nyan11 opened this issue Oct 25, 2024 · 6 comments
Open

Is ToUninstallSkinEvent usefull ? #217

Nyan11 opened this issue Oct 25, 2024 · 6 comments
Labels
question Further information is requested

Comments

@Nyan11
Copy link
Collaborator

Nyan11 commented Oct 25, 2024

What is ToUninstallSkinEvent?

ToUninstallSkinEvent is created when a theme is changed.
During this event, the element we want to untheme must have its properties reset to its previous state in order to avoid mixing theme together.

But the previous state should always be the values of the rawskin.
Therefor, why do the Theme need to be uninstalled if we will just reapply the rawskin values ? (We could simply install the rawskin).

Also currently, the theme needs to remember the previous state of the different properties.
The theme must have variable containing the previous theme.
The theme is not stateless.

I think the theme would be easier to create/maintain/understand whithout the ToUninstallSkinEvent.

@plantec
Copy link
Collaborator

plantec commented Oct 27, 2024

A theme must have ways to clean-up the place before it is replaced by another theme.
A theme style rule or a skin class installSkinEvent: can create objects (or child elements) that must be removed properly when the theme is changed. More over, objects created by a theme A are unknown by the new theme B and installing a new theme can become a mess.
Currently this the case of ToMenuSkin as an example.
Obviously, this is much more easier with RawSkin (with dedicated skin classes).
And this is one of its advantages because one could add instance variables for that.

I understand it can be more difficult with style sheet.
I guess your question is related to style-sheets ? right ?

  • "The theme must have variable containing the previous theme.", No, no, it's just the opposite and this is exactly why one have an uninstall.

I don't think it makes a theme more difficult to create/maintain.
I think it makes a theme easier to implement properly.

@plantec plantec added the question Further information is requested label Oct 27, 2024
@Nyan11
Copy link
Collaborator Author

Nyan11 commented Oct 28, 2024

"The theme must have variable containing the previous theme.",
No, no, it's just the opposite and this is exactly why one have an uninstall.

For example, i have a Button.

  • Step 1 (raw skin): My button is open in the space with the raw skin, it's background is White.
  • Step 2 (ToBeeThemeDark): I install a dark theme, the background of my button is Black.
  • Step 3 (ToBeeThemeLight): I uninstall the dark theme. Durring this step, the dark theme must know that the previous theme has a white background for the button and set the background to white.

In the example, we need to know the previous color of the background of the button when we change skin.
By default this color will always be the same as the RawSkin.

@Nyan11
Copy link
Collaborator Author

Nyan11 commented Oct 28, 2024

There is another problem with the no variable approach.
condere the following code:

myButton := ToButton new.

"Step 1: set the backgroun to yellow."
myButton background: Color yellow.

"Step 2: add a new theme. The background is white."
myButton space toTheme: ToBeeThemeGenerated.

"setp 3: uninstall the theme".
myButton space toTheme: nil.

In the previous code. At the end of Step3, what should be the color of myButton ?

  • if white, then the information yellow is missing.
  • if yellow, then the Theme ust have store the information yellow somewhere.

@Nyan11
Copy link
Collaborator Author

Nyan11 commented Oct 28, 2024

A theme style rule or a skin class installSkinEvent: can create objects (or child elements) that must be removed properly when the theme is changed.

There are elements for styling and others that are technical.
For example if you create an application for a touch screen you may want to add larger event zones for the button. Should a theme do it ?

@plantec
Copy link
Collaborator

plantec commented Oct 28, 2024

But it seems to me that there is no issue with all BlElement properties (as #background) because an install can set them to fit the look that the skin want to implement. Normally you can change these properties without having to take care of the previous one. So no need for an uninstall step in these cases.
Anyway, regarding a the default properties, one can retrieve the default state easily with BlDefaultVisuals

@plantec
Copy link
Collaborator

plantec commented Oct 28, 2024

A theme style rule or a skin class installSkinEvent: can create objects (or child elements) that must be removed properly when the theme is changed.

There are elements for styling and others that are technical. For example if you create an application for a touch screen you may want to add larger event zones for the button. Should a theme do it ?

A theme no. A skin yes. the same widget can have different configuration according to its skin. This can imply the adding of elements by the skin. ToMenuSkin do that as an example (even it is not a so good example). Another example is the ToAlbumSkin which adds a gray background layer on top in case of a DisabledSkinEvent.

Other examples could be the DatePicker and the ColorPicker. They can be dressed differently, with or without additional elements according to the skin. But this is still to be experimented :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants