Code Monkey home page Code Monkey logo

giu's Introduction

giu

Join the chat at https://gitter.im/AllenDang-giu/community Go Report Card Build Status Godoc Card

A rapid cross-platform GUI framework for Go based on Dear ImGui and the great Go binding imgui-go.

Any contribution (features, widgets, tutorials, documents, etc...) is appreciated!

Sponsor

(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If you are using giu, please consider reaching out.)

Businesses: support continued development and maintenance via invoiced technical support, maintenance, sponsoring contracts:

E-mail: [email protected]

Individuals: support continued development and maintenance here.

Documentation

For documentation refer to our wiki, examples, GoDoc, or just take a look at comments in code.

Supported Platforms

giu is built upon GLFW v3.3, so ideally giu could support all platforms that GLFW v3.3 supports.

  • Windows (Windows 10 x64 and Windows 11 x64)
  • macOS (macOS v10.15 and macOS Big Sur)
  • Linux (thanks remeh for testing it)
  • Raspberry Pi 3B (thanks sndvaps for testing it)

Features

Compared to other Dear ImGui golang bindings, giu has the following features:

  • Small executable file size (<3MB after UPX compression for the example/helloworld demo).
  • Live-updating during the resizing of the OS window (implemented on GLFW 3.3 and OpenGL 3.2).
  • Support for displaying various languages without any font setting. Giu will rebuild font atlas incrementally according to texts in UI between frames.
  • Redraws only when user event occurs. Costs only 0.5% CPU usage with 60FPS.
  • Declarative UI (see examples for more details).
  • DPI awareness (auto scaling font and UI to adapt to high DPI monitors).
  • Drop in usage; no need to implement render and platform.
  • OS clipboard support.

Screenshot Screenshot1 Screenshot2

Hello world

package main

import (
 "fmt"

 g "github.com/AllenDang/giu"
)

func onClickMe() {
 fmt.Println("Hello world!")
}

func onImSoCute() {
 fmt.Println("Im sooooooo cute!!")
}

func loop() {
 g.SingleWindow().Layout(
  g.Label("Hello world from giu"),
  g.Row(
   g.Button("Click Me").OnClick(onClickMe),
   g.Button("I'm so cute").OnClick(onImSoCute),
  ),
 )
}

func main() {
 wnd := g.NewMasterWindow("Hello world", 400, 200, g.MasterWindowFlagsNotResizable)
 wnd.Run(loop)
}

Here is the result:

Helloworld

Quick introduction

What is immediate mode GUI?

Immediate mode GUI system means the UI control doesn't retain its state and value. For example, calling giu.InputText(&str) will display a input text box on screen, and the user entered value will be stored in &str. Input text box doesn't know anything about it.

And the loop method in the Hello world example is in charge of drawing all widgets based on the parameters passed into them. This method will be invoked 30 times per second to reflect interactive states (like clicked, hovered, value-changed, etc.). It will be the place you define the UI structure.

The layout and sizing system

By default, any widget placed inside a container's Layout will be placed vertically.

To create a row of widgets (i.e. place widgets one by one horizontally), use the Row() method. For example giu.Row(Label(...), Button(...)) will create a Label next to a Button.

To create a column of widgets (i.e. place widgets one by one vertically) inside a row, use the Column() method.

Any widget that has a Size() method, can set its size explicitly. Note that you can pass a negative value to Size(), which will fill the remaining width/height value. For example, InputText(...).Size(giu.Auto) will create an input text box with the longest width that its container has left.

Containers

MasterWindow

A MasterWindow means the platform native window implemented by the OS. All subwindows and widgets will be placed inside it.

Window

A Window is a container with a title bar, and can be collapsed. SingleWindow is a special kind of window that will occupy all the available space of MasterWindow.

Child

A Child is like a panel in other GUI frameworks - it can have a background color and border.

Widgets

Check examples/widgets for all kinds of widgets.

