Overview
Fresnel is a visual component library based on CSS and custom drawn components. It is in an early stage of development.
git repo: https://gitlab.com/freepascal.org/lazarus/fresnel
Requirements: fpc 3.2.2, for skia: fpc 3.3.1
Platforms
Fresnel runs already natively on
- Linux/gtk3 with Skia and fpc 3.3.1.
- Windows with Skia and fpc 3.3.1.
- Webassembly in the browser using fpc 3.3.1.
Fresnel forms can also run inside an LCL application.
- A Fresnel form can be used inside an LCL app. This allows to migrate LCL forms one by one.
- Fresnel runs everywhere the LCL runs.
- Renderer:
- Skia
- Directly on the LCL canvas.
- Finally there is a LCL control, allowing to embed a Fresnel viewport as a control on a LCL form.
Documentation
What is working?
As Fresnel is still in an early pre-alpha stage, a few things do work already:
- fcl-css supports big part of CSS parsing, even some CSS-5 feats (the actual attributes are done by TFresnelElement)
- A Lazarus package src/fresnel.lpk containing the runtime units for standalone applications.
- A Lazarus package src/lcl/fresnellcl.lpk containing the runtime units for Fresnel inside a LCL applications.
- A Lazarus designtime package design/fresneldsgn.lpk registering a Fresnel Form, allowing to put TBody, TDiv, TSpan, etc onto the designer.
- Current platforms:
- Linux/Gtk3 with Skia - for a native application
- Windows with Skia - for a native application
- WebAssembly - for a website
- Inside a LCL application as window: TFresnelForm - for LCL applications
- Using LCL canvas for rendering (default)
- Using Skia as renderer: add an IDEMacro value FresnelLCLRenderer:=skia to Additions and Overrides
- Inside a LCL form as control: TFresnelLCLControl - to embed Fresnel inside an LCL form
- Lazarus Designer for TFresnelForm
- TFresnelElement
- a TComponent that works similar to an HTML element
- supports many common CSS attributes like border, padding, margin, etc
- has inline CSS in the Style property and CSS classes in the CSSClasses property
- Elements can have child elements, building a tree similar to the browser DOM.
- CSS attributes are evaluated to their computed values.
- You can define descendants adding their own CSS attributes. See for example TCustomLabel
- TFresnelViewport
- a TFresnelElement that is the root of the tree.
- Base class for TFresnelForm.
- Defines the Width and Height of the rendering area.
- Contains a CSS StyleSheet property, which is applied to all its child elements. Like the author css in a browser.
- Contains a Layouter, which computes all the element render boxes and has a pluggable system to support various node layouters - needed for flow, flex and grid layuout.
- TDiv - a TFresnelElement similar to HTML div element, i.e. block
- TSpan - a TFresnelElement similar to HTML span element, i.e. inline
- TReplacedElement - a TFresnelElement leaf node
- TCustomLabel - a TReplacedElement with a Caption property, the text specifies the min-width and min-height and is rendered.
- TLabel - a TCustomLabel with published properties
- TBody - a TDiv, works similar to HTML body element. Only needed if you use some internet css stylesheet.
- TImage - a TElement, similar to HTML img element
- TFresnelForm - a window with a viewport
- Unit Fresnel.LCLControls providing controls for using the Fresnel framework in a LCL application.
- Layouters: flow, flex, grid
Skia
- On aarch64 Mac:
Skia is a static lib. Add your fpc linker search path -FL:
/Users/USERNAME/pathtoyour/fresnel/bin/Binary/Static/OSXARM64
- On intel Mac:
For the static library add to the linker search path -FL:
/Users/USERNAME/pathtoyour/fresnel/bin/Binary/Static/OSX64
Goals
The main goals are at the moment:
- a CSS engine, capable of parsing common stylesheets and skipping unknown attributes and optionally log errors
- clipboard
- drag&drop on a form, between forms, from external, to external
- a text edit element
- native Cocoa backend
- CSS development tools
- set form and application title
Roadmap
- CSS engine:
- A application wide CSS stylesheets with origin user.
- Application and Form stylesheets as file.
- CSS attributes are skipped if invalid. One log entry per CSS error.
- CSS functions calc, min, max, minmax, clamp.
- CSS selector @media
- type styles should be collected only once
- changing an inline style, should not re-compute everything
- Extend Lazarus lfm repair wizard to support duplicate classnames
- Extend Lazarus Change Class to support duplicate classnames
- Layouter:
- Flow layouter:
- fragments for text elements
- direction: ltr
- position: sticky, absolute, fixed
- position:absolute, fixed, sticky
- direction:rtl
- Flow layouter:
- CSS Inspector
- expand/collapse shorthand
- underline source, click to open
- strikethrough invalid attributes
- mark overwritten attributes
- show CSS classes
- inherited attributes
- color button
- editing: add, delete attribute
- editing: change value
- Editing CSS stylesheet of form and application in Lazarus source editor
- Renderer-LCL:
- Testsuite
- colors: rgb, rgba, hsl, hsla
- borders: style
- invalidate changed containers, paint only parts
- Renderer-Skia:
- Skia
- Testsuite
- colors: rgb, rgba, hsl, hsla
- borders: style
- invalidate changed containers, paint only parts
- Mouse capture, drag and drop
- Events
- keyboard, focus, mouse wheel, minimize, maximize, restore, idle, clipboard
- Fresnel backend
- cocoa
- Animation
- Fresnel components:
- label fragmentation aka multi line
- link (CSS a), pseudo elements: :active, :link, :visited
- edit aka input type=text
- textarea
- Designer:
- grid
- CSS inspector
- change values
- add/delete attributes
- Other:
- background image
- stylesheets for windows, linux, macos
- lists
- special funding page on foundation site.
- HTML importer