Go to file
Pietro Gagliardi c82949b8d2 Removed some more commented-out code from ages ago from area_unix.go. 2014-06-02 12:03:37 -04:00
experiments Merged back combobox_darwin.m, rewrote it to use boundListboxArray() instead of creating a whole new object, and implemented what appears to be a fix for NSPopUpButton selection. Will delete the unneeded select(-1) code later and test again... 2014-05-28 23:46:33 -04:00
olddocs Moved some old documents out of the top-level directory and into a folder olddocs/ to make things neater. 2014-05-16 19:57:25 -04:00
test Decided to drop the whole handled thing with Area events and just continue the event chain if needed. Same for MousEvent; will have to document that. This is just the test program for now. 2014-06-01 23:34:26 -04:00
tools Moved the standard window class (for Window) on Windows to get the sysData pointer from CreateWindowEx() and store it in the window memory instead of being given it via a closure. This will lead to having only one window class for all Windows, which will come next. Also fixed an error in windowsconstgen's output related to GetWindowLongPtr()/SetWindowLongPtr(). 2014-05-30 17:59:29 -04:00
.travis.yml Changed -qq to -y in the apt-get install line in .travis.yaml because I want to see the full details of the install. 2014-03-24 11:54:30 -04:00
LICENSE Added license and README. 2014-02-17 18:38:50 -05:00
README.md Added the CL and some notes to the README since it won't land in Go 1.3. I should probably retool this README... 2014-05-28 12:19:22 -04:00
area.go Documented the changed event handling of Area. 2014-06-02 11:27:37 -04:00
area_darwin.go Added new Modifiers code for Mac OS X. Also fixed some comment typos and added more TODOs. 2014-05-29 14:26:45 -04:00
area_darwin.m Changed #include to #import on the Objective-C files to settle the whole include guards thing. Now to continue fixing Mac OS X 10.6 building... 2014-05-20 08:08:55 -04:00
area_unix.go Removed some more commented-out code from ages ago from area_unix.go. 2014-06-02 12:03:37 -04:00
area_windows.go Implemented the new Area event handling on Windows. 2014-06-02 11:32:19 -04:00
button.go Documented that event channels can be assigned to each other to collapse events. 2014-04-10 11:59:40 -04:00
callbacks_unix.go Removed the extra #cgo directives from the Unix files. cgo collects directives from ALL files, rather than using each file's directive individually, so having them combined like this is pointless. Instead, the #cgo directives are (or is, since there's only one) in uitask_unix.go. Will do the same for Mac next; this will help since we're going to add a CFLAGS value afterward. 2014-05-19 22:32:38 -04:00
checkbox.go Moved TODOs about new event signals to the future plans document. 2014-04-28 20:59:42 -04:00
combobox.go Checked to see if the previous commit worked after removing the leftover Combobox selectIndex() code; it does. Removed the dummy code from the Windows and GTK+ backends as well. 2014-05-29 04:41:07 -04:00
combobox_darwin.m Checked to see if the previous commit worked after removing the leftover Combobox selectIndex() code; it does. Removed the dummy code from the Windows and GTK+ backends as well. 2014-05-29 04:41:07 -04:00
comctl_windows.go Fixed issues handling INVALID_HANDLE_VALUE in the Windows constant generator, and built the first build with generated constants! 2014-05-25 14:04:03 -04:00
common_windows.go Merged windows_windows.go into common_windows.go. 2014-05-26 22:36:34 -04:00
control.go Updated the documentation: Area now works on all platforms, Modifiers behavior on both left and right keys simultaneously is undefined for now, and the way to create custom Controls no longer involves embedding Area. 2014-03-30 19:57:24 -04:00
controls_windows.go Removed commented-out checkbox stuff from controls_windows.go since we'll be sending messages directly to the checkbox instead. We still have to worry about radio buttons, so I'm not merging controls_windows.go into common_windows.go just yet. 2014-05-26 22:39:30 -04:00
d32 cgo inserts -m32 automatically, so we don't need to in ./d32. 2014-03-08 17:32:56 -05:00
delegate_darwin.go Same as previous commit, but for Mac OS X now. The #cgo directives are in uitask_darwin.go. 2014-05-19 22:52:59 -04:00
delegateuitask_darwin.m Fixed the whole NSApplication.h thing so now the project builds with both 10.6 and 10.8. Ugh. 2014-05-20 08:35:39 -04:00
dialog.go Removed unnecessary space if the secondaryText argument to MsgBox***() is an empty string. This doesn't change much on Mac OS X; it always shows the informational text field, showing an empty string by default. On GTK+ it seems to get rid of the bold over the primary text; I'm going to assume this is intentional (it looks that way on GTK+ 2; the HIG docs have outdated screenshots...). 2014-04-10 12:35:37 -04:00
dialog_darwin.go Same as previous commit, but for Mac OS X now. The #cgo directives are in uitask_darwin.go. 2014-05-19 22:52:59 -04:00
dialog_darwin.m Changed #include to #import on the Objective-C files to settle the whole include guards thing. Now to continue fixing Mac OS X 10.6 building... 2014-05-20 08:08:55 -04:00
dialog_unix.go Removed the extra #cgo directives from the Unix files. cgo collects directives from ALL files, rather than using each file's directive individually, so having them combined like this is pointless. Instead, the #cgo directives are (or is, since there's only one) in uitask_unix.go. Will do the same for Mac next; this will help since we're going to add a CFLAGS value afterward. 2014-05-19 22:32:38 -04:00
dialog_windows.go Stripped constants from dialog_windows.go. 2014-05-25 14:12:57 -04:00
doc.go Documented that event channels can be assigned to each other to collapse events. 2014-04-10 11:59:40 -04:00
events_darwin.go Removed kVK_ANSI_KeypadClear from events_darwin.go; this is a holdover from early Mac keyboards that had a Clear key where Num Lock is on an IBM keyboard (for example, http://upload.wikimedia.org/wikipedia/commons/4/4e/Apple_Macintosh_Plus_Extended_Keyboard.jpg (via Psy| in irc.freenode.net/#macdev)) and is irrelevant to our usage. 2014-05-31 23:49:57 -04:00
events_notdarwin.go Finished the Area clicking stuff: formalized the behavior in documentation in area.go, pointed out that Mac OS X already behaves as expected, updated some comments, and removed the relevant TODO. 2014-05-23 23:48:17 -04:00
futureplans.md Decided not to rename Stack to Box because Box means a lot of different things; described problems with that in futureplans.md. 2014-05-31 21:09:07 -04:00
grid.go Resolved Grid TODOs: moved feature requests to future plans and made sure SetStretchy() doesn't leave previous stretchy controls filling by accident. 2014-04-29 10:10:28 -04:00
gtk_unix.h Moved <stdlib.h> includes in the GTK+ backend to gtk_unix.h; organized that file a bit. 2014-04-01 16:01:49 -04:00
gtkcalls_unix.go More TODOs. 2014-05-24 21:30:21 -04:00
gtkcasts_unix.go Removed the extra #cgo directives from the Unix files. cgo collects directives from ALL files, rather than using each file's directive individually, so having them combined like this is pointless. Instead, the #cgo directives are (or is, since there's only one) in uitask_unix.go. Will do the same for Mac next; this will help since we're going to add a CFLAGS value afterward. 2014-05-19 22:32:38 -04:00
init.go Removed a TODO from init.go that was already in the future plans document. 2014-04-28 02:15:19 -04:00
init_windows.go Changed Areas on WIndows so that they all use the same window class, rather than having one per Area. 2014-05-30 23:02:15 -04:00
label.go Fixed Area test time label weirdness by making Labels truncate their text instead of word-wrapping on all platforms. This doesn't explain GTK+/Wayland, alas. 2014-04-13 18:05:07 -04:00
lineedit.go Moved TODOs about new event signals to the future plans document. 2014-04-28 20:59:42 -04:00
listbox.go Found a method in NSArrayController via Stack Overflow which lets me suppress selection-changing behavior on NSTableView inserts; use that on Listbox in Mac OS X. This means sysData.selectIndices() and its Mac OS X implementation can (and has) gone away, clearing TODOs on Windows and Unix by extension. 2014-05-17 12:42:00 -04:00
listbox_darwin.go Same as previous commit, but for Mac OS X now. The #cgo directives are in uitask_darwin.go. 2014-05-19 22:52:59 -04:00
listbox_darwin.m Fixed the whole NSApplication.h thing so now the project builds with both 10.6 and 10.8. Ugh. 2014-05-20 08:35:39 -04:00
listbox_unix.go Removed the extra #cgo directives from the Unix files. cgo collects directives from ALL files, rather than using each file's directive individually, so having them combined like this is pointless. Instead, the #cgo directives are (or is, since there's only one) in uitask_unix.go. Will do the same for Mac next; this will help since we're going to add a CFLAGS value afterward. 2014-05-19 22:32:38 -04:00
objc_darwin.go Same as previous commit, but for Mac OS X now. The #cgo directives are in uitask_darwin.go. 2014-05-19 22:52:59 -04:00
objc_darwin.h Checked to see if the previous commit worked after removing the leftover Combobox selectIndex() code; it does. Removed the dummy code from the Windows and GTK+ backends as well. 2014-05-29 04:41:07 -04:00
objc_darwin.m Fixed the whole NSApplication.h thing so now the project builds with both 10.6 and 10.8. Ugh. 2014-05-20 08:35:39 -04:00
prefsize_darwin.go Same as previous commit, but for Mac OS X now. The #cgo directives are in uitask_darwin.go. 2014-05-19 22:52:59 -04:00
prefsize_darwin.m Fixed the whole NSApplication.h thing so now the project builds with both 10.6 and 10.8. Ugh. 2014-05-20 08:35:39 -04:00
prefsize_unix.go Removed height-for-width TODO from prefsize_unix.go after discussion with Company in irc.gimp.net/#gtk+. 2014-04-27 16:26:06 -04:00
prefsize_windows.go Rolled back the Windows horizontally scrolling Listbox changes because I can't seem to get it to work on Mac OS X (and keeping that code there is inefficient); removed the guarantee of horizontal scrollbars in Listbox and made that a future plan. Both the Windows and the non-working Mac OS X code is in unmigrated/hscrolllistbox.go (and the unmigrated/ folder will be renamed shortly). 2014-04-13 13:00:07 -04:00
progressbar.go Removed the initText parameter from sysData.make() and changed all invocations to call sysData.setText() separately; this avoids the need to check if sysData.setText() is valid. Also implemented that on GTK+. 2014-04-01 16:43:56 -04:00
stack.go Made Space() return the same Control repeatedly instead of making a new one each time to conserve memory. No future guarantees, however, so that is noted in the documentation as well. 2014-04-26 16:05:23 -04:00
stdfont_windows.go Finished migrating the Windows code to using the pregenerated constants. 2014-05-25 15:23:11 -04:00
stdwndclass_windows.go Changed storeSysData() on Windows to write the HWND to the sysData structure there. This will be important for removing some of the TODOs from areaWndProc(). 2014-05-30 23:28:41 -04:00
sysdata.go Checked to see if the previous commit worked after removing the leftover Combobox selectIndex() code; it does. Removed the dummy code from the Windows and GTK+ backends as well. 2014-05-29 04:41:07 -04:00
sysdata_darwin.go Checked to see if the previous commit worked after removing the leftover Combobox selectIndex() code; it does. Removed the dummy code from the Windows and GTK+ backends as well. 2014-05-29 04:41:07 -04:00
sysdata_darwin.m Checked to see if the previous commit worked after removing the leftover Combobox selectIndex() code; it does. Removed the dummy code from the Windows and GTK+ backends as well. 2014-05-29 04:41:07 -04:00
sysdata_unix.go Changed Unix Area WM_ACTIVATE equivalent handling to use enter-notify-event and leave-notify-event instead of focus-in-event and focus-out-event as suggested by tristan in irc.gimp.net/#gtk+. 2014-06-01 00:16:57 -04:00
sysdata_windows.go Changed storeSysData() on Windows to write the HWND to the sysData structure there. This will be important for removing some of the TODOs from areaWndProc(). 2014-05-30 23:28:41 -04:00
tableviewproposal.md Switched TableView proposal from <tt>...</tt> to <tt><ins>...</ins></tt> to make those parts distinct from code blocks. 2014-05-08 16:38:46 -04:00
test.sh Corrected the environment in windowsconstgen.go so that we can run it from test.sh. Phew! 2014-05-25 16:50:52 -04:00
todo.md Added new Modifiers code for Mac OS X. Also fixed some comment typos and added more TODOs. 2014-05-29 14:26:45 -04:00
uitask_darwin.go Set up the Mac OS X build to always target Mac OS X 10.6 regardless of the host system; this is what we want and by default building on 10.8 produces binaries which won't run on 10.6. This isn't working yet, though: one enum in NSApplication.h becomes empty on 10.6... 2014-05-19 23:53:10 -04:00
uitask_unix.go Moved gtk_main() such that uitask_unix.go calls it directly via cgo. This is in preparation for the next two commits, which will remove the #cgo directives from all files except the uitask_*.go files, since they're being concatenated across files. 2014-05-19 22:18:53 -04:00
uitask_windows.go Normalized DefWindowProc() handling across the Windows files; the syscall.LazyProc now has the normalized name _defWindowProc and defWindowProc() is a convenience function that calls _defWindowProc properly. This will also be important for the switch to a single window class per Window/Area. 2014-05-30 14:15:32 -04:00
window.go Documented that event channels can be assigned to each other to collapse events. 2014-04-10 11:59:40 -04:00
zconstants_windows_386.go Moved the standard window class (for Window) on Windows to get the sysData pointer from CreateWindowEx() and store it in the window memory instead of being given it via a closure. This will lead to having only one window class for all Windows, which will come next. Also fixed an error in windowsconstgen's output related to GetWindowLongPtr()/SetWindowLongPtr(). 2014-05-30 17:59:29 -04:00
zconstants_windows_amd64.go Moved the standard window class (for Window) on Windows to get the sysData pointer from CreateWindowEx() and store it in the window memory instead of being given it via a closure. This will lead to having only one window class for all Windows, which will come next. Also fixed an error in windowsconstgen's output related to GetWindowLongPtr()/SetWindowLongPtr(). 2014-05-30 17:59:29 -04:00

README.md

Build Status

Native UI library for Go

THIS PACKAGE IS UNDER ACTIVE DEVELOPMENT. It can be used; the API is stable enough at this point, but keep in mind there may still be crashes and API changes, as suggestions are always open. If you can help, please do! Run ./test to build a test binary test/test which runs a (mostly) feature-complete UI test. Run ./d32 ./test to build a 32-bit version (you will need a cgo-enabled 32-bit go environment, and I have only tested this on Mac OS X). For Windows targets, you will need a cgo-enabled windows/386 AND windows/amd64 to regenerate the autogenerated zconstants_windows_*.go files (cross-compiling multiple cgo-enabled targets in Go isn't possible yet; I have a CL pending that will make it so (it's too late for Go 1.3 but it might land in 1.4; you can try applying it yourself but; I also don't intend on adding a flag to suppress regeneration lest I get complacent and start using it myself and introduce some mystery bug); native Windows targets should be able to work fine, but I haven't tested it).

UPDATE 12 March 2014: Windows 2000 is no longer supported as it is no longer supported by Go.

UPDATE 18 March 2014: Resizes are now assumed to stop other UI event processing, and thus do not run with locks anymore. I changed real control resizing so that it doesn't need to lock (it just fills an array with data fed in), but real control preferredSize() and Stack/Grid.setRect() could potentially still be racy... if I am right it won't be an issue, but if anyone else knows, please let me know. (Everything else is thread-safe again.)

UPDATE 27 March 2014: Unix builds now require go tip due to a cgo fix that affected this package.

UPDATE 12 April 2014: Areas now require their images to be image.RGBA, not image.NRGBA. Update your code appropriately.

This is a simple library for building cross-platform GUI programs in Go. It targets Windows, Mac OS X, Linux, and other Unixes, and provides a thread-safe, channel-based API. The API itself is minimal; it aims to provide only what is necessary for GUI program design. That being said, suggestions are welcome. Layout is done using various layout managers, and some effort is taken to conform to the target platform's UI guidelines. Otherwise, the library uses native toolkits.

ui aims to run on all supported versions of supported platforms. To be more precise, the system requirements are:

  • Windows: Windows XP or newer. The Windows backend uses package syscall and calls Windows DLLs directly, so does not rely on cgo.
    • Note: it does, however, rely on a pregenerated set of constants based on the Windows header files. I locally build a new one each time and these are included in the repo as zconstants_windows_*.go; you can rebuild them yourself with the included tools/windowsconstgen.go (see test.sh).
  • Mac OS X: Mac OS X 10.6 (Snow Leopard) or newer. Objective-C code is used directly for maximum portability, and thus this uses cgo.
    • Note: you will need Go 1.3 or newer (so until it is released, go tip) for this verison, as it uses Objective-C.
  • Other Unixes: The Unix backend uses GTK+, and thus cgo. It requires GTK+ 3.4 or newer; for Ubuntu this means 12.04 LTS (Precise Pangolin) at minimum. Check your distribution.
    • Note: you will need Go 1.3 or newer (as above) due to various cgo errors fixed in this version (such as this one).

ui itself has no outside Go package dependencies; it is entirely self-contained.

To install, simply go get this package. On Mac OS X, make sure you have the Apple development headers. On other Unixes, make sure you have the GTK+ development files:

  • for Ubuntu, libgtk-3-dev is sufficient
  • for FreeBSD with the pkgng system, gtk3 is sufficient, however you will need to manually install pkgconf to please cgo (and you may need to specify CC=gcc47) (this should be put on the Go wiki)

Package documentation is available at http://godoc.org/github.com/andlabs/ui.

For an example of how ui is used, see https://github.com/andlabs/wakeup, which is a small program that implements a basic alarm clock.

Known To Have Ever Been Built Matrices

For convenience's sake, here are matrices of builds that I have personally done at least once. Each cell represents the run status. These matrices represent builds that I have done at any point in development; it is not a guarantee that the current version works. (I built this list to answer questions of whether or not ui works with a specific configuration.) Only configurations marked with a * are tested during active development. "(invalid)" means the given OS/arch combination is not supported by Go.

386 amd64 arm
windows works on windows; works on wine* works on windows; fails on wine (invalid)
linux see table below see table below Raspian: works
darwin (Mac OS X) works* (cross-compiled from 64-bit) works* (invalid)
dragonfly untested untested (invalid)
freebsd works untested (VM failure) untested
netbsd untested untested untested
openbsd untested untested (invalid)
solaris (invalid) Oracle Solaris 11: GTK+ 3 not available from official repos (invalid)
plan9 (not written yet; problems building Go) (not written) (invalid)
nacl (not sure how to handle) (not sure how to handle) (invalid)
linux 386 amd64
Kubuntu (14.04) works; cross-compiling on 64-bit Linux fails due to nonexistent .so symlinks works*
Fedora untested untested
openSUSE untested untested
Arch Linux untested untested
Mandriva (TODO choose between PCLinuxOS and Mageia - it appears the original Mandriva is either dead or nonfree and I would rather choose the fork that structures packages identically for parity; do they both?) untested untested
Slackware untested untested
Gentoo untested untested

(The above list should cover all the bases of major Linux distributions and variants thereof; I might add a dedicated Debian test later but other than that... suggestions welcome. Kubuntu 64-bit is my main system and the main development platform; the Windows builds are cross-compiled from here. And yes, this also implies I seriously consider a Plan 9 port of the library using libcontrol, though I'm guessing this will blow up in my face due to any possible conflicts between libthread and Go's runtime (I need to see how the Go runtime implements OS threads on Plan 9).)

Contributing

Contributions are welcome. File issues, pull requests, approach me on IRC (pietro10 in #go-nuts; andlabs elsewhere), etc. Even suggestions are welcome: while I'm mainly drawing from my own GUI programming experience, everyone is different. I have received emails, however I am not likely to see those right away, so I don't suggest contacting me by email if your communication is urgent.

If you want to dive in, read implementation.md: this is a description of how the library works. (Feel free to suggest improvements to this as well.) The other .md files in this repository contain various development notes.

Please suggest documentation improvements as well.