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

Introduce a project configuration file #267

Open
tronical opened this issue Jun 21, 2021 · 1 comment
Open

Introduce a project configuration file #267

tronical opened this issue Jun 21, 2021 · 1 comment
Labels
rfc Request for comments: proposals for changes

Comments

@tronical
Copy link
Member

tronical commented Jun 21, 2021

We identified that having a project file that's understood by the tooling around Slint would have several benefits to support larger scale projects by centralising settings in a well-defined location.

This issue proposes to introduce slint.project.json as a configuration file

File Format

The file format shall be JSON with the extension of supporting comments.

Location

The file shall be read by the Slint compiler, the preview tool as well as by the LSP implementation. When loading a .slint file in order to compile the entry component as instructed, the tools shall look in the directory of the .slint file and in the directory hierarchy upwards for a slint.project.json file. In the case of the slint::slint! macro in the Rust integration, the starting point for the lookup shall be the CARGO_MANIFEST_DIR.

Purpose

Initially the file shall allow configuring the following settings:

  • The default style to be used.
  • A list of include search paths for .slint files.
  • A list of file paths to custom fonts to load (replaces import "foo.ttf" syntax)
  • The version of Slint the .slint files are intended to be compatible with.
  • The license of Slint selected by the user.

This could also be extended in the future to allow defining an entry point, so that tools like the preview tool could be pointed to a slint.project.json file.

Priority

Some of these settings are also configurable through different means, such as the style with the SLINT_STYLE environment variable. The order of priority shall be from lowest to highest priority:

  1. Environment variables
  2. slint.project.json value
  3. API / Command line option

Schema

A schema shall be provided, which allows for the validation of the project settings file and code completion in IDEs

The proposed initial schema is:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://slint.dev/slint.project.schema.json",
  "title": "Slint Project Settings",
  "description": "Various configurable settings when using Slint with .slint files",
  "type": "object",
  "properties": {
    "style": {
        "description": "The style to use when loading and rendering the UI",
        "type": "string"
    },
    "includes": {
        "description": "A list of include search paths, relative to the slint.project.json file",
        "type": "array",
        "items": {
            "type": "string",
        }
    },
    "fonts":  {
        "description": "A list of file paths to font files, relative to the slint.project.json file",
        "type": "array",
        "items": {
            "type": "string",
        }
    },
    "version": {
        "description": "The Slint version number the project files are intended to be compatible with",
        "type": "string",
    }
  }
}
@tronical tronical added the rfc Request for comments: proposals for changes label Jun 21, 2021
@ogoffart
Copy link
Member

Other things that the project file could contains:

  • Some target information that could be overriden for specific targets
    • screen size
    • pixel format (relevant for MCU)
    • scale factor
    • which unicode coverage for each font / size to embedded as pixmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc Request for comments: proposals for changes
Projects
None yet
Development

No branches or pull requests

2 participants