impress

package module
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 6 Imported by: 10

README

impress. Go GUI cross-platform library

PkgGoDev

See project site for a technical details and a library overview.

Some usage examples are in the examples folder.

Hello World Example

Let's say hello:

package main

import (
    "image"
    "image/color"

    "github.com/codeation/impress"
    "github.com/codeation/impress/event"

    _ "github.com/codeation/impress/duo"
)

func main() {
    app := impress.NewApplication(image.Rect(0, 0, 480, 240), "Hello World Application")
    defer app.Close()

    font := impress.NewFont(15, map[string]string{"family": "Verdana"})
    defer font.Close()

    w := app.NewWindow(image.Rect(0, 0, 480, 240), color.RGBA{255, 255, 255, 255})
    defer w.Drop()

    w.Text("Hello, world!", font, image.Pt(200, 100), color.RGBA{0, 0, 0, 255})
    w.Line(image.Pt(200, 120), image.Pt(300, 120), color.RGBA{255, 0, 0, 255})
    w.Show()
    app.Sync()

    for {
        e := <-app.Chan()
        if e == event.DestroyEvent || e == event.KeyExit {
            break
        }
    }
}

See an explanation of the source code in a library overview.

To run this example on Debian/ Ubuntu:
  1. Install gcc, make, pkg-config if you don't have them installed.

  2. Install GTK+ 3 libraries if you don't have them installed:

sudo apt-get install libgtk-3-dev
  1. Build impress terminal from source:
git clone https://github.com/codeation/it.git
cd it
make
cd ..
  1. Then run example:
git clone https://github.com/codeation/impress.git
cd impress
IMPRESS_TERMINAL_PATH=../it/it go run ./examples/simple/

Steps 0-2 are needed to build a impress terminal binary. See impress terminal page for other options for downloading or building impress terminal app.

Project State

Notes
  • The project is currently in its beta stage. It is highly suitable for the development of in-house applications.
  • The project was tested on Debian 12.4 and macOS 14.3.
  • While the API remains stable, please note that the specific details may be subject to change.

A cross-platform mind-map application is being developed to showcase the core principles of the library.

Key features

See project site for a basic principles and details.

Contributing

First, welcome:

  • Any like to the project (star, post, link, etc.).
  • Any recommendations about library design principles.
  • Contribution to project, documentation, examples.
  • Bug report, open issue.
  • Or any help to fix grammatical or writing errors (PR or issue).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(current driver.Driver)

Register is an internal function that makes the GUI driver available.

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

Application represents application top level window

func NewApplication

func NewApplication(rect image.Rectangle, title string) *Application

NewApplication creates main application window

func (*Application) Chan added in v0.1.10

func (app *Application) Chan() <-chan event.Eventer

Chan returns event channel

func (*Application) ClipboardGet added in v0.4.0

func (app *Application) ClipboardGet(typeID int)

ClipboardGet requests event with clipboard content

func (*Application) ClipboardPut added in v0.4.0

func (app *Application) ClipboardPut(c clipboard.Clipboarder)

ClipboardPut set content to OS clipboard

func (*Application) Close

func (app *Application) Close()

Close destroys application resources

func (*Application) NewFrame added in v0.2.4

func (app *Application) NewFrame(rect image.Rectangle) *Frame

NewFrame create new inner frame with a specified size

func (*Application) NewMenu added in v0.1.7

func (app *Application) NewMenu(label string) *Menu

NewMenu returns a new top-level menu node

func (*Application) NewWindow

func (app *Application) NewWindow(rect image.Rectangle, background color.Color) *Window

NewWindow creates new inner window with a specified size and background color

func (*Application) Size

func (app *Application) Size(rect image.Rectangle)

Size sets application window size

func (*Application) Sync added in v0.2.3

func (app *Application) Sync()

Sync flushes graphics content to screen driver

func (*Application) Title

func (app *Application) Title(title string)

Title sets application window title

type Font

type Font struct {
	driver.Fonter
	Height     int
	LineHeight int
	Baseline   int
	Ascent     int
	Descent    int
	Attributes map[string]string
}

Font represents a font selection

func NewFont

func NewFont(height int, attributes map[string]string) *Font

NewFont return a font selection struct. Note than "family" and other attributes are driver specific. Open duo/font.go for details.

func (*Font) Close

func (f *Font) Close()

Close destroys font selection

func (*Font) Size

func (f *Font) Size(text string) image.Point

Size returns the width and height of the drawing area

func (*Font) Split

func (f *Font) Split(text string, edge int, indent int) []string

Split breaks the text into lines that fit in the specified width; indent is a width to indent first line

type Frame added in v0.2.4

type Frame struct {
	// contains filtered or unexported fields
}

func (*Frame) Drop added in v0.2.4

func (f *Frame) Drop()

Drop deletes frame Note that a dropped frame can no longer be used

func (*Frame) NewFrame added in v0.2.4

func (f *Frame) NewFrame(rect image.Rectangle) *Frame

NewFrame create new child frame with a specified size

func (*Frame) NewWindow added in v0.2.4

func (f *Frame) NewWindow(rect image.Rectangle, background color.Color) *Window

NewWindow creates new frame window with a specified size and background color

func (*Frame) Raise added in v0.2.4

func (f *Frame) Raise()

Raise brings the frame to the forefront

func (*Frame) Size added in v0.2.4

func (f *Frame) Size(rect image.Rectangle)

Size changes frame size and position

type Image

type Image struct {
	driver.Imager
	Size image.Point
}

Image represents a draw-ready image

func NewImage

func NewImage(img image.Image) *Image

NewImage returns a image resources struct

func (*Image) Close

func (i *Image) Close()

Close destroys image resources

type Menu struct {
	// contains filtered or unexported fields
}

Menu represents any menu node

func (m *Menu) NewItem(label string, event event.Menu)

NewItem adds a item to menu node

func (m *Menu) NewMenu(label string) *Menu

NewMenu returns new submenu node

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window represents inner window

func (*Window) Clear

func (w *Window) Clear()

Clear clears current window

func (*Window) Drop

func (w *Window) Drop()

Drop deletes window Note that a dropped window can no longer be used

func (*Window) Fill

func (w *Window) Fill(rect image.Rectangle, foreground color.Color)

Fill draws a rectangle with specified size and foreground color

func (*Window) Image

func (w *Window) Image(rect image.Rectangle, img *Image)

ImageScale draws a image into specified rectangle

func (*Window) Line

func (w *Window) Line(from image.Point, to image.Point, foreground color.Color)

Line draws a color line connecting two specified points

func (*Window) Raise added in v0.1.7

func (w *Window) Raise()

Raise brings the window to the forefront

func (*Window) Show

func (w *Window) Show()

Show sends the contents of the window to the screen Note that a drawings are not visible until Show

func (*Window) Size

func (w *Window) Size(rect image.Rectangle)

Size changes window size and position

func (*Window) Text

func (w *Window) Text(text string, font *Font, from image.Point, foreground color.Color)

Text draws a text at specified location using a specified font and foreground color

Directories

Path Synopsis
Package to connect to WebAssembly driver
Package to connect to WebAssembly driver
Package to connect to GTK driver
Package to connect to GTK driver
examples
geo
joint
domain
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
drawrecv
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
drawsend
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
eventchan
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
eventrecv
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
eventsend
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
iface
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
lazy
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
rpc
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.
serversocket
Package implements an internal mechanism to communicate with an impress terminal.
Package implements an internal mechanism to communicate with an impress terminal.

Jump to

Keyboard shortcuts

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