Install

The backend of giu depends on OpenGL 3.3, make sure your environment supports it (as far as I know, some Virtual Machines like VirtualBox doesn't support it).

MacOS

xcode-select --install
go get github.com/AllenDang/giu

Windows

  1. Install mingw download here. Thanks @alchem1ster!
  2. Add the binaries folder of mingw to the path (usually is \mingw64\bin).
  3. go get github.com/AllenDang/giu

Or, install TDM-GCC.

Linux

First you need to install the required dependencies:

sudo apt install libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libglx-dev libgl1-mesa-dev libxxf86vm-dev

on Red Hat based distributions:

sudo dnf install libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel libGL-devel libXxf86vm-devel

you may also need to install C/C++ compiler (like g++) if it isn't already installed. Follow go compiler prompts.

Then, a simple go build will work.

Cross-compiling is a bit more complicated. Let's say that you want to build for arm64. This is what you would need to do:

sudo dpkg --add-architecture arm64
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
    libx11-dev:arm64 libxcursor-dev:arm64 libxrandr-dev:arm64 libxinerama-dev:arm64 libxi-dev:arm64 libglx-dev:arm64 libgl1-mesa-dev:arm64 libxxf86vm-dev:arm64
GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ HOST=aarch64-linux-gnu go build -v

Deploying

Build MacOS version on MacOS

go build -ldflags "-s -w" .

Build Windows version on Windows

go build -ldflags "-s -w -H=windowsgui -extldflags=-static" .

Build Windows version on MacOS/Linux

  1. Install mingw-64.

on Mac:

brew install mingw-w64

on Linux:

sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-winpthreads-static
  1. Prepare and embed the application icon into the executable and build.
cat > YourExeName.rc << EOL
id ICON "./res/app_win.ico"
GLFW_ICON ICON "./res/app_win.ico"
EOL

x86_64-w64-mingw32-windres YourExeName.rc -O coff -o YourExeName.syso
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ HOST=x86_64-w64-mingw32 go build -ldflags "-s -w -H=windowsgui -extldflags=-static" -p 4 -v -o YourExeName.exe

rm YourExeName.syso
rm YourExeName.rc

Documentation

Check Wiki

Contribution

All kinds of pull requests (document, demo, screenshots, code, etc.) are more than welcome!

Star History

Star History Chart

giu's People

Contributors

alchem1ster avatar allendang avatar asmaloney avatar bezrazli4n0 avatar charlesdaniels avatar daiwhea avatar dependabot[bot] avatar dimooski avatar essial avatar gitter-badger avatar goweasel avatar gucio321 avatar hackeralert avatar ianling avatar kettek avatar misustinivan avatar mrcyjanek avatar necoro avatar nitrix avatar raph6 avatar ryn1x avatar saucesaft avatar sgosiaco avatar spair avatar stigok avatar supergod avatar threpio avatar tpaljor avatar voytas avatar yarcat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

giu's Issues

Can't always get correct size of content region

Sometimes when I call imgui.ContentRegionAvail() I get the current size of the content region, but other times I do not.

For example, in the following snippet I display an image and a histogram in a split layout. The histogram correctly fills it's content area, but the image does not. If I instead use -1 as the image width and height it does fill the area, but as far as I can tell that just eventually calls imgui.ContentRegionAvail(). The reason I cannot use -1 for width and height is because I need to pass the width to my own function getScaledHeight() that will return a height, based on the current width, that maintains the image's original aspect ratio.

example:

func loop() {
	g.SingleWindow("main", g.Layout{
		g.SplitLayout("image/hist split", g.DirectionVertical, true, 800,
			g.Layout{
				g.Label(imageName),
				g.Image(imgT, imgui.ContentRegionAvail().X, getScaledHeight(imgui.ContentRegionAvail().X)),
			},
			g.Layout{
				g.Custom(func() {
					if len(image32) > 0 {
						imgui.PlotHistogramV("", image32, 0, "", math.MaxFloat32, math.MaxFloat32, imgui.Vec2{X: imgui.ContentRegionAvail().X, Y: imgui.ContentRegionAvail().Y})
					}
				}),
			}),
	})
}

Label auto-wrap

It'll be very good if labels will auto-wrap based on parent widget/layout/window sizes.

Widget rendering by condition.

Hi, how i can render widgets by conditions with new layout system?, for ex. if true => render button. With previous layout system it's will possible.

Unsafe pointer arithmetic

I've compiled application with -race and it crashed right before showing up GUI.

fatal error: checkptr: unsafe pointer arithmetic

goroutine 1 [running, locked to thread]:
runtime.throw(0xce6324, 0x23)
        /usr/lib/go/src/runtime/panic.go:1112 +0x72 fp=0xc00011fa18 sp=0xc00011f9e8 pc=0x483d12
runtime.checkptrArithmetic(0x1, 0x0, 0x0, 0x0)
        /usr/lib/go/src/runtime/checkptr.go:24 +0xce fp=0xc00011fa48 sp=0xc00011fa18 pc=0x456fde
github.com/AllenDang/giu/imgui.TextureID.handle(...)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui/TextureID.go:24
github.com/AllenDang/giu/imgui.FontAtlas.SetTextureID.func1(0x27280e0, 0x1)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui/FontAtlas.go:174 +0x78 fp=0xc00011fa88 sp=0xc00011fa48 pc=0xa3c3c8
github.com/AllenDang/giu/imgui.FontAtlas.SetTextureID(0x27280e0, 0x1)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui/FontAtlas.go:174 +0x43 fp=0xc00011faa8 sp=0xc00011fa88 pc=0xa35683
github.com/AllenDang/giu/imgui.(*OpenGL3).createFontsTexture(0xc000074230)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui/RendererOpenGL3.go:338 +0x3e5 fp=0xc00011fb50 sp=0xc00011faa8 pc=0xa289f5
github.com/AllenDang/giu/imgui.(*OpenGL3).createDeviceObjects(0xc000074230)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui/RendererOpenGL3.go:292 +0xd26 fp=0xc00011fcc8 sp=0xc00011fb50 pc=0xa28256
github.com/AllenDang/giu/imgui.NewOpenGL3(0x2724368, 0x3fe00000, 0xb, 0x258, 0x1f4)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/imgui/RendererOpenGL3.go:46 +0x1f5 fp=0xc00011fd50 sp=0xc00011fcc8 pc=0xa25485
github.com/AllenDang/giu.NewMasterWindowWithBgColor(0xcd52c1, 0xb, 0x258, 0x1f4, 0x1, 0xc00011fec0, 0x0, 0x7fd2ff3d8108)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:54 +0x263 fp=0xc00011fe30 sp=0xc00011fd50 pc=0xa53723
github.com/AllenDang/giu.NewMasterWindow(...)
        /home/pztrn/projects/go/pkg/mod/github.com/!allen!dang/[email protected]/MasterWindow.go:25

Use existing *glfw.Window?

Im trying to integrate giu with github.com/faiface/pixel. Since pixel is using glfw aswell is there a way to draw a giu SingleWindow into a existing *glfw.Window?

I also want to ask how I could manually quit the giu mainloop since I'm using the frameless window flag.

Cannot get Texture to load win10 x64

somehow it get's stuck on texture, err = g.NewTextureFromRgba(rgba) and the window get's unresponsive

package main

import (
	g "github.com/AllenDang/giu"
	"github.com/sirupsen/logrus"
)

func onClickMe() {
        // unnamed.png is in same folder as main.go 
        // random img 147kB with transparent background
	rgba, err := g.LoadImage("unnamed.png")
	if err == nil {
		// gets stuck on this call
		texture, err = g.NewTextureFromRgba(rgba)
		if err != nil {
			logrus.Error(err)
		}
	} else {
		logrus.Error(err)
	}
}

var texture *g.Texture

func loop() {
	g.SingleWindow("hello world", g.Layout{
		g.Label("Hello world from giu"),
		g.Custom(func() {
			if texture == nil {
				g.Line(
					g.Button("Load image", onClickMe),
				).Build()
			}
		}),
		g.Custom(func() {
			if texture != nil {
				g.Image(texture, -1, -1).Build()
			}
		}),
	})
}

func main() {
	wnd := g.NewMasterWindow("Hello world", 600, 350, false, nil)
	wnd.Main(loop)
}

Can't set background color

        w := g.NewMasterWindow("Overview", 800, 600, 0, nil)
	w.SetBgColor(color.RGBA{
		R: 13,
		G: 13,
		B: 149,
		A: 1,
	})
	w.Main(loop)
func NewMasterWindow(title string, width, height int, flags MasterWindowFlags, loadFontFunc func()) *MasterWindow {
...
mw := &MasterWindow{
		clearColor: [4]float32{0.05, 0.05, 0.58, 1},
		width:      width,
		height:     height,
		title:      title,
		io:         &io,
		context:    context,
		platform:   p,
		renderer:   r,
	}
...
}

I tried to modify these two places but nothing happened.T_T

Closing the main form.

How would one go about closing the Master window when an item is clicked in the menu?

g.MenuBar( g.Layout{ g.Menu("File", g.Layout{ g.MenuItem("Close", closeWindow), }), }, ),

I love what you have so far this project and I'm currently using it to help build a gui for an Asset Management program I am building. It really is awesome.

Fonts - problem with latin extended

Hello, I have problem with polish characters like ąśćłóĄ etc. My code below:

fonts := g.Context.IO().Fonts() fontPath := "OpenSans-Regular.ttf" fonts.AddFontFromFileTTFV(fontPath, 16, imgui.DefaultFontConfig, fonts.GlyphRangesDefault())

Polish characters are replaced with ?. How to solve this problem ?

Documentation

Sorry to put this in "issues". Didn't know where else to put this.

I clicked on the Wiki, but it was the same as the main page.

Is there documentation for this? I'd really like to check it out.

Thanks!!

The `CursorPos` does not update

package main

import (
	"fmt"

	g "github.com/AllenDang/giu"
	"github.com/AllenDang/giu/imgui"
)

func loop() {
	g.SingleWindow("hello world", g.Layout{
		g.Label(fmt.Sprintf("%v", g.GetCursorPos())),
		g.Label(fmt.Sprintf("%v", g.GetCursorScreenPos())),
		g.Label(fmt.Sprintf("%v", imgui.CursorPos())),
		g.Label(fmt.Sprintf("%v", imgui.CursorScreenPos())),
	})
}

func main() {
	wnd := g.NewMasterWindow("Hello world", 400, 200, false, nil)
	wnd.Main(loop)
}

https://github.com/inkyblackness/imgui-go/blob/b0afda23d6d95414a79bfe1472b470a281d1c483/imgui.go#L675

Consider adding some communication channel (chat, mailing list, etc.)

This is not a very high priority of course, but it will be good if such communication channel with you (or other who might join to development) exist. For example gitter room, channel at Gophers slack, IRC channel, Telegram group, or even plain old mailing list.

Reason - to keep issues tracker clean of chats.

Add missing documentation

Although there's plenty of info in the wiki, most of the types and functions don't show up any documentation when using godoc or pkg.go.dev. As someone unfamiliar with Dear Imgui it's not obvious at all what a builder is or what NewGlyphRanges() even does and why it's necessary to load fonts. So it'd be nice to have more information for all of them :)

No way to close Window from Button

I love the library and the ability to create quick GUI's on the fly with this.

However, I've run into an issue where I want to essentially stop the event loop because I don't need to maintain a window anymore, but want to run a process in the background. I don't see any way to close the window via a function that I can do via button press?

It looks like all I'd need to do there is stop the Main loop from running, but I can't seem to find a way to do that.

Is this possible or will something have to be built in?

DPI awareness not working

Using commit bccdc44

DPI awareness (autoscaling based on system settings, in my case - 175% in Windows 10) works only with default font. But when I tried to use another font (Go Regular) - I have to do scaling manually and choose larger font size, e.g.:

func (m *mainWindow) initialize() {
	m.window = giu.NewMasterWindow("My Mega App", 1000, 750, true, m.loadFont)
	m.window.Main(m.loop)
}

func (m *mainWindow) loadFont() {
	fonts := giu.Context.IO().Fonts()

	fonts.AddFontFromMemoryTTF(goregular.TTF, 24)

	imgui.CurrentStyle().ScaleAllSizes(1.75)
}

Which isn't "DPI awareness" at all. Am I miss something important here, or it is a bug?

Add Bindings for implot

See relevant discussion here.

I am opening this issue to track progress and discuss binding implot into GUI.

I had started looking at this and then got distracted. Hopefully I will get at least something basic going before I get distracted again :).

