GithubHelp home page GithubHelp logo

lou15b / fidgetty Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elcritch/fidgetty

0.0 0.0 0.0 865 KB

Widget library built on Fidget written in pure Nim and OpenGL rendered

License: MIT License

Nim 99.06% GLSL 0.94%

fidgetty's Introduction

Fidgetty

Widget library built using a fork of Fidget written in pure Nim and OpenGL rendered.

Demo application in example/demo.nim:

Demo

nimble install -d
nim c -r examples/demo.nim

Example widget and application:

import std/strformat, std/hashes
import fidgetty
loadFont("IBM Plex Sans", "IBMPlexSans-Regular.ttf")

fidgetty CounterButton:
  properties:
    label: string
  state:
    count: int

proc new*(_: typedesc[CounterButtonProps]): CounterButtonProps =
  new result
  fill palette.foreground

proc render*(
    props: CounterButtonProps,
    self: CounterButtonState
): Events[All]=
  clipContent true
  cornerRadius theme.cornerRadius
  onHover:
    highlight palette
  onClick:
    self.count.inc()
  text "counter button":
    boxSizeOf parent
    fill palette.text
    characters  fmt"label ({self.count})"
    textAutoResize tsHeight

type
  AppState* = ref object
    count1: int

proc exampleApp*() =
  ## defines a stateful app widget
  frame "main":
    font "IBM Plex Sans", 16, 200, 0, hCenter, vCenter
    let self = withState(AppState)

    CounterButton:
      centeredXY 8'em, 2'em
      onClick:
        echo "hi!"

startFidget(
  exampleApp,
  setup = 
    when defined(demoBulmaTheme): setup(bulmaTheme)
    else: setup(grayTheme),
  w=640, h=400,
  uiScale=2.0
)

fidgetty's People

Contributors

elcritch avatar retsyo avatar beef331 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.