Mousetrap is a GUI library for Julia. It, and its stand-alone C++-component of the same name, fully wrap GTK4 (which is written in C), vastly simplifying its interface to improve ease-of-use without sacrificing flexibility.
It aims to give developers of all skill levels the tools to start creating complex GUI applications with little time and effort.
Note: Mousetrap is under active development. While backwards-compatibility for all future releases can already be guaranteed, stability, portability, and quality of the documentation may be affected.
Consider participating in the development by opening an issue when you encounter an error or bug.
- Introduction
- Features
- Planned Features
- Showcase
3.1 Hello World
3.2 Swapping between Light- and Dark Themes
3.3 Opening a File Explorer Dialog
3.4 Rendering a Rectangle using OpenGL
3.5 Reacting to Mouse / Touchscreen Events - Supported Platforms
- Installation
- Documentation
- Credits & Donations
- Contributing
- License
- Create complex GUI application for Linux, Windows, and MacOS
- Choose from over 40 different kinds of pre-made widgets, or create your own!
- Supports mice, keyboards, touchscreens, touchpads, and stylus devices
- Image processing facilities, well-suited for image manipulation programs
- Fully abstracted OpenGL interface, allows for high-performance, hardware-accelerated rendering of custom shapes / shaders
- Hand-written manual and extensive documentation: every exported symbol is documented
Inn order of priority, highest first:
- Simplify installation process to
] add mousetrap
- Implement installation of .desktop files on end-user computers
- Implement drag-and-drop for files, images, and widgets
- Allow retrieving a widget from its container, for this to be possible the widgets type has to be stored C-side
- Allow filtering and searching of selectable widget containers such as
ListView
andColumnView
- Allow adding custom signals that use the GLib marshalling system
- Allow bundling of mousetrap apps, their resources, and all their dependencies into a portable C-executable
- Make all functions that modify the global state thread-safe
- Expose the full
GtkTextView
andGtkSourceView
interface, makingTextView
a fully feature text editor
using Mousetrap
main() do app::Application
window = Window(app)
set_child!(window, Label("Hello World!"))
present!(window)
end
set_current_theme!(app, THEME_DEFAULT_LIGHT)
file_chooser = FileChooser()
on_accept!(file_chooser) do self::FileChooser, files
println("selected files: $files")
end
present!(file_chooser)
render_area = RenderArea()
rectangle = Rectangle(Vector2f(-0.5, 0.5), Vector2f(1, 1))
add_render_task!(render_area, RenderTask(rectangle))
function on_click(::ClickEventController, x, y)
println("Click registered at ($x, $y)") # in pixels
end
click_controller = ClickEventController()
connect_signal_clicked!(on_click, click_controller)
add_controller!(window, click_controller)
Click registered at (367.5, 289.0)
Platform | Basic GUI Component | OpenGL Rendering Component |
---|---|---|
Linux (64-bit) | ✓ |
✓ |
Linux (32-bit) | ✓ |
✕ |
Windows (64-bit) | ✓ |
✓ |
Windows (32-bit) | ✕ |
✕ |
MacOS | ✓ |
✕ |
FreeBSD | ✓ |
✓ |
In the Julia REPL, execute:
import Pkg
begin
try Pkg.rm("mousetrap") catch end
Pkg.add(url="https://github.com/Clemapfel/mousetrap_windows_jll")
Pkg.add(url="https://github.com/Clemapfel/mousetrap_linux_jll")
Pkg.add(url="https://github.com/Clemapfel/mousetrap_apple_jll")
Pkg.add(url="https://github.com/Clemapfel/mousetrap.jl")
end
Mousetrap was renamed from mousetrap.jl
to Mousetrap.jl
in version 0.2.0, which is why we have to remove the old package to assure compatibility.
We can confirm everything works by pressing ]
while in the REPL to enter Pkg
mode, then:
test Mousetrap
At the end it should say Mousetrap tests passed
.
Note: On Windows, some
GLib
log messages regarding dbus connections and may appear during testing. These do not indicate a problem, as long as at the end of the testing suite it saysmousetrap tests passed
.
Documentation is available here. This includes a tutorial on how to get started using mousetrap, a manual introducing users to mousetrap and GUI programming in general, as well as an index of all classes, enums, and functions.
The Julia and C++ component of mousetrap were designed and implemented by C.Cords.
Mousetrap was created with no expectation of compensation and made available for free. Consider donating to reward past work and support the continued development of this library:
The goal is for mousetrap to be 100% stable and flawless when Julia static compilation finishes development. Static compilation and the lack of fully featured, easy-to-use GUI libraries are currently the largest factors as to why Julia is ill-suited for front-end development. Mousetrap aims to address this.
Consider contributing by taking on one of these bounty projects:
I am unable to offer any monetary reward, but I'd be happy to credit you as a co-author of mousetrap on GitHub and as a Julia package author if your work contributes significantly to the implementation of one of these three bounty projects.
Other than this, consider participating in development by opening an issue if you encounter a bug, crash, or missing feature.
Thank you for your consideration.
C.
The current and all past version of mousetrap, including any text or assets used in mousetraps documentation, are licensed under GNU Lesser General Public License (Version 3.0). This means it can be used in both free, open-source, as well as commercial, closed-source software.