So far, I have really, really basic sin() plot working (relevant commit). I will continue working in the same fork of GIU until this is far enough to open a PR.

If @AllenDang would prefer, we can close this, and open a "WiP" pull request, to remain un-merged until ready.


Pics or it didn't happen:

screenshot_2020-05-26_at_15_56_48

ImageButton shows no image

Result:

A tiny button with nothing in it, click event works but the image isn't inserted into the button.

Code:

package main

import (
	"bytes"
	"fmt"
	"image"
	"image/draw"
	_ "image/jpeg"
	_ "image/png"
	"time"

	g "github.com/AllenDang/giu"
	resty "github.com/go-resty/resty/v2"
)

var (
	texture *g.Texture
	url     string = "https://projectrevolver.org/wp-content/uploads/2018/01/rick-astley.jpg"
	client  *resty.Client
	loading bool
)

func loadImage(imageUrl string) {
	loading = true
	g.Update()

	resp, err := client.R().Get(imageUrl)
	if err != nil {
		panic(err)
	}

	img, _, err := image.Decode(bytes.NewReader(resp.Body()))
	if err != nil {
		panic(err)
	}
	rgba := image.NewRGBA(img.Bounds())
	draw.Draw(rgba, img.Bounds(), img, image.Point{}, draw.Src)
	texture, _ = g.NewTextureFromRgba(rgba)

	loading = false
	g.Update()
}

