Skip to content

Clojure GUI utility. This repository is *deprecated*, see mummi instead.

License

Notifications You must be signed in to change notification settings

jonasseglare/signe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THIS REPOSITORY IS DEPRECATED

Please see my other repository instead, www.github.com/jonasseglare/mummi, and the examples in mummi/test/mummi/signe/swing_test.clj. It is much easier to use

signe

Signe is a minimal library that bridges the gap between the functional programming style of Clojure and stateful object oriented GUI libraries such as Java Swing. The goal is to eliminate the complexity and spaghetti code that object-oriented GUI programming can easily lead to, and separate the user interface from the domain model, such that the domain model is unaware of the user interface. The domain model can be a single immutable clojure data structure wrapped inside an atom. In practice, it implements the observer design pattern, so that whenever the domain model is replaced by a new version of itself, e.g. through an atomic swap, only functions that are connected with GUI elements that need to be refreshed are called. This library is not bound to a particular GUI library, but is designed to work well with Swing. For Swing, there is also the Seesaw library that provides a nice wrapper and syntactic sugar to hide the Java interop calls. Signe offers functionality orthogonal to that of Seesaw and will play well with or without it.

The functionality of this library is best appreciated by taking a look at the examples in examples.clj.

Usage

Here are some very useful functions and macros. Since this is a very small library, the user will probably not need any other functions in order to use the library.

See examples.clj for how they are used in practice.

Useful Functions

(make-monitor state-atom)

Creates a new instance of type Monitor from an atom that wraps the domain model.

(only-register monitor funcall updater & args)

registers a function updater that will be called whenever the call chain defined by funcall evaluates to a different value than before, when applied to the model. monitor is the monitor object that monitors the model for changes. The updater function takes a record of type ModelChange which contains a state-field, and returns the next hidden state. The initial state is nil, or an optional value from args.

(register-and-update monitor funcall updater & args)

Works like the function only-register, but also calls the updater function once. Usually, you will want to use this function over only-register, so that newly instantiated widgets get initialized.

Useful Macros

(call-chain expr)

A macro used to define a chain of function calls. Evaluates to a Funcall. If expr is a keyword :obj, it will evaluate to an empty Funcall object. Otherwise it will recursively build a function call chain.

Installation

With leiningen, add [signe "0.1.0-SNAPSHOT"] to :dependencies your project.clj file, for instance

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [signe "0.1.0-SNAPSHOT"]]

License

Copyright © 2014 Jonas Östlund

Distributed under the Eclipse Public License version 1.0.

About

Clojure GUI utility. This repository is *deprecated*, see mummi instead.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages