1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

[Programming Project] Renderer unspecific GUI Library

Discussion in 'Programming & Webmastering' started by razaron, Jul 1, 2013.

  1. razaron

    razaron

    Joined:
    Apr 26, 2008
    Messages:
    1,107 (0.45/day)
    Thanks Received:
    177
    Location:
    london
    Disclaimer: This thread is mostly for keeping me motivated since I'm a lazy something or other. So feel free to be annoying.


    I code in Java using OpenGL and hate Java Swing with all my heart. I usually make crappy ad hoc UIs for every thing I code (not that I code much), so I decided to make my own GUI library.
    Since I'm a noob it'd make a good learning experience, what with never having coded a library before. I'm making it renderer unspecific for the same reason.

    Although I'm coding it in Java, I'm going to try to not use any Java packages (the import thingies). This way it'll pretty much be OO psuedo-code in Java form, easily convertible into whichever OO language I decide to learn next. Also, it'd increase the cool factor, which is good for motivation.
    Renderer unspecific basically means that the library won't handle any of the drawing. You'll have to make your own renderer using whatever graphics library you prefer (in my case, that would be OpenGL).

    -A script generates a UI via the library.
    -UI takes in KB/M data from whatever program (now known as Jimmy) is using the library.
    -UI updates element positions (x,y coordinates), states and orders (what goes on top of what) based on KB/M input.
    -UI sends element positions, orders and states/events to Jimmy.
    -Jimmy renders a GUI using received UI element positions and orders.
    -Jimmy performs functions and updates its variables using received UI element states/events.
    -Have everything about the GUI (including what each element does when triggered) be determined via a script.
    -Layers (e.g. inventory screen) that are resizeable, repositionable and min/maximizable during runtime.
    -Buttons, text-boxes, drop-down lists, sliders and scrollbars.
    -Elements hold very abstracted state/event data (e.g. a double between 0 and 1 for sliders).
    -Buttons and layers have click detection.
    -Layers are reordered when clicked on.
    -Layers are repositioned when you click and drag them.
    -Horizontal and vertical scroll bars for layers.
    -Layers can be resized.
    I'm not very good at explaining things so I hope what I've said so far makes sense. If not, just ask.

    I̶'̶l̶l̶ ̶u̶p̶l̶o̶a̶d̶ ̶t̶h̶e̶ ̶s̶o̶u̶r̶c̶e̶ ̶a̶f̶t̶e̶r̶ ̶I̶'̶v̶e̶ ̶c̶o̶d̶e̶d̶ ̶a̶ ̶b̶i̶t̶ ̶m̶o̶r̶e̶ ̶a̶n̶d̶ ̶a̶d̶d̶e̶d̶ ̶c̶o̶m̶m̶e̶n̶t̶s̶.̶.̶.̶ Also, scripting support will be the last thing I do, so the source won't be for a library, it'll be for a program with all the classes intended for the library plus a Core class (main) to simulate/act as an abstraction of Jimmy and his renderer.

    Compiled runnable version,
    http://www.mediafire.com/download/0tl8k4819xkr3i0/GuiDemo.rar
    It works like a standard UI. Drag the scroll bar to scroll, click a button to click a button, drag the bottom right corner to resize and drag anywhere else to drag the layer.


    Source,
    http://pastebin.com/u/razaron
    It's under "GUI Library/". Requires LWJGL.


    This is all part of a larger goal, the first step of which is to be able to quickly and easily make UIs. By around October I hope to have learned basic AI, coded a fairly versatile cellular automaton library, coded an impulse based physics library and gotten my head around scripting (so I don't have to hard-code everything). I've already learned A*, know how I'm going to do the cellular automaton library and coded a verlet based physics engine beforehand. The only thing I know jack squat about is scripting.
     
    Last edited: Jul 14, 2013
  2. RCoon

    RCoon Gaming Moderator Staff Member

    Joined:
    Apr 19, 2012
    Messages:
    8,004 (8.13/day)
    Thanks Received:
    4,123
    Location:
    Gypsyland, UK
    1st - Please dont code in Java, please let it die along with flash
    2nd - use the time saved to order and wait for pizza
    3rd - enjoy

    Thank me later.
     
  3. Frick

    Frick Fishfaced Nincompoop

    Joined:
    Feb 27, 2006
    Messages:
    10,915 (3.38/day)
    Thanks Received:
    2,436
    Meh, Java isn't so bad.
     
    Aquinus says thanks.
  4. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,125 (6.23/day)
    Thanks Received:
    3,939
    Location:
    IA, USA
    Last edited: Jul 2, 2013
    RCoon and Mindweaver say thanks.
    Crunching for Team TPU
  5. Aquinus

    Aquinus Resident Wat-man

    Joined:
    Jan 28, 2012
    Messages:
    6,900 (6.47/day)
    Thanks Received:
    2,481
    Location:
    Concord, NH
    No, but languages that are built on top of it can be brilliant. The JVM is not slow and it runs on just about any platform. There are benefits to using Java for more reasons than how you program it.

    Clojure is a good example of brilliance, and it's on top of Java.

    So as a general question, what do you not like about Swing? Don't get me wrong, I don't like it either, but what about it in particular do you dislike? You might be able to change what you want without re-inventing the wheel.
     
  6. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,125 (6.23/day)
    Thanks Received:
    3,939
    Location:
    IA, USA
    The way it handles events (needlessly breaks them into separate functions) and especially the lack of a ShowDialog() method which passes the GUI thread to another form and sends it back on closure. I had to expose variables that shouldn't have been exposed and other really stupid tactics to get around it.

    Lets not forget it looks like shit, has no WYSIWYG editor, and is overall clunky.
     
    Crunching for Team TPU
  7. Castiel

    Castiel

    Joined:
    May 5, 2008
    Messages:
    3,319 (1.37/day)
    Thanks Received:
    310
    Hoping for Java to die is like Hell freezing over, it ain't gonna happen.
     
  8. hellrazor

    hellrazor

    Joined:
    Feb 18, 2010
    Messages:
    1,582 (0.89/day)
    Thanks Received:
    319
    But could you imagine how much happier programmers would be when nobody forces them to learn and/or use it?
     
  9. Aquinus

    Aquinus Resident Wat-man

    Joined:
    Jan 28, 2012
    Messages:
    6,900 (6.47/day)
    Thanks Received:
    2,481
    Location:
    Concord, NH
    It really depends on what you consider bad. Do you consider Java as a programming language bad or do you consider the JVM bad? Personally, I've been enjoying Clojure, which is a functional language and a dialect of Lisp and it was written on top of Java and the JVM. Now I can write Clojure code (which I think looks pretty elegant as a language,) and I still have the benefits that Java provides while writing a minimal of Java code.
     
  10. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,125 (6.23/day)
    Thanks Received:
    3,939
    Location:
    IA, USA
    I'd rather Microsoft open up .NET and people create languages/compilers for .NET instead of JVM.
     
    Crunching for Team TPU
  11. BiggieShady

    BiggieShady

    Joined:
    Feb 8, 2012
    Messages:
    1,051 (1.00/day)
    Thanks Received:
    366
    Location:
    Zagreb, Croatia
    Mono is open. Unity game engine has Mono embedded and uses #C (.NET 2.0 subset) as scripting language. It works really well.
     
  12. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,125 (6.23/day)
    Thanks Received:
    3,939
    Location:
    IA, USA
    Mono doesn't have WPF. C# is not a new language to the .NET framework. It is using the same compilers already included with .NET. I was talking about new languages compiled for .NET like Haskell, Java, or whatever. That way you could use .NET instead of JVM.
     
    Crunching for Team TPU
  13. razaron

    razaron

    Joined:
    Apr 26, 2008
    Messages:
    1,107 (0.45/day)
    Thanks Received:
    177
    Location:
    london
    Rewrote how shapes are handled and added scroll bar functionality.
    PS. All buttons are always visible for convenient bug finding.

    I prefer to make my own libraries. It's more entertaining that way. Since I don't program for any serious reasons, that's the only thing that matters.


    EDIT: Added a crappy tech demo to the OP.
     
    Last edited: Jul 10, 2013
  14. razaron

    razaron

    Joined:
    Apr 26, 2008
    Messages:
    1,107 (0.45/day)
    Thanks Received:
    177
    Location:
    london
    Added resize functionality and cleaned up the maths in the Layer class. The only thing left for the Layer class is minimizing/maximizing and closing.
     
  15. Zygmunt New Member

    Joined:
    Jul 19, 2013
    Messages:
    8 (0.02/day)
    Thanks Received:
    1
    Java Is a broad language.

    My dear Java is totally object oriented and broad language. You can do many things which you can't do in other language. You can use Net beans to code java project or GUI forum design, It would help you and make Java easy for you.
     
  16. RCoon

    RCoon Gaming Moderator Staff Member

    Joined:
    Apr 19, 2012
    Messages:
    8,004 (8.13/day)
    Thanks Received:
    4,123
    Location:
    Gypsyland, UK
    Only spammers use the phrase "my dear"

    I'm watching you.
     
    razaron, hellrazor and Zygmunt say thanks.
  17. Zygmunt New Member

    Joined:
    Jul 19, 2013
    Messages:
    8 (0.02/day)
    Thanks Received:
    1
    Don't Worry, I am not Spammer.
     
    RCoon says thanks.
  18. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    14,125 (6.23/day)
    Thanks Received:
    3,939
    Location:
    IA, USA
    Java is not "totally object oriented," only partially. All primitives are not objects in Java (e.g. int, char, float, etc.). C#.NET and VB.NET are "totally object oriented." Everything is derived from the base class System.Object.
     
    Crunching for Team TPU

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page