func btnLoadClicked() {
	if len(url) > 0 {
		go loadImage(url)
	}
}

func onImageButtonClick() {
	fmt.Println("CLICKED")
}

func loop() {
	g.SingleWindow("load image", g.Layout{
		g.Label("Paste image url and click download"),
		g.InputText("##Url", -1, &url),
		g.Button("Download and display", btnLoadClicked),
		g.Custom(func() {
			if loading {
				g.Label("Downloadig image ...").Build()
			} else if texture != nil {
				g.ImageButton(texture, -1, -1, onImageButtonClick).Build()
			}
		}),
	})
}

func main() {
	client = resty.New()
	client.SetTimeout(10 * time.Second)

	wnd := g.NewMasterWindow("Load Image", 600, 400, false, nil)
	wnd.Main(loop)
}

WebAssembly support

Is there any planned support coming up for WebAssembly to build GUIs in the browser?

No references in widget click functions

Hi. I am really interested about this project! I want to rewrite my old app using this layout but I have problem with events functions. For example: i render buttons based on array of strings. I need to pass this string to click function. There is any option to pass any data to this function or to get reference for clicked button ?

itms := []string{"foo", "bar", "zzz", "www"}
var rows []*g.RowWidget
for i,name := range  itms {
    rows = append(rows,  g.Row(g.Label(fmt.Sprintf("a%d",i)), g.Label(fmt.Sprintf("b%d",i)), g.Button(name, func(){
			fmt.Println(name) // It's always www now. I need correct ID here
    })))
}

