Shirakumo / alloy

A new user interface protocol and toolkit implementation
https://shirakumo.github.io/alloy
zlib License
181 stars 12 forks source link

[Help] Using alloy with other backends #1

Closed Inc0n closed 4 years ago

Inc0n commented 4 years ago

I am aware this project is:

"currently still in its design phase"

I have seen some example code on some of the alloy demo videos, however, it still remain unfamiliar to me as to how to use alloy, such as using a different back-end, OpenGL, to avoid install trial, the game engine package.

Is there any example codes laying around somewhere in the project? Or where can we find some basic introductory document explaining how alloy can be used?

Shinmera commented 4 years ago

Hi, thanks a lot for the interest!

Alloy can be used independent of Trial with the alloy-glfw backend that implements the opengl and windowing protocols of Alloy.

There's unfortunately no example code or document that explains how to do things yet. The best way to get help would be to ask me directly on the #shirakumo IRC channel on Freenode.

Here's a basic example that I whipped up just now:

(defpackage #:workbench
  (:use #:cl)
  (:local-nicknames
    (#:alloy #:org.shirakumo.alloy)
    (#:glfw #:org.shirakumo.alloy.renderers.glfw)
    (#:windowing #:org.shirakumo.alloy.windowing)
    (#:colors #:org.shirakumo.alloy.colored.colors)))

(in-package #:workbench)

(glfw:with-screen (screen)
  (let* ((window (windowing:make-window screen))
         (focus (make-instance 'alloy:focus-list :focus-parent window))
         (layout (make-instance 'alloy:vertical-linear-layout :layout-parent window))
         (button (alloy:represent "Greet" 'alloy:button)))
    (alloy:enter button layout)
    (alloy:enter button focus)
    (alloy:on alloy:activate (button)
      (let ((window (windowing:make-window screen :background-color colors:white)))
        (alloy:enter (alloy:represent "Hey!" T) window)))))

In order to get it to run I had to patch a few things (f4dd7312459933693e965291272fad802232b8f3) so as you can see, things are far from stable. That's mostly because there's nobody else preventing things from rotting that I'm not using myself at this moment, though, so with some more eyes on the project things would stabilise a lot.