mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-03 19:44:22 +00:00
Add theming expositon to README and separate THEMES documents
This commit is contained in:
1 parent
5531a0ec9e
commit
d7c8f71744
2 files changed
+49
No files matched your search
@@ -99,6 +99,10 @@ The syntax might look different, but it is designed for clarity and power.
|
||||
|
||||
Pure JavaScript and Objective-J can be mixed and matched, even in the same file. The Objective-J code is transpiled into highly-optimized JavaScript for deployment, but can also be run directly in the browser during development.
|
||||
|
||||
## Themes
|
||||
|
||||
Aristo is Cappuccino's default theme family and is built with it, so every application has a theme. An application uses Aristo3 unless it supplies another theme bundle and names it in its Info.plist. A theme stands alone: values it does not give fall back to each class's built-in value, never to Aristo's. See [THEMES.md](THEMES.md) for the rules and the reasons.
|
||||
|
||||
## Find Out More
|
||||
|
||||
* **Official Website:** [cappuccino.dev](http://cappuccino.dev)
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
Themes
|
||||
======
|
||||
|
||||
A theme gives Cappuccino's controls and windows their look: colours, images, fonts, metrics and the classes that draw window decoration. This document states how an application gets its theme, what a theme must contain, and why.
|
||||
|
||||
## The default theme
|
||||
|
||||
Aristo is Cappuccino's default theme family. It is part of the Cappuccino source and is built with it, so a theme is always available. An application uses the current version of Aristo, Aristo3, unless it supplies another theme and names it.
|
||||
|
||||
## Using another theme
|
||||
|
||||
A theme is a bundle, like a framework. To use a theme other than Aristo, an application places the theme bundle, `<Name>.blend`, in its Resources folder and names it under the key `CPDefaultTheme` in its Info.plist. The Info.plist is a required part of every application, so the theme is declared with the application's other settings.
|
||||
|
||||
The legacy toolchain does not check this declaration. When the named bundle is missing, loading it fails when the application launches. The new toolchain, `capp-build`, is designed to check the declaration: a theme that is named but missing will stop the build, as a missing framework does.
|
||||
|
||||
## A theme stands alone
|
||||
|
||||
A theme is a discrete bundle that is valid on its own. It does not depend on another theme, and no theme fills in values that another theme leaves out.
|
||||
|
||||
When a theme does not give a value for a class, that class uses its built-in value. It does not use Aristo's value.
|
||||
|
||||
The reasons:
|
||||
|
||||
- **Omissions stay visible.** A value that a theme forgot shows as the class's built-in value, where the theme's author can see it and fix it. If Aristo's value filled the gap, the omission would look like a deliberate choice and could go unnoticed.
|
||||
- **A theme's look does not change with Cappuccino releases.** If a theme took some values from Aristo, its look would change whenever Aristo changed, for example from Aristo2 to Aristo3, although its author changed nothing.
|
||||
- **Families do not mix.** Aristo's bezels and colours inside a theme designed around other shapes and colours would clash.
|
||||
- **Metrics stay coherent.** Each theme family has its own metrics, and Cappuccino adjusts frames when the theme changes. Metrics borrowed from Aristo would break that.
|
||||
|
||||
The built-in value of a class is part of the class's code and changes only with that code.
|
||||
|
||||
## Starting a new theme
|
||||
|
||||
`capp gen -t ThemeDescriptor` creates an empty theme project. A tool to duplicate an existing theme bundle as the starting point for a new one is planned. A copy starts complete, belongs entirely to its author, and does not change when the original changes.
|
||||
|
||||
## Variants
|
||||
|
||||
A theme bundle can contain variants for host platforms, for example the order and position of the window buttons on Windows. A variant changes look only, never metrics. It either supplies its own values for the classes it concerns, replacing the theme's values for those classes, or names classes that draw differently, such as a window view subclass. How variants are declared inside a bundle is not yet specified.
|
||||
|
||||
Light, dark, high-contrast and HUD looks are not variants. They are appearances. Each named colour and image of a theme holds its values per appearance and resolves them when it is drawn.
|
||||
|
||||
## The theme of a view
|
||||
|
||||
A view's theme is inherited, as its appearance is: the theme set explicitly on the view, else its superview's theme, else its window's, else the application's. Colours and images resolve against the theme of the view that draws them.
|
||||
|
||||
This is the design; the code does not yet follow it fully. Today a view takes the application's theme when it is made or decoded and keeps it, and some colours and images resolve against the application's theme instead of the view's.
|
||||
Reference in new issue
Block a user