I know that this code is wrong but it explains my problem

Support built-in styles

Hi,

Original Dear Imgui supports three built-in styles:

  • Classic
  • Dark
  • Light

that are selectable using the three functions:

  • StyleColorsClassic()
  • StyleColorsDark()
  • StyleColorsLight()

Unfortunately my not so young eyes are having increasing problems using dark themes with small fonts. It would be great if support for at least those three styles could be added to the library. Thanks.

Can't link successfully but have required input

/usr/lib/x86_64-linux-gnu/libGL.so
/usr/lib/x86_64-linux-gnu/libGL.so.1
/usr/lib/x86_64-linux-gnu/libGL.so.1.7.0

uname -a
Linux edgar-ThinkPad-X1-Extreme-2nd 5.3.0-26-generic #28-Ubuntu SMP Wed Dec 18 05:37:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

go build -ldflags '-L /usr/lib/x86_64-linux-gnu -w -extldflags "-static"' gui/main.go

command-line-arguments

/home/edgar/.gimme/versions/go1.13.6.linux.amd64/pkg/tool/linux_amd64/link: running g++ failed: exit status 1
/usr/bin/ld: cannot find -lGL
/usr/bin/ld: /tmp/go-link-679058208/000039.o: in function `_glfwInitVulkan':
c_glfw.cgo2.c:(.text+0x6e5e): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status

where the main.go example is your README's example

Linux support

You've noted in the README that you may need some help for the Linux testing, I can probably do that for you.

As far as I've tested it, giu works well on Linux, everything I've tested in the widgets example worked well. The dynamicloadfont did not work though, even by providing a correct path to a valid ttf font but the error doesn't look alarming:

panic: Assertion failed!
File: imgui.cpp, Line 3508

Expression: g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?"

Thanks for the lib, it is awesome and I'll probably use it for a personal project. Please let me know what I could do if you need further testing 👍

Enabling INI Support

Is there any particular reason that the MasterWindow disables imgui's INI system? Perhaps MasterWindow should take an additional parameter or expose a func that uses IO's SetIniFilename.

I am currently enabling INI support by calling imgui.CurrentIO().SetIniFilename("..."), though it'd be more in the spirit of giu not to reach into imgui's IO, imo.

[Request] Multiple (child) Windows Demo

All of the examples use SingleWindow() and it would be nice to have an example of the proper way to handle multiple windows with Window(). My first guess at how to do it would be something like the code below, but I am unsure what the standard convention is.

package main

import (
	g "github.com/AllenDang/giu"
)

var showWindow2 = false
var showWindow3 = false

func mainWindow() {
	g.Window("Main Window", 0, 0, 0, 0, g.Layout{
		g.Button("Open Window 2", func() { showWindow2 = true }),
		g.Button("Open Window 3", func() { showWindow3 = true }),
	})
}

func window2() {
	g.Window("Window 2", 10, 10, 100, 100, g.Layout{
		g.Button("Close", func() { showWindow2 = false }),
	})
}

func window3() {
	g.Window("Window 3", 10, 10, 100, 100, g.Layout{
		g.Button("Close", func() { showWindow3 = false }),
	})
}

func loop() {
	if showWindow2 {
		window2()
	}
	if showWindow3 {
		window3()
	}

	mainWindow()
}

func main() {
	wnd := g.NewMasterWindow("Multiple Windows", 400, 300, g.MasterWindowFlagsFloating, nil)
	wnd.Main(loop)
}

Make Chinese Font loading more fast

Now the loading duration of Chinese font is a little bit slow (using AddFontFromFileTTFV and builder.AddRanges(fonts.GlyphRangesChineseSimplifiedCommon()), if using GlyphRangesChineseFull, will be much more slower).

Could it be better to load Chinese font quickly(I need at least common Chinese characters, not only specific characters)? Thanks.

Versioning

Thanks for an interesting project! I'm getting to know it right now for a vending machine project I'm working on.
I see that you jumped version numbers, from 0.3 to 0.31 and 0.32. Please note, that according to semantic versioning, a future version 0.4 will not be a later version than 0.31 as the version numbers are commonly separated by punctuations . as in <Major>.<Minor>.<Patch>.

A way out of this now could be to issue next patch as 0.33.1 or next minor as 0.34.0. See https://semver.org/ for better information about this subject :)

how to set fonts?

I have a demo like this:

package main

import (
	"fmt"

	g "github.com/AllenDang/giu"
	"github.com/AllenDang/giu/imgui"
)

var (
	font_korean imgui.Font
)

func loadFonts() {
	fonts := g.Context.IO().Fonts()

	ranges := imgui.NewGlyphRanges()

	builder := imgui.NewFontGlyphRangesBuilder()
	//builder.AddRanges(fonts.GlyphRangesKorean())
	builder.AddText("한국어")

	builder.BuildRanges(ranges)

	font_korean := "./NanumGothic.ttf"
	fonts.AddFontFromFileTTF(font_korean, 12)
        // fonts.AddFontFromFileTTFV(font_korean, 12, imgui.DefaultFontConfig, fonts.GlyphRangesKorean())

}

func test1() {
	fmt.Println("한국어")
}

func loop() {
        // g.PushFont(font_korean)
	g.SingleWindowWithMenuBar("한국어", g.Layout{
		g.Line(
			g.Button("한국어", test1),
		),
	})
        // g.PopFont()
}

func main() {
	wnd := g.NewMasterWindow("한국어", 1024, 768, 0, nil)
	wnd.Main(loop)
}

but when I run giu, I only see ??? for the button.

giu and goroutines

Hello, i have checked example about updating variables from another goroutine, but if i moving the window no gui update happen.

PopupModal doesn't work in menu.

This is caused by the selectable and menuitem will invoke CloseCurrentPopup automatically and will close PopupModal which is just opened.

This could be handled inside giu.

Add widget dynamically

Hi, I'm trying to, given the click of a button (in it's triggered func(){}) add another button next to the previous one.

I can't find a concrete example of how to do this because the widgets are not passed by reference. Do I need to copy and re-render the whole window with all it's previous state and just the new button added? How can I achieve this?

Many thanks for the great lib!

InputText in TabItem not working.

Hi, i can provide simple code for demonstrate the problem:

var value string
func loop(w *giu.MasterWindow) {
	giu.SingleWindow(w, "test", giu.Layout{
		giu.TabBar("MainBar", []*giu.TabItemWidget{
			giu.TabItem("InputText", giu.Layout{
				giu.InputText("", &value, nil),
			}),
		}),
	})
}

NewMasterWindow serialization

Is there any possibility to Serialize the MasterWindow struct into a file, and then have other programs read the struct and have the capabilities of accesing giu functions as adding more windows inside the main window?
As like having a server/client architecture where the server creates the MasterWindow and writes the struct to a file while having the main window open. Then if i open the client app, it will read the struct from the file and manipulate the main window via the struct.
I don't know if i explained myself and what im trying to achieve, but is there any way of getting into what i have in mind? Thanks!

Get mouse position

Is there a function inside Giu or Imgui that gives the mouse position inside the window?
Thanks :)

Issue on macOS with an external monitor

While running the widgets example, I can't click or interact with anything in the window if I'm using an external monitor with a Mac having the lid closed. Hopefully, it works if the lid is opened (on both the Mac screen and on the external monitor).

Something that may be interesting is that I can interact with the inputs (editfield and button) in the loadimage, simple and helloworld examples, but not in others (i.e. splitter, customwidget, widgets).

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.