[Openmcl-devel] Lisp User Interface LUI (was: Currency Converter Example)

Alexander Repenning ralex at cs.colorado.edu
Fri Jan 2 19:30:55 UTC 2009


This may be a good moment to discuss some of the ideas regarding the  
creation of LUI, the "Lisp User Interface as a cross platform, but Mac  
first" open source GUI tool.

At this point a very early prototype exists for CCLmac Intel/PPC with  
classes implemented in Cocoa including: buttons, windows, sliders,  
labels, editable text, images, sound, speech, Web browser view,  
OpenGL, ..

The main question is how to bring this to Windows or more specifically  
to CCL windows. Who has some ideas, time to hack stuff, experience  
with Windows lisp hacking etc. Some ideas tossed around so far are:  
Cocotron, GNUstep, native win32, .NET,

The initial implementation of the core GUI classes was quite simple  
and short (single short file) in Cocoa with CCL. Thank you Clozure for  
the nice Cocoa Objective-C integration!

Some fundamental ideas of LUI are:
- separation of platform specific and independent code: write platform  
independent code or create specific Cocoa based extensions
- separation of procedural (Lisp) and declarative (XML syntax but it  
is really Lisp: X-expressions http://www.cs.colorado.edu/~ralex/papers/PDF/X-expressions.pdf) 
  GUI information
- layout managers: interfaces that stretch and don't need, but do  
allow, hardcoded coordinates/sizes. In the example below the window  
can be stretched updating the size of the editable fields.



;;; ------- Here is the complete code to Currency Converter in LUI:
;; editable numbers contain valid numbers and have number, instead of  
string, setters/getters


(defmethod CONVERT-CURRENCY-ACTION ((w application-window) (Button  
button))
   (setf (value (view-named w "amount"))
         (* (value (view-named w "rate"))
            (value (view-named w "dollars")))))


<application-window title="Currency Converter" width="300" height="180">
   <column align="stretch" valign="stretch" padding="9">
     <row align="stretch" minimize="vertical" valign="bottom">
      <label text="Exchange Rate per $1:" align="right" flex="2"/>
      <editable-number name="rate" text="1.0" flex="1"/>
     </row>
     <row align="stretch" minimize="vertical" valign="bottom">
      <label text="Dollars to Convert:" align="right" flex="2"/>
      <editable-number name="dollars" text="1.0" flex="1"/>
     </row>
     <row align="stretch" minimize="vertical" valign="bottom">
      <label text="Amount in the other Currency:" align="right"  
flex="2"/>
      <editable-number  name="amount" text="1.0" flex="1"/>
     </row>
     <row align="right" valign="bottom" vflex="1">
       <button text="Convert" action="convert-currency-action" default- 
button="true"/>
     </row>
   </column>
</application-window>






;;--------  Example mixing 2D and 3D:



;; complete code here:

(defclass TRIANGLE-OPENGL-DIALOG (opengl-dialog)
())

;; the "#_" syntax needs to go to make this more platform  
independent,  readable and symbol completable
(defmethod DRAW ((Self triangle-opengl-dialog))
(#_glBegin #$GL_TRIANGLES)
   (#_glColor3f (value (view-named (window Self) "red")) 0.0 0.0)
   (#_glVertex3f 0.0 0.6 0.0)
   (#_glColor3f 0.0 (value (view-named (window Self) "green")) 0.0)
   (#_glVertex3f -0.6 -0.3 0.0)
   (#_glColor3f 0.0 0.0 (value (view-named (window Self) "blue")))
   (#_glVertex3f 0.6 -0.3 0.0)
(#_glEnd))


(defmethod ADJUST-VERTEX-COLOR-ACTION ((W application-window) (S  
slider))
   ;; openGL view update
   (display (view-named W "opengl"))
   (display (view-named W "opengl2"))
   (display (view-named W "opengl3"))
   ;; labels update
   (setf (text (view-named W "red label")) (format nil "~,2F" (value  
(view-named W "red"))))
   (setf (text (view-named W "green label")) (format nil "~,2F" (value  
(view-named W "green"))))
   (setf (text (view-named W "blue label")) (format nil "~,2F" (value  
(view-named W "blue")))))


<application-window title="OpenGL 3D" margin="12" width="300"  
height="300">
<column align="stretch" valign="stretch">
   <row minimize="vertical" align="stretch" valign="middle">
      <label text="red" align="right" width="50"/>
      <slider name="red" action="adjust-vertex-color-action" max- 
value="1.0" flex="1"/>
      <label text="0.00" name="red label" width="40"/>
   </row>
   <row minimize="vertical" align="stretch" valign="middle">
      <label text="green" align="right" width="50"/>
      <slider name="green" action="adjust-vertex-color-action" max- 
value="1.0" flex="1"/>
      <label text="0.00" name="green label" width="40"/>
   </row>
   <row minimize="vertical" align="stretch" valign="middle">
      <label text="blue" align="right" width="50"/>
      <slider name="blue" action="adjust-vertex-color-action" max- 
value="1.0" flex="1"/>
      <label text="0.00" name="blue label" width="40"/>
   </row>
   <spacer height="12"/>
   <triangle-opengl-dialog name="opengl" vflex="1"/>
   <spacer height="12"/>
   <row align="stretch" valign="stretch" vflex="2">
     <triangle-opengl-dialog name="opengl2" flex="1"/>
     <spacer height="12" width="12"/>
     <triangle-opengl-dialog name="opengl3" flex="1"/>
   </row>
</column>
</application-window>


Happy New Year,

Alex


Prof. Alexander Repenning

University of Colorado
Computer Science Department
Boulder, CO 80309-430

vCard: http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20090102/8235a26b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Clozure CLScreenSnapz001.png
Type: image/png
Size: 15737 bytes
Desc: not available
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20090102/8235a26b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic.tiff
Type: image/tiff
Size: 32326 bytes
Desc: not available
URL: <http://lists.clozure.com/pipermail/openmcl-devel/attachments/20090102/8235a26b/attachment.tiff>


More information about the Openmcl-devel mailing list