Giter Club home page Giter Club logo

gown.js's Introduction

gown.js

UI system for pixi.js inspired by feathers-ui.

Inline docs Code Climate Build Status

Features

  1. Basic UI components

    • Button: simple Button, with label and background, easy to extend using themes
    • CheckBox a simple checkbox
    • ToggleButton: a button with pressed state
    • Slider a simple slider with modifyable start and end value
  2. Layouting

    • LayoutGroup: a component to create horizontal, vertical or tile-based layouts
  3. Scrollable container

    • ScrollArea: a viewport that can be scrolled using mouse (including mouse wheel) or touch gestures. When its content is a LayoutGroup the scroll behaviour will be dependent on its layout: a horizontal layoutgroup will default to horizontal scrolling, vertical layout to vertical scrolling. But you are in control and can manually overwrite the scroll behaviour.
    • ScrollBar: providing a scroll thumb that can be moved. gets automatically oriented on the given ScrollArea
  4. A Text input providing text and password input (based on PIXI Input )

  5. Basic shapes that provide width and height that can be changed easily (for use in themes for example)

Examples

see the examples-folder in this repo or play with some example online at: http://brean.github.io/gown-examples/

Folder structure

  • examples - simple examples to show the usage (and to have something more graphical besides the jasmine-tests)

  • lib - required libraries (just pixi-dev)

  • src - source code for gown.js

  • test - unit tests, run coverage_karma_istanbul.sh to get a table providing all files and their coverage, run coverage_blanket to start a web server that shows you the coverage for all lines of the generated browserify output file.

  • themes - basic UI example themes

  • AeonTheme.js A theme based on Feather's AeonDesktopTheme making use of 9-tiled images

  • MetalWorksMobileTheme.js a theme based on Feather's MetalWorksMobileTheme

  • Themes/ShapeTheme.js a theme using only basic shapes.

Theming

  • Using the python script themes/xml_to_json.py you can convert your XML file from feathers-ui into JSON so the default PIXI loader can parse it.

  • example:

python xml_to_json.py assets/aeon/aeon_desktop.xml

the script requires PIL (or Pillow) to determine the texture width/height

  • It is possible to have different themes in one project
  • Themes can be switched at run time
  • For reference how to create your own theme check the themes folder. It contains two different approaches on creating themes
  • The test/src/TestTheme.js is a fake theme used only for the unit tests

Under the hood

Center of the theming system is the "skins"-object. It holds unique names of different controls as key (e.g. "button" as identifier for GOWN.Button) and nested objects as value. These nested objects allow you to save different graphics for different skins (e.g. "down" when the user pressed a button down). The graphic for the state can be an images but also any kind of shape (you can set everything that can be added to a PIXI-DisplayObjectContainer as skin). It is important that the variable width/height of your skin can be changed so your skin can be layouted correctly. Every control need its own instance for the skin, so you have to wrap it in a function that creates a new instance of the skin.

In short, the skins-object looks like this: theme.skins = {<control>: {<state>: function () { new <skin>() } }}

Rendering

When changing a component the corresponding setter updates an invalid flag. This will force a redraw on the next frame. (this can be the recalculation of the position and dimensions or a skin change on user interaction).

The loop looks like this:

  1. redraw (gown)
  2. updateTransform (PIXI)
  3. render (PIXI)

The redraw function is hooked into PIXI's render loop in the updateTranform methond but called before the actual calcluation of updateTransform.

Known Bugs

see Issues

gown.js's People

Contributors

brean avatar florianludwig avatar marfri avatar

Watchers

James Cloos avatar Stafford Williams avatar  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.