wilgaboury / jsignal

Declarative GUI Library for Java Desktop Applications
https://jsignal.org
MIT License
2 stars 1 forks source link

JSignal

WebsiteJavadocsDiscord

A declarative GUI library for Java desktop applications that takes strong inspiration from SolidJS.

Module Disambiguation

Module Description
rx reactive primitives
ui UI system built on JSignal, Skia (Skija), JWM, and Yoga
std standard component library
prop annotation processor for component properties

Key Features

Example

public class Counter extends Component {
  public static void main(String[] args) {
    UiThread.start(() -> {
      var window = UiUtil.createWindow();
      window.setTitle("Counter");
      window.setContentSize(250, 250);
      new UiWindow(window, Counter::new);
    });
  }

  private final Signal<Integer> count = Signal.create(0);

  @Override
  public Element render() {
    return Node.builder()
      .layoutBuilder(lb -> lb
        .fill()
        .center()
        .column()
        .gap(10f)
      )
      .children(Nodes.compose(
        Para.builder()
          .string(() -> "Count: " + count.get())
          .styleBuilder(sb -> sb.textStyleBuilder(tsb -> tsb
            .fontSize(20f)
            .color(EzColors.BLUE_500)
          ))
          .build(),
        Button.builder()
          .color(EzColors.BLUE_300)
          .action(() -> count.accept(c -> c + 1))
          .children(() -> Para.fromString("Increment"))
          .build()
      ))
      .build();
  }
}

Counter Example Screencapture