Skip to content

A sane application development framework for the desktop.

Notifications You must be signed in to change notification settings

chris-montero/terra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IMPORTANT

This project is currently unmaintained.

Terra

What if you didn't have to write electron apps anymore?

Terra offers a platform-independent, featureful toolkit that allows you to easily and quickly build your application, and then flexibly go as low-level as you need to optimize your application.
This toolkit was built based on my experience with AwesomeWM, Elm, and Elm-ui, and other projects. I hope you find it useful.

Whether weather app image

Build gorgeous, high-performance applications

Terra aims to make developing cross platform applications an experience that is both fast and pleasant, without sacrificing on aesthetics or performance.

Mathgraph app image

Current state

Warning: Terra is experimental software and very early in development. We push to the main branch and live life day to day. :)
Also, I'm working on this whenever I have time and whenever I feel like it. I may be slow to solve issues. Terra currently only works with luajit on linux under Xorg. Support for Wayland, Windows and Mac is planned.
If you experience any issues with installing, bugs, etc., you can open an issue or contact me directly.

Example

This code creates an application, creates a window, creates a UI tree with Oak, terra's built-in UI library, paints a green background, creates a red ball, draws "hello world" on it, and animates the ball to spin in a circle.

#!/usr/bin/env luajit

local t_app = require("terra.app")
local t_window = require("terra.window." .. t_app.get_platform())

local tt_color = require("terra.tools.color")

local to_size = require("terra.oak.size")
local to_align = require("terra.oak.align")

local toeb_root = require("terra.oak.elements.branches.root")
local toeb_el = require("terra.oak.elements.branches.el")

local toel_bg = require("terra.oak.elements.leaves.bg")
local toel_text = require("terra.oak.elements.leaves.text")

local function init_app(app)

    local model = {}
    app.model = model

    -- create the window
    model.main_window = t_window.create(app, 320, 420, 200, 160, {

        tree = toeb_root.new({ -- the root of the UI tree
            toeb_el.new({ -- the background of the window
                width = to_size.FILL,
                height = to_size.FILL,
                bg = toel_bg.new({
                    source = tt_color.rgb(0.17, 0.42, 0.21), -- green
                }),
                toeb_el.new({ -- the red ball
                    halign = to_align.CENTER,
                    valign = to_align.CENTER,
                    width = 60,
                    height = 60,
                    bg = toel_bg.new({
                        source = tt_color.rgb(0.8, 0.1, 0), -- red
                        border_radius = 30,
                    }),
                    -- declaratively subscribe to signals on elements
                    subscribe_on_root = { 
                        ["AnimationEvent"] = function(self, time)
                            local spin_push = 20
                            self:set_offset_x(math.sin(time) * spin_push)
                            self:set_offset_y(-math.cos(time) * spin_push)
                        end
                    },
                    toel_text.new({ -- "hello world" text
                        family = "Roboto",
                        size = 11,
                        width = 40, -- constrain the width so the text wraps
                        halign = to_align.CENTER,
                        valign = to_align.CENTER,
                        text = "hello world",
                        fg = tt_color.rgb(1, 1, 1),
                    })
                }),
            }),
        }),
    })

    t_window.request_raise(model.main_window)
end

t_app.desktop(init_app, t_app.make_default_event_handler(function(app, event_type, ...)
end))

The above code produces the following output (without the titlebar):

green background red ball image

Installing

  1. Clone the repo
    git clone https://github.com/chris-montero/terra.git
  2. Build the project and install the luarock
    sudo luarocks make
  3. That's it. Now you should be able to successfully run the code in the Example section.

Credits

  • Uli Schlachter, for promptly and elaborately answering my questions about Xorg on stack overflow.
  • My mom, for sponsoring this project. Thanks mom.

Contributing

You are welcome to contribute by opening issues, comitting code, or through donations.
Any support is sincerely appreciated.

https://ko-fi.com/chrismontero

US DOLLAR IBAN: RO75BTRLUSDCRT0323524101
EURO IBAN: RO71BTRLEURCRT0323524101

About

A sane application development framework for the desktop.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages