GithubHelp home page GithubHelp logo

mtk's Introduction

Introduction

MTK(Mural Toolkit) is a simple widget toolkit for creating graphical user interfaces written in Go with Pixel and Beep libraries.

The toolkit provides basic UI elements(buttons, text boxes, switches, lists, animations, etc.), simple audio handling and automatic scaling of UI elements.

Originally created as a part of Mural GUI.

MTK highly relies on Pixel library, make sure to check Pixel wiki first.

Dependencies

Basic dependencies are OpenGL development libraries, and some audio development libraries.

Linux

On Fedora-like distribution install: go libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-devel libXxf86vm-devel alsa-lib-devel.

On other distributions, you need to install the equivalence of these packages.

macOS

Install Go and Xcode or Command Line Tools for Xcode.

Windows

Install Go

Examples

All UI elements are automatically scaled to size specified in Pixel WindowConfig.

Create window:

// Create Pixel window configuration.
cfg := pixelgl.WindowConfig{
       Title:  "MTK window",
       Bounds: pixel.R(0, 0, 1600, 900),
}
// Create MTK warpper for Pixel window.
win, err := mtk.NewWindow(cfg)
if err != nil {
       panic(fmt.Errorf("Unable to create MTK window: %v", err))
}

Create button:

// Specify button parameters.
params := mtk.Params{
	Size:      mtk.SizeBig,
	FontSize:  mtk.SizeMedium,
	Shape:     mtk.ShapeRectangle,
	MainColor: colornames.Red,
}
// Create button.
button := mtk.NewButton(params)
// Set label and on-hover info.
button.SetLabel("Button")
button.SetInfo("Button info")
// Set some function on button click event.
button.SetOnClickFunc(onButtonClickedFunc)

Draw button in window:

for !win.Closed() {
	// Clear window.
	win.Clear(colornames.Black)
	// Draw button.
	buttonPos := win.Bounds().Center()
	button.Draw(win, mtk.Matrix().Moved(buttonPos))
	// Update.
	win.Update()
	button.Update(win)
}

Check example package for more detailed examples.

Documentation

Source code documentation can be easily browsed with go doc command.

Contributing

You are welcome to contribute to project development.

If you looking for things to do, then check TODO file or contact maintainer([email protected]).

When you find something to do, create new branch for your feature. After you finish, open pull request to merge your changes with master branch.

Contact

License

Copyright 2018-2024 Dariusz Sikora <[email protected]>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.