Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Abstract User Interface - Implementation with LWJGL  (Read 975 times)
0 Members and 1 Guest are viewing this topic.
Offline lacombej

Junior Devvie


Medals: 12
Projects: 1



« Posted 2018-07-17 15:39:08 »

I've been working on a UI implementation that uses LWJGL. I initially made it so that I can create a level editor or possibly embed UI widgets inside a LWJGL window but then I figured that it can also be a solution for general use-cases for desktop applications in Java.

So with that in mind, I decided to create an Abstract User Interface (AUI). Here are some bullet points to show where I'm coming from:
  • I had problems embedding AWT/Swing with LWJGL in the past (I think there is a solution now)
  • I did not like using event listeners when I used to use Swing. After using Qt I fell in love with signals/slots.
  • AUI should be able to be used to interface with any GUI. A switch in the UI used would require little changes.

So the definition of the API can be found here:
https://github.com/LacombeJ/Aerial/tree/master/aerial/aui/src/ax/aui

My implementation using LWJGL can be found here:
https://github.com/LacombeJ/Aerial/tree/master/aerial/tea/src/ax/tea

Tea User Interface

Some of the features of Tea:
  • CSS-like styling
  • Easy to create custom widgets - from scratch or by combining multiple widgets
  • File choosers and message dialogs from Swing
  • Can be used with in LWJGL applications




Example with output:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
package ax.examples.tea;

import ax.aui.*;
import ax.commons.io.Console;
import ax.tea.TUIManager;

public class TeaSimpleMain {

    public static void main(String[]args) {
        new TeaSimpleMain().run();
    }

    void run() {

        TUIManager ui = TUIManager.instance();
        ui.setDarkStyle();

        Window window = ui.window();
        window.setResizable(true);
        window.setWidth(400);
        window.setHeight(400);

        ArrayLayout layout = ui.arrayLayout();
        Panel panel = ui.panel(layout);

        Button button0 = ui.button("Click me");
        Button button1 = ui.button("Button 1");
        Button button2 = ui.button("Button 2");
        Slider slider = ui.slider(Align.HORIZONTAL);
        LineEdit lineEdit = ui.lineEdit("Initial line edit text");
        RadioButton radioButton0 = ui.radioButton("Radio Button 0");
        RadioButton radioButton1 = ui.radioButton("Radio Button 1");
        Dial dial = ui.dial();

        button0.clicked().connect(() -> {
            Console.log("Hello World!");
            Console.log("Slider value:", slider.value());
            Console.log("Line Edit text:", lineEdit.text());
            Console.log("Radio Button #0 checked:", radioButton0.checked());
            Console.log("Radio Button #1 checked:", radioButton1.checked());
            Console.log("Dial value:", dial.value());
        });

        slider.changed().connect((value)->{
            Console.log("Slider value was changed:", value);
        });

        int row = 0;
        layout.add(ui.label("Button:"), row, 0);
        layout.add(button0, row++, 1);
        layout.add(ui.label("Button:"), row, 0);
        layout.add(button1, row++, 1);
        layout.add(ui.label("Button:"), row, 0);
        layout.add(button2, row++, 1);
        layout.add(ui.label("Slider:"), row, 0);
        layout.add(slider, row++, 1);
        layout.add(ui.label("LineEdit:"), row, 0);
        layout.add(lineEdit, row++, 1);
        layout.add(ui.label("RadioButton:"), row, 0);
        layout.add(radioButton0, row++, 1);
        layout.add(ui.label("RadioButton:"), row, 0);
        layout.add(radioButton1, row++, 1);
        layout.add(ui.label("Dial:"), row, 0);
        layout.add(dial, row++, 1);

        window.setWidget(panel);
        window.create();
        window.setVisible(true);

    }

}




I decided to make this post after seeing other similar projects:
LWJUI - http://www.java-gaming.org/topics/lwjgui-application-gui-solution-for-lwjgl3/38726/view.html
LEGUI - http://www.java-gaming.org/topics/legui-gui-library-for-lwjgl/38565/view.html

I don't have any intention of continuing my own implementation of the API because I'd rather contribute to an existing UI library but I like the AUI api. There's a lot of things that need to be fixed with the internal Layout and Event handler so I'd figure I'd just scrap the project and try to implement AUI with other existing UI libraries. Also those two projects seem to be using NanoVG and I think LEGUI uses Yoga. Both libraries seem very robust and I didn't know they existed while working on this project.  Shocked


Offline orange451

JGO Kernel


Medals: 438
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #1 - Posted 2018-07-18 03:04:13 »

I don't think you should scrap your project. Everyone likes their own flavor when designing an application.

I've designed mine to be more like JavaFX, you've designed yours to be more like QT. I'm sure there's someone that will choose your project due to their API preferences!

It's great that there's more and more resources for creating UI with LWJGL! Smiley

First Recon. A java made online first person shooter!
Offline zngga
« Reply #2 - Posted 2018-07-18 16:58:52 »

There isn't nearly enough UI solutions for LWJGL or OpenGL in general, I think every addition is useful, you should continue working on it if you enjoy it.

My code never has bugs... it just develops unexpected features!
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1639 views)
2018-06-10 19:43:48

EgonOlsen (1700 views)
2018-06-10 19:43:44

EgonOlsen (1154 views)
2018-06-10 19:43:20

DesertCoockie (1582 views)
2018-05-13 18:23:11

nelsongames (1182 views)
2018-04-24 18:15:36

nelsongames (1705 views)
2018-04-24 18:14:32

ivj94 (2513 views)
2018-03-24 14:47:39

ivj94 (1730 views)
2018-03-24 14:46:31

ivj94 (2811 views)
2018-03-24 14:43:53

Solater (951 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!