Colours, the app and enums
Make colours, points and other values, reach the running
application and its locale, and name the keys of alignment,
keyboard and pointer enums in a file of Ljós's API.
After reading this page, you will be able to make and shade colours, build points, sizes and other values, read and change the running application through
App, format dates for a locale, and name the keys of alignment, keyboard and pointer enums. Everything here comes from Ljos.Core, apart from fonts and enums, which come from Ljos.Ui.rgba, hsla and hsva make a colour from its components, each between 0 and 1. A colour's name ("red", "#336699") goes wherever a color is expected. Color.of(c) takes a colour or a colour's name and gives a colour with methods: darker(f), lighter(f), tint(t), alpha(a) and equals(other). A property already typed color has those methods itself.point(x, y), size(w, h), rect(x, y, w, h), vector2d, vector3d, vector4d, quaternion and matrix4x4 make the value of their name. Font.of({ … }) makes a font from its fields, and Font.families() lists the families the system has.App is the running application:App.name, App.version, App.organization, App.domain and App.displayName describe it, and App.arguments lists what it was started with.App.platform.os names the system it runs on.App.language is the language its text is translated into. It is writable, and the text that depends on it follows when it changes.App.hints holds the system's hints for input and motion, such as App.hints.mousePressAndHoldInterval, and App.inputMethod the on-screen keyboard, such as App.inputMethod.visible.App.openUrlExternally(u) opens a link in the system's browser, and App.quit() ends the application. App.exit(code) ends it too; a code other than 0 does not reach the process yet, and the log says so.Three functions go with it.
later(f, …) calls f with the rest of its arguments once the current event has been handled. url(u) resolves u against the file it is written in. bind(f), assigned to a property, makes the property follow f again after an assignment has broken its binding.Locale.current is the locale the application runs in, and Locale.named("de_DE") is the locale of that name. A locale formats a date or a time with formatDate, formatTime and formatDateTime, given a format such as "yyyy-MM-dd".An alignment, a key, a pointer button, a modifier, a cursor and the other keys a program passes around each belong to a type named for what they are, so a key says what it is:
Align.Left, Key.Return, MouseButton.Left, Modifier.Control, Orientation.Horizontal, Elide.Right, Cursor.PointingHand, CheckState.Checked, Direction.RightToLeft. A key that would start with a digit is spelled out: Key.Digit0.Align, Modifier and MouseButton are sets of flags, combined with |. The other enums are plain: a value is one of their keys.Bringing existing QML, for where each member of a file written for Qt goes








