Giter Club home page Giter Club logo

go-fltk's People

Contributors

aiddqd avatar andrebq avatar diegoefe avatar jopbrown avatar mark-summerfield avatar mgord9518 avatar moalyousef avatar pwiecz avatar roblillack avatar sunshine69 avatar tomet 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

go-fltk's Issues

Subtle crash with dynamic menu

I have a reproducable crash in Gviz which I can't figure out.

  1. Preparation: run gviz and open one of the eg/*.gv files; repeat this a few times so you have some recent files.
  2. Run gviz and press Alt+F,R to pop up the recent files submenu
  3. Press Esc
  4. Press Alt+O to pop up the file open menu: all works fine.
  5. Run gviz and press Alt+F,R to pop up the recent files submenu
  6. Press up arrow to highlight the open menu, then press Enter to select the open menu: crash.

The error I get is:

Unrecoverable error: runtime error: slice bounds out of range [:-1]

But I believe that I don't use [:-1] in my code.

[request] HelpView scroll to End

I have a HelpView in minicalc which gets repopulated after every calculation in the Evaluator tab. Once the size of the html page is too long the HelpView correctly adds a vertical scrollbar. But I cannot find a way to scroll the HelpView so that the last line is visible. I've tried SetTopLine and SetTopLineString but neither help. I just need a ScrollToEnd() method.

Example app: gviz

The Gviz app I'm finishing up now is essentially complete. It is < 2KLOC yet shows:

  • standard menu bar with dynamically updated recent files list
  • two toolbars both hideable/showable
  • a modeless dialog (help dialog)
  • modal dialogs including ones that provide results (e.g., ask_form, find_form), and a "smart" live updates dialog (config_form)
  • use of a Tile and a Scroll
  • several event handlers

So it might be worth linking to as an example to supplement the docs. Anyway, that's up to you. (Either way, please just close this issue once you've read it. I'd have emailed but don't know your address & there's no discussion link I can see.)

Fl::set_fonts?

Is it possible to add support of the Fl::set_fonts method so multiple fonts can be use?

Wrap Fl_Group::children()

Without this method there is no way to know how many children a group has and, for example, Fl_Scroll can't be reused (meaning clear all children and add new ones without erasing it) because with some "reset" code like this:

func ClearScroll(canvas *fltk.Scroll) {
	c := 0
	for {
		child := canvas.Child(c)

		if nil != child {
			canvas.Remove(child)
		} else {
			break
		}

		c += 1
	}
	canvas.ScrollTo(0, 0)
}

the scrollbars get removed. In Fl_Scroll, the scrollbars are the last widgets in the group so, i.e., you can remove all but the last 2 widgets to preserve the scrollbars.
Or there are another way to do this that I'm missing? (sorry in that case)

svg icons

I prefer to use SVG images for my icons & for the app icon.
But Window.SetIcons only accepts ftlk.RgbImages. FLTK supports the use of SVG images so would it be possible to add Window.SetIcon(fltk.SvgImage) ?

Update bundle libs

Hello, is there a possibility that the bundle libs for gofltk will be updated and also added for apple m1?
I did this in the private workspace for apple m1, but the function signatures in the fltk 1.4 master have now been changed.

Example image.cxx :
int go_fltk_image_fail(Fl_Image *i) {
return i->fail();
}
to
int go_fltk_image_fail(const Fl_Image *i) {
return i->fail();
}

best regards

[question] plans

Interesting package, Go and Fltk would be a excellent fit, one would think. I might be interested in using it, but I'm wondering what can be expected in terms of maintenance and keeping up-to-date with default fltk.

ChoiceDialog improvements

The ChoiceDialog has a title bar with no title and does not show the application icon.
It would be nice if both could be set.

How to set callback on Box?

Hello, I'm trying to implement the code below, but setCallback on Box is not working

package main

import (
	"fmt"
	"math/rand"

	"github.com/pwiecz/go-fltk"
)

const (
	winWidth     = 400
	winHeigth    = 300
	boxNumberCol = 16
	boxNumberRow = 5
	boxWidth     = winWidth / boxNumberCol
	boxHeigth    = winHeigth / boxNumberRow
)

var (
	buffer  [boxNumberCol * boxNumberRow]*fltk.Box
	woffset int = 0
	hoffset int = 0
)

func main() {
	win := fltk.NewWindow(winWidth, winHeigth)
	win.SetLabel("Random Colors")

	for i := 0; i < boxNumberCol*boxNumberRow; i++ {
		color := fltk.NewRGBColor(byte(rand.Int31n(255)), byte(rand.Int31n(255)), byte(rand.Int31n(255)))
		buffer[i] = fltk.NewBox(fltk.BORDER_BOX, 0+woffset, 0+hoffset, boxWidth, boxHeigth, "")
		buffer[i].SetColor(color)
		buffer[i].SetCallback(func() {
			fmt.Println("Clicked") // code not executed
		})
		woffset += boxWidth
		if i%16 == 0 && i != 0 {
			hoffset += boxHeigth
			woffset = 0
		}
	}

	win.End()
	win.Show()
	fltk.Run()
}

There are a way to this callback work on box?

[request] support redrawing after resizing

When I resize minicalc with the Evaluator tab showing, the layout does not automatically re-layout. I tried to solve this:

	app.Window.SetResizeHandler(func() { // app.Window is of type *fltk.Window
		fmt.Println("resize")
		app.Window.Redraw()
	})

This prints 'resize' on the console, but does not force the layout to re-layout.

Browser::HideLine

Hi @mgord9518
I noticed that the code for Browser::HideLine is commented out with:

//TODO: fix crash whenever this is called

FLTK browsers have 1 based indexing, and uncommenting that code (and relevant C++ code) works correctly, it might crash with input (line == 0 or line >= browser.size()), but these checks can be added to the Go side of things.

[suggestion] add Version funcs...

Suggest adding: fltk.Version() string (returns the version of fltk being used, e.g., "v1.4.0") and fltk.GoVersion() string (returns the version of go-fltk, e.g., "v0.1.0")

How to use a gorotine to update widgets? AwakeNullMessage seems not working.

Hi. Very nice work.

I would like to know how I can update a progess bar or other widgets using a goroutine. I'm trying something like the code below, but AwakeNullMessage seems not working.

package main

import (
	"fmt"
	"time"

	"github.com/pwiecz/go-fltk"
)

func main() {

	win := fltk.NewWindow(400, 200)
	win.SetLabel("Go Fltk")
	progress := fltk.NewProgress(10, 10, 250, 40, "Progress")
	progress.SetMaximum(99)
	progress.SetMinimum(0)
	button := fltk.NewButton(10, 50, 80, 30, "Clique-me")
	button.SetColor(fltk.GREEN)
	button.SetCallback(func() {
		fmt.Println("Button clicked")
		go func() {
			for i := 0; i < 100; i++ {
				fltk.Lock()
				progress.SetValue(float64(i))
				fltk.Unlock()
				fltk.AwakeNullMessage()// not updating gui
				time.Sleep(300 * time.Millisecond)
			}
		}()
	})
	win.Resizable(button)
	win.End()
	win.Show()
	fltk.Run()
}

There are a way to acquire something like that?

Image support

Hi
I would like to add image support if that’s ok (would require linking fltk_images, fltk_jpeg, fltk_png and fltk_z on all systems).
Regarding the api, since some images can be constructed from data and/or files, I’m thinking of something like:

image, err := fltk.SvgImageLoad("image.svg")

image, err := fltk.SvgImageString("<svg></svg>") // or SvgImageData

Context switch caption is always "FLTK"

As you can see from the screenshot when I task switch in Linux (Debian XFCE) it correctly shows "MiniCalc" as the application name but under the icon it wrongly shows "FLTK". With other applications the name shown is the same for both, i.e., the application's name.
screenshot

[poss. bug] callback stops being called

I have attached a go-fltk app that has a bug. The bug occurs in my code, but I believe it is due to a bug in go-fltk. I think this because the same thing happened before with a previous go-fltk app I created.

At first I thought the problem was due to me keeping the whole app's state in a pointer to a single struct, e.g.,

type App struct {
	*fltk.Window
	config         *Config
	tabs           *fltk.Tabs
	evalView       *fltk.HelpView
	evalInput      *fltk.InputChoice
	evalResults    []EvalResult
	evalCopyButton *fltk.MenuButton
	regexView      *fltk.HelpView
	regexInput     *fltk.InputChoice
	regexTextInput *fltk.InputChoice
	asciiView      *fltk.HelpView
	customView     *fltk.HelpView
}

and passing this pointer to a callback, and that some kind of locking occurs under the hood so that after a while the callback stops being called. But this isn't the case.

Anyway, to reproduce the bug: build or go run the attached callback_bug.zip. When it starts up you should be on the Evaluator tab. Press and hold the Enter key. This will output a number in the HelpView. After 30-40 repeats holding down Enter will stop having any effect: this is the bug. If you close the app (click X close button or press Ctrl+Q) and rerun and repeat holding Enter, the number it gets up to varies from run to run, i.e., is not deterministic which is why I think it is go-fltk rather than me.

The bug occurs on the file evaluator_tab.go in the onEval callback defined in the function makeBottomRow.
If you comment out lines 43 (userVarNames := ... ) and 59 (nextVarName = onEval(...), and rerun, the bug will not occur: the numbers will continue to be output.

So, on the face of it the problem is in my code (i.e., in onEval or one of its callees); however, I don't believe that my code is the real problem: I think it is a go-fltk issue.

callback_bug.zip

Last time I had this problem, the solution I found was instead of passing a pointer to the whole App struct, I passed in pointers to just those widgets etc. that I needed to access. So I tried this solution with minicalc, but it didn't work. Here's the code with this approach:

callback_bug2.zip

So right now I don't know how to fix this.

[question] How to limit Tabs label height

I have some code like this:

const BUTTON_HEIGHT = 32
window = fltk.NewWindow(512, 480)
window.Resizable(app.window)
window.SetLabel(APPNAME)
width := app.window.W()
height := app.window.H()
tabs := fltk.NewTabs(0, 0, width, height)
tabs.SetAlign(fltk.ALIGN_TOP)
// tabs.SetLabelHeight(BUTTON_HEIGHT) // has no effect
height -= BUTTON_HEIGHT // Allow room for tab
group := fltk.NewGroup(x, y, width, height, "A&bout")
view := fltk.NewHelpView(x, y, width, height)
view.SetValue(aboutHtml())
group.End()
// etc

It runs fine & correctly shows the tabs. But when I increase the size of the window by dragging or maximizing, although most of the extra space goes to the tab groups, some goes to the tabs themselves making them far taller than needed. Is it possible to set their maximum height to BUTTON_HEIGHT?

[request] Complete support for Choice and MenuButton

At the moment it is not possible to dynamially populate a Choice or MenuButton.
Yet this is often a requirement. For example, in https://github.com/mark-summerfield/minicalc I am using an Input for calculator expressions, but I'd prefer to use a Choice which shows the last expression, and the expression before that, and so on for the previous, say 7 expressions. But the current Choice API doesn't support this.
Similarly at the moment I have two Copy buttons to copy specific things, but I'd prefer a Copy MenuButton whose items I could change dynamically.

Image memory leak

There is a small memory leak associated with NewSvgImageFromString(), possibly others but I haven't tested them.

To reproduce, create a loop such as:

for {
    image, _ := NewSvgImageromString(...)
    defer image.Destroy()
}

And the memory usage will slowly rise. It looks like the image pointer isn't being completely destroyed.

[bug] calling InputChoice.MenuButton().Popup() can crash

Run the tiny eg below. Press F2 to pop up the InputChoice menu. Correctly, nothing happens because the menu is empty. Then press F2 again: crash!

package main

import (
	"fmt"

	"github.com/pwiecz/go-fltk"
)

func main() {
	const (
		width      = 200
		height     = 80
		lineHeight = height / 2
	)
	fltk.SetScheme("oxy")
	window := fltk.NewWindow(width, height)
	window.SetLabel("InputChoice")
	vbox := fltk.NewFlex(0, 0, width, height)
	box := fltk.NewBox(fltk.DOWN_FRAME, 0, 0, width, lineHeight,
		"(Nothing Chosen)")
	choice := fltk.NewInputChoice(0, lineHeight, width, lineHeight)
	fmt.Println(box, choice)
	vbox.End()
	window.SetEventHandler(func(event fltk.Event) bool {
		if fltk.EventType() == fltk.KEY && fltk.EventKey() == fltk.F2 {
			if menu := choice.MenuButton(); menu != nil {
				menu.Popup()
			}
		}
		return false
	})
	window.Show()
	fltk.Run()
}

My crash output:

&{{0x2186ef0 0 3 0 0 0 <nil> <nil>}} &{{{0x21870d0 0 4 0 0 0 <nil> <nil>}} 0xc00009e0f0 0xc0000b40e0 5}
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x54338e]

runtime stack:
runtime.throw({0x653997?, 0x7ffead511618?})
	/home/mark/opt/go/src/runtime/panic.go:1047 +0x5d fp=0x7ffead511510 sp=0x7ffead5114e0 pc=0x4aa9fd
runtime.sigpanic()
	/home/mark/opt/go/src/runtime/signal_unix.go:821 +0x3e9 fp=0x7ffead511570 sp=0x7ffead511510 pc=0x4bf0c9

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x5071b0, 0xc0000bfc20)
	/home/mark/opt/go/src/runtime/cgocall.go:157 +0x5c fp=0xc0000bfbf8 sp=0xc0000bfbc0 pc=0x47c3dc
github.com/pwiecz/go-fltk._Cfunc_go_fltk_MenuButton_popup(0x216e7c0)
	_cgo_gotypes.go:2554 +0x45 fp=0xc0000bfc20 sp=0xc0000bfbf8 pc=0x4fd505
github.com/pwiecz/go-fltk.(*MenuButton).Popup.func1(0xc0000bfc70?)
	/home/mark/opt/gows/pkg/mod/github.com/pwiecz/[email protected]/menu.go:139 +0x46 fp=0xc0000bfc58 sp=0xc0000bfc20 pc=0x4ff126
github.com/pwiecz/go-fltk.(*MenuButton).Popup(0xc00000ffbf?)
	/home/mark/opt/gows/pkg/mod/github.com/pwiecz/[email protected]/menu.go:139 +0x19 fp=0xc0000bfc70 sp=0xc0000bfc58 pc=0x4ff0b9
main.main.func1(0x63a4c0?)
	/home/mark/tmp/inputchoice/choice.go:27 +0x85 fp=0xc0000bfc90 sp=0xc0000bfc70 pc=0x5037c5
github.com/pwiecz/go-fltk.(*eventHandlerMap).invoke(...)
	/home/mark/opt/gows/pkg/mod/github.com/pwiecz/[email protected]/enumerations.go:315
github.com/pwiecz/go-fltk._go_eventHandler(0x61a0?, 0x8)
	/home/mark/opt/gows/pkg/mod/github.com/pwiecz/[email protected]/enumerations.go:335 +0x51 fp=0xc0000bfcb8 sp=0xc0000bfc90 pc=0x4fe431
_cgoexp_00c77b302643__go_eventHandler(0x7ffead512114)
	_cgo_gotypes.go:7099 +0x25 fp=0xc0000bfcd0 sp=0xc0000bfcb8 pc=0x5012a5
runtime.cgocallbackg1(0x501280, 0xc0000bfe80?, 0x0)
	/home/mark/opt/go/src/runtime/cgocall.go:315 +0x2b1 fp=0xc0000bfd98 sp=0xc0000bfcd0 pc=0x47c8d1
runtime.cgocallbackg(0xc0000061a0?, 0x300000002?, 0xc0000061a0?)
	/home/mark/opt/go/src/runtime/cgocall.go:234 +0x109 fp=0xc0000bfe28 sp=0xc0000bfd98 pc=0x47c589
runtime.cgocallbackg(0x501280, 0x7ffead512114, 0x0)
	<autogenerated>:1 +0x2f fp=0xc0000bfe50 sp=0xc0000bfe28 pc=0x4d9c0f
runtime.cgocallback(0x47c405, 0x506520, 0xc0000bfee0)
	/home/mark/opt/go/src/runtime/asm_amd64.s:998 +0xb4 fp=0xc0000bfe78 sp=0xc0000bfe50 pc=0x4d7514
runtime.systemstack_switch()
	/home/mark/opt/go/src/runtime/asm_amd64.s:463 fp=0xc0000bfe80 sp=0xc0000bfe78 pc=0x4d5520
runtime.cgocall(0x506520, 0xc0000bfee0)
	/home/mark/opt/go/src/runtime/cgocall.go:167 +0x85 fp=0xc0000bfeb8 sp=0xc0000bfe80 pc=0x47c405
github.com/pwiecz/go-fltk._Cfunc_go_fltk_run()
	_cgo_gotypes.go:6634 +0x48 fp=0xc0000bfee0 sp=0xc0000bfeb8 pc=0x4fe148
github.com/pwiecz/go-fltk.Run(...)
	/home/mark/opt/gows/pkg/mod/github.com/pwiecz/[email protected]/fltk.go:22
main.main()
	/home/mark/tmp/inputchoice/choice.go:33 +0x1ab fp=0xc0000bff80 sp=0xc0000bfee0 pc=0x50370b
runtime.main()
	/home/mark/opt/go/src/runtime/proc.go:250 +0x207 fp=0xc0000bffe0 sp=0xc0000bff80 pc=0x4ad2e7
runtime.goexit()
	/home/mark/opt/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000bffe8 sp=0xc0000bffe0 pc=0x4d7741

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/home/mark/opt/go/src/runtime/proc.go:381 +0xd6 fp=0xc000068fb0 sp=0xc000068f90 pc=0x4ad716
runtime.goparkunlock(...)
	/home/mark/opt/go/src/runtime/proc.go:387
runtime.forcegchelper()
	/home/mark/opt/go/src/runtime/proc.go:305 +0xb0 fp=0xc000068fe0 sp=0xc000068fb0 pc=0x4ad550
runtime.goexit()
	/home/mark/opt/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000068fe8 sp=0xc000068fe0 pc=0x4d7741
created by runtime.init.6
	/home/mark/opt/go/src/runtime/proc.go:293 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
	/home/mark/opt/go/src/runtime/proc.go:381 +0xd6 fp=0xc000069780 sp=0xc000069760 pc=0x4ad716
runtime.goparkunlock(...)
	/home/mark/opt/go/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
	/home/mark/opt/go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc0000697c8 sp=0xc000069780 pc=0x49a48e
runtime.gcenable.func1()
	/home/mark/opt/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000697e0 sp=0xc0000697c8 pc=0x48f966
runtime.goexit()
	/home/mark/opt/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000697e8 sp=0xc0000697e0 pc=0x4d7741
created by runtime.gcenable
	/home/mark/opt/go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc000090000?, 0x66adc8?, 0x1?, 0x0?, 0x0?)
	/home/mark/opt/go/src/runtime/proc.go:381 +0xd6 fp=0xc000069f70 sp=0xc000069f50 pc=0x4ad716
runtime.goparkunlock(...)
	/home/mark/opt/go/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x75f460)
	/home/mark/opt/go/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc000069fa0 sp=0xc000069f70 pc=0x4983d3
runtime.bgscavenge(0x0?)
	/home/mark/opt/go/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc000069fc8 sp=0xc000069fa0 pc=0x4989a5
runtime.gcenable.func2()
	/home/mark/opt/go/src/runtime/mgc.go:179 +0x26 fp=0xc000069fe0 sp=0xc000069fc8 pc=0x48f906
runtime.goexit()
	/home/mark/opt/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000069fe8 sp=0xc000069fe0 pc=0x4d7741
created by runtime.gcenable
	/home/mark/opt/go/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x1a0?, 0x75f8a0?, 0x60?, 0x78?, 0xc000068770?)
	/home/mark/opt/go/src/runtime/proc.go:381 +0xd6 fp=0xc000068628 sp=0xc000068608 pc=0x4ad716
runtime.runfinq()
	/home/mark/opt/go/src/runtime/mfinal.go:193 +0x107 fp=0xc0000687e0 sp=0xc000068628 pc=0x48e9a7
runtime.goexit()
	/home/mark/opt/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000687e8 sp=0xc0000687e0 pc=0x4d7741
created by runtime.createfing
	/home/mark/opt/go/src/runtime/mfinal.go:163 +0x45
exit status 2

[possible bug] When EventType() is Key letters are only matched if CTRL is down

Here's a simplified version:

window := fltk.NewWindow(640, 480)
window.SetEventHandler(func(event fltk.Event) bool {
	switch fltk.EventType() {
	case fltk.KEY:
		switch fltk.EventKey() {
		case fltk.ESCAPE:
			return true
		case fltk.HELP, fltk.F1:
			fmt.Println("help")
			return true
		case fltk.F2:
			fmt.Println("F2")
			return true
		case 'q', 'Q': // only triggered with CTRL! -- is this correct or a bug???
			fmt.Println("Q")
		}
	case fltk.CLOSE:
		window.Destroy()
	}
	return false
})

To try it out run https://github.com/mark-summerfield/minicalc (>= v1.1.1) and press 'Q' or 'q' in one of the Inputs and then try Ctrl+q (which should quit)

[question] static building for windows on linux

I can cross-compile a windows .exe on linux using this .sh script:

go-winres simply --icon images/icon.ico
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc \
    CXX=x86_64-w64-mingw32-g++ \
    go build -buildvcs=false -ldflags -H=windowsgui -o minicalc.exe .

But unfortunately, this uses dynamic linking which means the target windows machine must have mingw's dlls installed and in the PATH.

Is it possible to create a completely standalone .exe (i.e., statically linked) for windows from linux? And if so, how?

Regarding the licensing of go-fltk

Hello
Would you consider changing the license to a more permissive license?
The FLTK license for example is basically lgpl with an exception allowing static linking.

Fullscreen support

Does this port support setting a window in fullscreen mode? I can't find any referances in the docs to this.

If not it would be a nice feature ^^

Can I set a window icon?

Hello.

How can I set a window Icon?

Is the window.SetImage() function the right way? Because that does nothing for me.

More TextDisplay methods needed...

I'm trying to create a little editor. Ideally I'd like to be able to set a monospace font: see TextDisplay.textfont.

Support for line numbering would also be nice although from the docs I can see how to format line numbers but not how to enable/disable them.

is it possible to build win .exe's on linux?

For command line applications I can usually build them on linux for windows using a command line like this:

But when I try this with a go-fltk app I get an error:

github.com/pwiecz/go-fltk: build constraints exclude all Go files in /home/mark/opt/gows/pkg/mod/github.com/pwiecz/[email protected]

It is possible, or must I build for windows on windows?

It can be useful to force a widget to redo its layout

In my gviz app I have two toolbars that the user can show or hide.
But when shown or hidden I need to get the main layout (a Flex) to redo its layout to account for the reduced or increased space available.

Although it is easily done in Go:

func (me *App) layout() { // me.mainVBox is a Flex
	me.mainVBox.Resize(me.mainVBox.X(), me.mainVBox.Y(), me.mainVBox.W(), me.mainVBox.H())
	me.mainVBox.Redraw()
}

The FLTK API provides Flex::layout() which does this. So it might be nice to provide it in the go-fltk API? The same applies to Group::init_sizes().

See Albrecht Schlosser's post for links and explanation.

fluid like tool for UI design

One of the best things about FLTK is the fluid ui designer.
I would be great to have a similar tool that parses de .fl files to generate one or more .go files with the corresponding definitions

texteditor example and use of Fl_Pack vs Fl_Flex or Fl_Grid

The texteditor example is using pack, but probably should use Flex or Grid

https://groups.google.com/g/fltkgeneral/c/YmeBCSbq2Rw/m/pEVMG_nUAwAJ?utm_medium=email&utm_source=footer&pli=1

"The reason for that behavior is the intended use (of FL_Pack) inside an Fl_Scroll, where the
pack would be the immediate child, so that the scrollbars adjust automatically
when a widget in the pack is removed/hidden."

"As Greg wrote, the Fl_Pack widget "shrink-wraps" around its children and uses a special handling of the resizable() child widget. It applies these special features mostly inside the draw() method which makes its behavior even less predictable (and IMHO usable).

Fl_Flex is designed to be used as a drop-in replacement of Fl_Pack (if you don't use some special Fl_Pack properties and methods). It's mostly source compatible and you can try/view/test this in test/pack.cxx which has been modified to use either an Fl_Pack or an Fl_Flex container inside an Fl_Scroll widget or as a main container.

Fl_Flex's resize behavior is kinda the opposite of Fl_Pack. Fl_Flex uses all the space assigned to it (w, h) and resizes its children to fit according to some rules. If you hide one child widget (of a total of two children) the other one will take the entire space of the parent Fl_Flex container. But beware: Fl_Flex is already functional but not yet 100% complete.

That said, another container (Fl_Grid) is work in progress and will provide a grid (aka matrix) of widgets similar to an HTML

. Fl_Grid will be included in 1.4.0 if nothing really bad happens, I'm pretty confident. Fl_Grid may not be what you want though but you can construct an Fl_Grid widget with only one row or one column if you want its particular resizing features which are much more versatile than Fl_Flex.

Fl_Flex and Fl_Grid can be children of another Fl_Group (or derived, even Fl_Flex or Fl_Grid) widget, hence you can achieve complex nested resizing behavior."

https://github.com/pwiecz/go-fltk/blob/main/examples/texteditor/main.go

TextEditor undo crashes

If I run https://github.com/mark-summerfield/gviz and immediatetly do Ctrl+Z or Edit->Undo (i.e., when there is nothing to be undone) the app crashes. The same thing happens if I do Ctrl+Shift+Z or Edit->Redo when there's nothing to be redone.

Unrecoverable error: runtime error: invalid memory address or nil pointer dereference

When I wrapped Fl_Text_Editor::undo() I used the same code pattern as was already in place for cut/copy/paste. But should I now add a check, e.g., changing,

func (t *TextEditor) Undo() {
	C.go_fltk_TextEditor_undo((*C.Fl_Text_Editor)(t.ptr()))
}

to, say,

func (t *TextEditor) Undo() {
        if p := t.ptr(); p != nil {
        	C.go_fltk_TextEditor_undo((*C.Fl_Text_Editor)(p))
        }
}

However, I suspect that the problem is elsewhere since none of the cut/copy/paste methods check the pointer deref. In which case, could it be a problem in FLTK itself?

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.