Giter VIP home page Giter VIP logo

pixi-layers's Introduction

pixi-layers - The UI Library for Pixilang

The aim of this project is to provide an easy to use and extend simple library with usual UI components that might need you in small projects on Pixilang.

pixi-layers manages mouse and touchscreen events so you can run it on every device.

Features

  • ✔️ touchscreen support
  • ✅ buttons activating by release
    • ✔️ with text
    • ✅ with icon
    • ✅ with icon and label
    • ✅ colored
    • ❕ radio
  • ✅ number inputs
  • ✅ popup windows
  • ✅ joysticks
  • ✅ scrolling viewer

Documentation is here

Usage example:

Running this example you should see 2 buttons and number in the centor on screen. You can increase or decrease the number by one by clicking on buttons.

include "bin/core.pixi"
include "bin/layers.pixi"
include "bin/release_buttons.pixi"

counter = 0

UI = create_abstract_layer(2) // create ui array with 2 elements
// create left button
UI[0] = create_button_activated_by_release_with_text(
    -80, 40, // button center position on screen
    80, 80, // button size
    {
        counter - 1
    }, // on click sub from counter 1
    "-" // button label
)

// create right button
UI[1] = create_button_activated_by_release_with_text(
    80, 40,
    80, 80,
    {
        counter + 1
    }, // on click add to counter 1
    "+" // button label
)

fn gl_callback($u){
    // enter to gl draw mode
    set_screen(GL_SCREEN)
    // clear screen with black
    clear()
    // draw buttons
    UI.draw(UI)

    // create temporary string
    $ts = ""
    // write counter value
    sprintf($ts, "%d", counter)

    t_push_matrix()
    t_translate(0, -40, 0)
    t_scale(2,2,1)
    print($ts) // draw scaled text
    t_pop_matrix()
    // exit from gl mode
    set_screen(0)
}

// set draw callback
set_gl_callback(gl_callback, 0)

while(1) { // main loop
    while(get_event()) { // event loop
        // fast quit on QUIT event
        if EVT[EVT_TYPE] == EVT_QUIT {
            halt
        }
        check_mouse_and_touches_events(UI)
    }
    // draw on screen
    frame()
}

pixi-layers's People

Contributors

maxhha avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

secret0-ochka

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.