Coder Social home page Coder Social logo

morphorm's Introduction

Morphorm

Morphorm is a crate for determining the position and size of UI elements which are organised in a visual tree. The algorithm is written from scratch but is based on the subform layout system.

How to use

To try and keep things as generic as possible Morphorm does not provide any containers for representing the layout properties or visual tree. Instead, three traits must be implemented by the users' containers in order to utilise the layout algorithm:

  • Node represents a UI element which can be sized and positioned. The node itself could contain the desired layout properties, or the properties can be provided by an external source (such as an ECS component store), which is provided by the Data associated type.
  • Hierarchy represents the visual tree of nodes. Morphorm requires three iterators to be provided: an upward iterator which iterates the tree from bottom to top in depth first order; a downward iterator which iterates the tree from the root in depth first order; and a child iterator which iterates through the children of a specified node.
  • Cache represents a store for the output of the layout computation as well as intermediate values used. The store is indexed by a reference to the node type and so the computed results cannot be stored within the node itself (due to the borrow checker).

Once the appropriate traits have been implmented, layout can be performed on the whole tree, e.g.

layout(&mut world.cache, &world.tree, &world.store);

In this example the cache, tree, and a store for the node properties are kept in an ECS world struct and a node is simply an entity id.

See examples for details.

Layout system description

TODO

An overview of stacks can be found here: overview (stacks)

morphorm's People

Contributors

geom3trik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.