Cura

A component toolkit for creating both graphical and text-based user interfaces.

Cura provides:

  • Component system
  • * Tree hierarchy
  • * Box model layouts
  • Event system
  • * Dispatching
  • * Middleware (aiming & translating)
  • * Handling
  • * Delegation
  • Adapter system

Install

Bundler: gem 'cura'

RubyGems: gem install cura

Adapters

Ruby

Used for its libraries.

Text-based User Interface (TUI)

Graphical User Interface (GUI)

MRuby

Used for its compilability and portability.

Text-based User Interface (TUI)

Graphical User Interface (GUI)

JRuby

Used for compilability, speed, and libraries.
Ruby FFI based adapters should also work in JRuby.

Text-based User Interface (TUI)

Graphical User Interface (GUI)

Usage

NOTE: The following is not functional yet. Move along...

require 'cura'

# Define our window

class MainWindow < Cura::Window

  def initialize
    super

    @label = Cura::Label.new(
      text: 'Hello, world!',
      bold: true,
      underline: true,
      alignment: { horizontal: :center },
      margin: 10,
      border: { size: 1, color: Cura::Color.red },
      padding: 3
    )

    add_child( @label ) # Will mixin any adapter methods for Label
  end

end

# Define our application and add our window

class Application < Cura::Application

  def initialize
    super

    @window = MainWindow.new

    add_window( @window )

    @window.show # Note that in TUIs, only one window can be shown at once.
  end

end

# Require any adapters

require 'cura-adapter-termbox'
require 'cura-adapter-termbox-ffi'
require 'cura-adapter-curses'
require 'cura-adapter-sdl'
require 'cura-adapter-sdl-ffi'
require 'cura-adapter-opengl'
require 'cura-adapter-opengl-ffi'
require 'cura-adapter-gosu'

# Choose adapter

adapter_names = Cura::Adapter.all.collect(&:name)
adapter = loop do
  puts "Choose one or type 'exit': #{ adapter_names.join(', ') }"
  print '> '

  answer = gets.downcase.strip

  exit if answer == 'exit'
  retry unless adapter_names.include?( answer.to_sym )
end

# Run application with adapter

Application.run( adapter: adapter )

Copyright © 2015 Ryan Scott Lewis [email protected].

The MIT License (MIT) - See LICENSE for further details.