melius

package module
v0.0.0-...-d89ebf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2021 License: MIT Imports: 5 Imported by: 0

README

Melius

DISCLAIMER:

Melius is NOT in a production state, nor is it close to being finished. If this project interests you, check in regularly for updated commits and documentation. While you're at it, give the repository a star too! Thank you!

Install

To install, simply enter this into your console: go get -u github.com/PutterBeanut/melius

Getting Started

Melius is almost immediate mode. It revolves around creating objects but the process is rather instant. Here is an example of a simple project made with Melius:

/*
// WARNING: THIS CODE DOES NOT YET WORK. THE PROJECT IS STILL IN DEVELOPMENT AND SHOULD NOT BE USED FOR PRODUCTION.
*/

import (
    "github.com/PutterBeanut/melius/"
    "github.com/PutterBeanut/melius/app"
    "github.com/PutterBeanut/melius/widget"
    "github.com/PutterBeanut/melius/window/"
    
    "fmt"
)

func main() {
    a := app.New("My App")
    w := app.CreateWindow()
    
    var click int = 0
    
    b := widget.Button{}
    b.OnClick = func() {
        click += 1
        b.Label = fmt.Sprint("You have clicked me ", click, " times!")
    }
    
    w.AddContent(&b);
    
    // This should be the very last line in the main() function
    a.ShowAndRun()
}

Documentation

Overview

Melius is an open source GUI Library oriented around OpenGL. While developing the library, I tried to keep an immediate mode pattern in mind. Although not necessarily immediate mode, Melius can easily get a window up and running with only a few lines of code!

Also while writing the library, I took many courses on UI programming for HTML/CSS to create the perfect base for the library. I attempted to design it so that it looked good right out of the box. Obviously, the library has the capability to be styled even more, but having a good base to work with isn't too bad!

If decided that this repository does not have a wanted feature, please read our roadmap. If nothing on the roadmap portrays to adding the requested features, go ahead and add them! The community would be grateful for that feature to be added (reference pull requests).

Contains all of the widget information and properties for drawing widgets. If needed, it is possible to create a custom widget (reference docs).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterWidget

func RegisterWidget(w Widget)

Allows for custom widgets to be created and registered.

Types

type App

type App struct {
	// Storage of all of the currently opened windows.
	Windows []Window
}

The App type contains all of the functions and variables needed to edit the application's settings.

NOTE: This struct should only be created once (using the New function).

type Style

type Style struct {
	// The overall color of the widget.
	Color style.Dye

	// The overrall color of the text on this widget.
	TextColor style.Dye

	// The border of the widget.
	Border style.Border

	// The shadow of the widget.
	Shadow style.Shadow

	// The font and font settings of the widget.
	Font style.Font
}

A struct dedicated purely on how a widget should look.

type Widget

type Widget interface {
	// An overriden function that can be used to draw a widget on a window.
	Draw(width string, height string, x string, y string) draw.DrawResult

	// Returns the style of the current widget.
	GetStyle() Style

	// Sets the style of the current widget.
	SetStyle(style Style)

	// Handles the input for that specific widget.
	HandleInput(mask input.InputMask) input.InputResult

	// Overrides the generated shader, allowing the user to have more control.
	// This is highly recommended due to the app not having to generate and cache shaders at runtime, giving a slight performance boost.
	OverrideShader(shader shader.Shader) draw.ShaderOverrideResult

	// Gets the overriden shader.
	// If the shader was not override, it will return empty.
	GetOverridenShader() shader.Shader

	// Checks to see if the widget has changed at all, may that be a hover, a click, etc.
	Changed() bool

	GetVertices() []float32
}

Pay attention to OverrideShader. It might come in handy!

type Window

type Window struct {
	// Holds all of the widgets that the window should use.
	Widgets []Widget
}

type WindowSettings

type WindowSettings struct {
	// The position of the window in pixels
	Position math.Vector2Int

	// The size of the window in pixels
	Size math.Vector2Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL