Author: maustin
Date: Tue Nov 8 02:52:20 2005
New Revision: 10361
Added:
trunk/libraries/inertia/inertia-effects.dylan (contents, props changed)
trunk/libraries/inertia/inertia-shapes/
trunk/libraries/inertia/inertia-shapes/shape-polygon.dylan (contents,
props changed)
trunk/libraries/inertia/inertia-shapes/shape-rectangle.dylan (contents,
props changed)
trunk/libraries/inertia/inertia-shapes/shape-shape-menu.dylan (contents,
props changed)
trunk/libraries/inertia/inertia-widgets/
trunk/libraries/inertia/inertia-widgets/widget-button.dylan (contents,
props changed)
trunk/libraries/inertia/inertia-widgets/widget-shape-editor.dylan
(contents, props changed)
trunk/libraries/inertia/inertia-widgets/widget-window.dylan (contents,
props changed)
trunk/libraries/inertia/tests/layout.ui
Modified:
trunk/libraries/inertia/Makefile
trunk/libraries/inertia/inertia-events.dylan
trunk/libraries/inertia/inertia-exports.dylan
trunk/libraries/inertia/inertia-main.dylan
trunk/libraries/inertia/inertia-shapes.dylan
trunk/libraries/inertia/inertia-widgets.dylan
trunk/libraries/inertia/inertia.dev
trunk/libraries/inertia/inertia.layout
trunk/libraries/inertia/inertia.lid
trunk/libraries/inertia/tests/inertia-test-exports.dylan
trunk/libraries/inertia/tests/inertia-test-main.dylan
Log:
job: 7269
A bit of reorganization, beginnings of persistent objects
Modified: trunk/libraries/inertia/Makefile
==============================================================================
--- trunk/libraries/inertia/Makefile (original)
+++ trunk/libraries/inertia/Makefile Tue Nov 8 02:52:20 2005
@@ -8,8 +8,20 @@
(cd tests; d2c -L.. inertia-test.lid)
inertia.lib.du: inertia.lid inertia-exports.dylan inertia-gl-utils.dylan
inertia-geometry.dylan \
- inertia-shapes.dylan inertia-events.dylan
inertia-effects.dylan inertia-widgets.dylan inertia-main.dylan
+ inertia-shapes.dylan \
+ inertia-shapes/shape-polygon.dylan \
+ inertia-shapes/shape-rectangle.dylan \
+ inertia-shapes/shape-shape-menu.dylan \
+ inertia-events.dylan inertia-effects.dylan \
+ inertia-widgets.dylan \
+ inertia-widgets/widget-shape-editor.dylan \
+ inertia-widgets/widget-button.dylan \
+ inertia-widgets/widget-window.dylan \
+ inertia-main.dylan
d2c inertia.lid
+
+test: tests/inertia-test
+ (cd tests; ./inertia-test)
clean:
rm -rf *.mak *.lib.du *.lo *.o *.la *.a *.c .libs
Added: trunk/libraries/inertia/inertia-effects.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-effects.dylan Tue Nov 8 02:52:20 2005
@@ -0,0 +1,63 @@
+module: inertia-shapes
+synopsis: Core shape effects
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// inertia-effects.dylan
+//
+
+define constant <effect-layer> = one-of (#"below", #"inside", #"above");
+
+//
----------------------------------------------------------------------------------------------
//
+// all class definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define class <shape-effect> (<object>)
+ slot effect-layer :: one-of (#"below", #"inside", #"above");
+end;
+
+define class <gradient-effect> (<shape-effect>)
+ inherited slot effect-layer = #"inside";
+ slot gradient-angle = 0.0, init-keyword: angle:;
+ slot gradient-color0 = #[0.0, 0.0, 0.0, 0.0];
+ slot gradient-color1 = #[0.0, 0.0, 0.0, 1.0];
+end;
+
+define class <shadow-effect> (<shape-effect>)
+ inherited slot effect-layer = #"below";
+end;
+
+//
----------------------------------------------------------------------------------------------
//
+// shape-effect methods definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define method draw-effect (shape :: <shape>, effect :: <gradient-effect>)
+ glBegin ($GL-QUADS);
+ glColor (1.0, 1.0, 1.0, 0.6); glVertex ( 0.0,
0.0, 0.0);
+ glColor (1.0, 1.0, 1.0, 0.0); glVertex ( 0.0,
shape.shape-height / 2.0, 0.0);
+ glColor (1.0, 1.0, 1.0, 0.0); glVertex (shape.shape-width,
shape.shape-height / 2.0, 0.0);
+ glColor (1.0, 1.0, 1.0, 0.6); glVertex (shape.shape-width,
0.0, 0.0);
+
+ glColor (0.0, 0.0, 0.0, 0.0); glVertex ( 0.0,
shape.shape-height / 2.0, 0.0);
+ glColor (0.0, 0.0, 0.0, 0.05); glVertex ( 0.0,
shape.shape-height, 0.0);
+ glColor (0.0, 0.0, 0.0, 0.05); glVertex (shape.shape-width,
shape.shape-height, 0.0);
+ glColor (0.0, 0.0, 0.0, 0.0); glVertex (shape.shape-width,
shape.shape-height / 2.0, 0.0);
+ glEnd ();
+end;
+
+define method draw-effect (shape :: <shape>, effect :: <shadow-effect>)
+ glPushMatrix ();
+ glColor (0.0, 0.0, 0.0, 0.03);
+ glTranslate (3.0, 0.0, 0.0);
+ draw-content (shape, shape);
+ glTranslate (-3.0, 3.0, 0.0);
+ draw-content (shape, shape);
+ glTranslate (3.0, 2.0, 0.0);
+ draw-content (shape, shape);
+ glTranslate (2.0, -2.0, 0.0);
+ draw-content (shape, shape);
+ glPopMatrix ();
+end;
+
Modified: trunk/libraries/inertia/inertia-events.dylan
==============================================================================
--- trunk/libraries/inertia/inertia-events.dylan (original)
+++ trunk/libraries/inertia/inertia-events.dylan Tue Nov 8 02:52:20 2005
@@ -60,7 +60,7 @@
define method send-event (shape :: <shape>, event :: <event>, data :: <object>)
=> (result :: <shape>)
- format-out ("send-event (%=, %=, %=)\n", shape, event, data);
+ //format-out ("send-event (%=, %=, %=)\n", shape, event, data);
shape;
end;
@@ -81,9 +81,10 @@
next-method ();
end;
-define method send-event (shape :: <shape>, event :: <mouse-event>, button ::
<mouse-button>)
+define method send-event
+ (shape :: <shape>, event :: <mouse-event>, button :: <mouse-button>)
=> (result :: <shape>)
- format-out ("send-event (%=, %=, %=)\n", shape, event, button);
+ //format-out ("send-event (%=, %=, %=)\n", shape, event, button);
block (return)
for (child in shape.children)
let x = event.origin.point-x - child.origin.point-x;
@@ -99,7 +100,6 @@
if (((new-x / child.z-scale > 50.0) & (new-x / child.z-scale < 60.0))
& (new-y > -5 & new-y < 5))
if (instance? (event, <mouse-down-event>))
- format-out ("gripper\n");
child.mouse-mode := #"gripper";
event.origin := new-origin;
//return (send-event (child, event));
@@ -131,7 +131,6 @@
=> (result :: <shape>)
let shape = next-method ();
if (screen.grabbed-shape ~= #f & shape ~= screen.grabbed-shape)
- format-out ("here\n");
on-mouse-event (screen.grabbed-shape, make (<mouse-exit-event>, origin:
event.origin), button);
screen.grabbed-shape := shape;
on-mouse-event (screen.grabbed-shape, make (<mouse-enter-event>, origin:
event.origin), button);
Modified: trunk/libraries/inertia/inertia-exports.dylan
==============================================================================
--- trunk/libraries/inertia/inertia-exports.dylan (original)
+++ trunk/libraries/inertia/inertia-exports.dylan Tue Nov 8 02:52:20 2005
@@ -10,6 +10,7 @@
define library inertia
use common-dylan;
+ use string-extensions;
use random;
use io;
use transcendental;
@@ -24,8 +25,11 @@
//
----------------------------------------------------------------------------------------------
//
define module inertia
- use common-dylan;
+ use common-dylan; //, rename: {method-definer => dylan-method-definer};
use simple-io;
+ use streams;
+ use character-type;
+ //use string-conversions;
use opengl;
use opengl-glu;
use opengl-glut;
@@ -34,11 +38,20 @@
use inertia-shapes;
export *tess-object*, *screen*, *menu*;
+ export
+ <field>,
+ <persistent>,
+ fields,
+ build-object;
+
+ export table, make-from-symbol;
+ export *function-table*;
end;
define module inertia-gl-utils
use common-dylan;
use simple-io;
+ use streams;
use opengl;
use opengl-glu;
use opengl-glut;
@@ -80,11 +93,15 @@
shape-width, shape-height, shape-width-setter, shape-height-setter,
add-child, contains-point?, send-event, on-mouse-event,
draw-shape, draw-content, draw-outline, draw-overlay,
+ fill-color, reshape,
<polygon>, <spinning-polygon>,
+ <button>,
+ on-click,
<rectangle>,
<screen>,
mouse-origin, mouse-origin-setter,
<shape-menu>,
+ <widget>,
<shape-editor>,
<push-button>,
<window>;
Modified: trunk/libraries/inertia/inertia-main.dylan
==============================================================================
--- trunk/libraries/inertia/inertia-main.dylan (original)
+++ trunk/libraries/inertia/inertia-main.dylan Tue Nov 8 02:52:20 2005
@@ -7,10 +7,32 @@
//
// inertia-main.dylan
//
-
+/*
+define macro method-definer
+ { define method (?parameters:*)
+ ?:body
+ end }
+ => { define method (?parameters)
+ ?body
+ end }
+end;
+*/
+
+define variable *function-table* = make (<table>);
+/*
+define macro method-definer
+ { define ?adjectives:* method ?:name ?rest:* end }
+ => { dylan-method-definer( ?adjectives method ?name ?rest end );
+ *function-table*[?"name"] := ?name }
+end;
+*/
c-include("/usr/include/w32api/GL/glu.h");
-define variable reshape :: <function> = callback-method (width :: <integer>,
height :: <integer>) => ();
+define generic make-from-symbol (symbol :: <symbol>, #rest init-args, #key);
+
+define method make-from-symbol (symbol :: <symbol>, #rest init-args, #key) end;
+
+define variable reshape-callback :: <function> = callback-method (width ::
<integer>, height :: <integer>) => ();
//define variable reshape = callback-method (width :: <integer>, height ::
<integer>) => ();
glMatrixMode ($GL-PROJECTION);
glLoadIdentity ();
@@ -67,6 +89,102 @@
define variable polygon-begin :: <function> = callback-method (mode ::
<integer>) => ();
end;
+// ------------------------------------------------------------------------- //
+
+define class <persistent> (<object>)
+ each-subclass slot fields = make (<table>);
+end;
+
+define method table (#rest args, #key, #all-keys)
+ let table = make(<table>);
+ for (i from 0 below args.size by 2)
+ table[args[i]] := args[i + 1];
+ end;
+ table;
+end;
+
+define method duplicate (string :: <string>, count :: <integer>)
+ let stream = make (<string-stream>, direction: #"output");
+ while (count ~= 0)
+ write (stream, string);
+ count := count - 1;
+ end;
+ stream-contents (stream);
+end;
+
+define class <field> (<object>)
+ slot category = "general", init-keyword: category:;
+ slot getter, init-keyword: getter:;
+ slot setter, init-keyword: setter:;
+end;
+
+define method build-object (object :: <persistent>, filename :: <string>, #key)
+ let stream = make (<file-stream>, locator: filename, direction: #"input");
+ build-object (object, stream);
+end;
+
+define method build-object (object :: <persistent>, stream :: <stream>, #key
level = 0)
+ block (return)
+ let name = #f;
+ let value = #f;
+
+ while (~stream-at-end? (stream))
+ block (break)
+ while (whitespace? (peek (stream)))
+ read (stream, 1);
+ end;
+
+ if (peek (stream) == '#')
+ read-line (stream);
+ end;
+
+ let data = read-to (stream, ' ');
+ if (data = "object")
+ let data = read-to (stream, ' ');
+ let name = as(<symbol>, copy-sequence (data, start: 0, end:
data.size - 1));
+ let value = read-line (stream);
+ format-out ("%sobject [%s] [%s]\n", duplicate (" ", level * 2),
name, value);
+ let child = make-from-symbol (as(<symbol>, value));
+ build-object (child, stream, level: level + 1);
+ *function-table*[name] := child;
+ add-child (object, child);
+ break ();
+ elseif (data = "end")
+ return ();
+ end;
+
+ name := as(<symbol>, copy-sequence (data, start: 0, end: data.size -
1));
+
+ let data = read-line (stream);
+ value := case
+ digit? (data[0]) => string-to-float (data);
+ data[0] == '\"' => copy-sequence (data, start: 1, end: data.size -
1);
+ alpha? (data[0]) => as(<symbol>, data);
+ end;
+
+ format-out ("%s[%s] [%s]\n", duplicate (" ", level * 2), name, value);
+ object.fields[name].setter (value, object);
+ end block;
+ end while;
+ cleanup
+ close (stream);
+ exception (xerror :: <error>)
+ //apply (format-out, xerror.condition-format-string,
xerror.condition-format-arguments);
+ end;
+end;
+
+define method asdf (abc)
+ abc * 2;
+end;
+
+*function-table*[#"asdf"] := asdf;
+
+define method perform (method-name :: <symbol>, #rest args)
+ apply (*function-table*[method-name], args);
+end;
+
+// ------------------------------------------------------------------------- //
+
begin
glut-init ();
glutInitDisplayMode ($GLUT-RGBA + $GLUT-DEPTH + $GLUT-DOUBLE +
$GLUT-STENCIL);
@@ -76,7 +194,7 @@
glutCreateWindow ("Dylan Inertia");
glutDisplayFunc (display);
- glutReshapeFunc (reshape);
+ glutReshapeFunc (reshape-callback);
glutPassiveMotionFunc (passive-motion);
glutMouseFunc (mouse-callback);
glutMotionFunc (motion-callback);
@@ -85,6 +203,7 @@
glEnable ($GL-BLEND); glBlendFunc ($GL-SRC-ALPHA, $GL-ONE-MINUS-SRC-ALPHA);
glEnable ($GL-LINE-SMOOTH); glLineWidth (1.5s0);
+ glEnable ($GL-POINT-SMOOTH); glPointSize( 1.5s0);
define variable *tess-object* = gluNewTess ();
@@ -95,5 +214,7 @@
define variable *screen* = make (<screen>, width: 1024.0, height: 768.0);
define variable *menu* = make (<shape-menu>, width: 100.0, height: 180.0);
add-child (*screen*, *menu*);
+
+ format-out ("%=\n", perform (#"asdf", 10));
end;
Modified: trunk/libraries/inertia/inertia-shapes.dylan
==============================================================================
--- trunk/libraries/inertia/inertia-shapes.dylan (original)
+++ trunk/libraries/inertia/inertia-shapes.dylan Tue Nov 8 02:52:20 2005
@@ -10,25 +10,33 @@
define variable *angle* = 0.0;
-//
----------------------------------------------------------------------------------------------
//
-// all class definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define class <shape> (<object>)
+// ------------------------------------------------------------------------- //
+// class definitions
+// ------------------------------------------------------------------------- //
+
+//define open class <shape> (<object>)
+define open class <shape> (<persistent>)
+ inherited slot fields = table (
+ #"shape-left", make (<field>, getter: shape-left, setter:
shape-left-setter),
+ #"shape-top", make (<field>, getter: shape-top, setter: shape-top-setter)
+ );
+
slot delegate :: subclass(<shape>), init-keyword: delegate:;
slot children = make (<deque>);
slot parent :: false-or (<shape>);
slot origin = make(<point>, x: 0.0, y: 0.0);
- slot %extent = make(<point>, x: 100.0, y: 100.0);
- slot z-angle :: <double-float> = 0.0;
+ slot extent = make(<point>, x: 100.0, y: 100.0), setter: %extent-setter;
+ slot z-angle :: <double-float> = 0.0, init-keyword: angle:;
slot z-scale :: <double-float> = 1.0;
slot mouse-mode = #"normal";
- slot fill-color :: <vector> = vector (random-float (0.5) + 0.5, random-float
(0.5) + 0.5, random-float (0.5) + 0.5, 0.9);
+ slot fill-color :: <vector> = vector (random-float (0.5) + 0.5,
+ random-float (0.5) + 0.5,
+ random-float (0.5) + 0.5, 0.9);
slot line-color = vector (0.0, 0.0, 0.0, 1.0);
slot line-width = 3.0;
slot effects :: <vector> = #[];
slot reshape = #[#"none", #"none"], init-keyword: reshape:;
- virtual slot extent :: <point>;
+
virtual slot shape-left :: <double-float>;
virtual slot shape-top :: <double-float>;
virtual slot shape-width :: <double-float>;
@@ -37,32 +45,13 @@
define method class-name (shape :: <shape>) "<shape>" end;
-define class <container> (<shape>)
-end;
-
-define class <polygon> (<shape>)
- slot data = #[
- #[0.0, 0.0, 0.0], #[15.0, 50.0, 0.0], #[0.0, 100.0, 0.0], #[50.0,
85.0, 0.0],
- #[ 100.0, 100.0, 0.0], #[ 85.0, 50.0, 0.0], #[100.0, 0.0, 0.0],
#[50.0, 15.0, 0.0]
- ];
- slot data2 = #[
- #[-50.0, -50.0, 0.0], #[-35.0, 0.0, 0.0], #[-50.0, 50.0, 0.0], #[0.0,
35.0, 0.0],
- #[ 50.0, 50.0, 0.0], #[ 35.0, 0.0, 0.0], #[50.0, -50.0, 0.0], #[0.0,
-35.0, 0.0]
- ];
- slot vertices;
-end;
+define open generic draw-overlay (shape :: <shape>, delegate :: <shape>);
-define class <spinning-polygon> (<polygon>)
- inherited slot effects = vector (make (<shadow-effect>));
-end;
+// ------------------------------------------------------------------------- //
-define method class-name (polygon :: <polygon>) "<polygon>" end;
-
-define class <rectangle> (<shape>)
+define class <container> (<shape>)
end;
-define method class-name (rectangle :: <rectangle>) "<rectangle>" end;
-
define class <screen> (<rectangle>)
inherited slot fill-color = vector (1.0, 1.0, 1.0, 1.0);
slot mouse-origin :: <point>;
@@ -71,30 +60,11 @@
define method class-name (screen :: <screen>) "<screen>" end;
-define class <shape-menu-center> (<rectangle>)
- inherited slot fill-color = vector (0.5, 0.5, 0.5, 0.9);
- inherited slot line-width = 1.0;
- keyword width: = 120.0;
- keyword height: = 120.0;
-end;
+// ------------------------------------------------------------------------- //
+// methods definitions
+// ------------------------------------------------------------------------- //
-define class <shape-menu> (<rectangle>)
- inherited slot fill-color = vector (0.5, 0.5, 0.5, 0.9);
- inherited slot line-width = 1.0;
-end;
-
-define method initialize (menu :: <shape-menu>, #rest init-args, #key) => ()
- next-method ();
- add-child (menu, make (<shape-menu-center>, left: menu.shape-width / 2.0 -
60.0, top: menu.shape-height / 2.0 - 60.0));
-end;
-
-define method class-name (menu :: <shape-menu>) "<shape-menu>" end;
-
-//
----------------------------------------------------------------------------------------------
//
-// shape methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-// - slot getters and setters
------------------------------------------------------------------- //
+// - slot getters and setters ---------------------------------------------- //
define method shape-left (shape :: <shape>) => (result :: <double-float>)
shape.origin.point-x;
@@ -121,34 +91,32 @@
define method shape-width-setter (value :: <double-float>, shape :: <shape>)
=> (result :: <double-float>)
- shape.extent.point-x := value;
- // send <shape-reshape-event>
+ //shape.extent.point-x := value;
+ shape.extent := make (<point>, x: value, y: shape.shape-height);
+ shape.shape-width;
end;
define method shape-height (shape :: <shape>)
=> (result :: <double-float>)
shape.extent.point-y;
- // send <shape-reshape-event>
end;
define method shape-height-setter (value :: <double-float>, shape :: <shape>)
=> (result :: <double-float>)
- shape.extent.point-y := value;
-end;
-
-define method extent (shape :: <shape>)
- shape.%extent;
+ //shape.extent.point-y := value;
+ shape.extent := make (<point>, x: shape.shape-width, y: value);
+ shape.shape-height;
end;
-define method extent-setter (extent :: <point>, shape :: <shape>)
+define method extent-setter (value :: <point>, shape :: <shape>)
=> (result :: <point>)
for (child in shape.children)
- send-event (child, make (<parent-reshape-event>), extent - shape.%extent);
+ send-event (child, make (<parent-reshape-event>), value - shape.extent);
end;
- shape.%extent := extent;
+ shape.%extent := value;
end;
-//
----------------------------------------------------------------------------------------------
//
+// ------------------------------------------------------------------------- //
define method screen-origin (shape :: <shape>)
shape.origin + shape.parent.screen-origin;
@@ -158,19 +126,29 @@
screen.origin;
end;
-//
----------------------------------------------------------------------------------------------
//
+// ------------------------------------------------------------------------- //
define method add-child (shape :: <shape>, child :: <shape>) => ()
child.parent := shape;
shape.children := add! (shape.children, child);
end;
+define method shape-add-child (shape :: <shape>, child :: <shape>) => ()
+ child.parent := shape;
+ shape.children := add! (shape.children, child);
+end;
+
define method remove-child (shape :: <shape>, child :: <shape>) => ()
child.parent := shape;
shape.children := remove! (shape.children, child);
end;
-// - drawing routines
--------------------------------------------------------------------------- //
+define method shape-remove-child (shape :: <shape>, child :: <shape>) => ()
+ child.parent := shape;
+ shape.children := remove! (shape.children, child);
+end;
+
+// - drawing routines ------------------------------------------------------ //
define method draw-shape (shape :: <shape>) => ()
glPushMatrix ();
@@ -188,8 +166,10 @@
glStencilFunc ($GL-ALWAYS, #x1, #x1);
glStencilOp ($GL-REPLACE, $GL-REPLACE, $GL-REPLACE);
- glColor (shape.fill-color[0], shape.fill-color[1], shape.fill-color[2],
shape.fill-color[3]);
- draw-content (shape, if (slot-initialized? (shape, delegate))
shape.delegate else shape end);
+ glColor (shape.fill-color[0], shape.fill-color[1], shape.fill-color[2],
+ shape.fill-color[3]);
+ draw-content (shape, if (slot-initialized? (shape, delegate))
shape.delegate
+ else shape end);
glStencilFunc ($GL-EQUAL, #x1, #x1);
glStencilOp ($GL-KEEP, $GL-KEEP, $GL-KEEP);
@@ -206,11 +186,14 @@
draw-effects (shape, #"above");
- glColor (shape.fill-color[0], shape.fill-color[1], shape.fill-color[2],
shape.fill-color[3]);
- draw-overlay (shape, if (slot-initialized? (shape, delegate))
shape.delegate else shape end);
+ glColor (shape.fill-color[0], shape.fill-color[1], shape.fill-color[2],
+ shape.fill-color[3]);
+ draw-overlay (shape, if (slot-initialized? (shape, delegate))
shape.delegate
+ else shape end);
glLineWidth (as(<single-float>, shape.line-width));
- glColor (shape.line-color[0], shape.line-color[1], shape.line-color[2],
shape.line-color[3]);
+ glColor (shape.line-color[0], shape.line-color[1], shape.line-color[2],
+ shape.line-color[3]);
draw-outline (shape);
glPopMatrix ();
glPopMatrix ();
@@ -224,234 +207,20 @@
define constant $PI = 3.14159;
-//
----------------------------------------------------------------------------------------------
//
+// ------------------------------------------------------------------------- //
define method draw-content (shape :: <shape>, delegate :: <shape>) => () end;
define method draw-overlay (shape :: <shape>, delegate :: <shape>) => () end;
define method draw-outline (shape :: <shape>) => () end;
-define method contains-point? (shape :: <shape>, point :: <point>) => (result
:: <boolean>)
+define method contains-point? (shape :: <shape>, point :: <point>)
+ => (result :: <boolean>)
#f
end;
-define method on-mouse-event (shape :: <shape>, event :: <mouse-event>, button
:: <mouse-button>)
- format-out ("on-mouse-event (%=, %=, %=)\n", shape, event, button);
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// polygon methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method initialize (polygon :: <polygon>, #rest init-args, #key left =
0.0, top = 0.0) => ()
- //apply (next-method, init-args);
- next-method ();
- format-out ("initialize (<polygon>)\n");
- polygon.shape-left := left;
- polygon.shape-top := top;
- polygon.z-angle := 5.0;
-
- polygon.vertices := map (method (vertex) as(<GLdouble*>, vertex) end,
polygon.data);
-end;
-
-define method draw-content (shape :: <shape>, polygon :: <polygon>) => ()
- gluBeginPolygon (*tess-object*);
- for (vertex in polygon.vertices)
- gluTessVertex (*tess-object*, vertex, as(<GLvoid*>, vertex));
- end;
- gluEndPolygon (*tess-object*);
-end;
-
-define method draw-outline (polygon :: <polygon>) => ()
- glBegin ($GL-LINE-LOOP);
- for (vertex in polygon.vertices)
- glVertex (vertex[0], vertex[1], vertex[2]);
- end;
- glEnd ();
-end;
-
-define constant $X = 0;
-define constant $Y = 1;
-define constant $Z = 2;
-
-define method contains-point? (polygon :: <polygon>, point :: <point>) =>
(result :: <boolean>)
- let x = point.point-x; let y = point.point-y;
- let v = polygon.data;
- let inside :: <boolean> = #f;
-
- for (i :: <integer> from 0 below v.size)
- let j :: <integer> = if (i = v.size - 1) 0 else i + 1 end;
- if (((v[i][$Y] <= y) & (v[j][$Y] > y)) | ((v[i][$Y] > y) & (v[j][$Y] <=
y)))
- let vt = (y - v[i][$Y]) / (v[j][$Y] - v[i][$Y]);
- if (x < v[i][$X] + vt * (v[j][$X] - v[i][$X]))
- inside := ~inside;
- end;
- end;
- end;
-
- inside;
-end;
-
-define variable *polygon* = 0;
-define variable *speed* = 10;
-
-define variable xtimer = callback-method (n :: <integer>) => ();
- if (*speed* > 0.01)
- glutTimerFunc (n, xtimer, n);
- *polygon*.z-angle := *polygon*.z-angle + *speed*;
- *speed* := *speed* * 0.9;
- glutPostRedisplay ();
- else
- *speed* := 10;
- end;
-end;
-
-define method on-mouse-event (polygon :: <spinning-polygon>, event ::
<mouse-down-event>, button :: <mouse-button>)
- next-method ();
- *polygon* := polygon;
- glutTimerFunc (10, xtimer, 10);
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// rectangle methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method initialize (rectangle :: <rectangle>, #rest init-args,
- #key left = 0.0, top = 0.0, width = 100.0, height =
100.0) => ()
- apply (next-method, init-args);
- format-out ("initialize (<rectangle>)\n");
- rectangle.shape-left := left;
- rectangle.shape-top := top;
- rectangle.shape-width := width;
- rectangle.shape-height := height;
-end;
-
-define method draw-content (shape :: <shape>, rectangle :: <rectangle>) => ()
- let width/2 = shape.shape-width / 2.0;
- let height/2 = shape.shape-height / 2.0;
-
- glBegin ($GL-QUADS);
- glVertex ( 0.0, 0.0);
- glVertex ( 0.0, shape.shape-height);
- glVertex (shape.shape-width, shape.shape-height);
- glVertex (shape.shape-width, 0.0);
- glEnd ();
-end;
-
-define method draw-outline (rectangle :: <rectangle>) => ()
- let width/2 = rectangle.shape-width / 2.0;
- let height/2 = rectangle.shape-height / 2.0;
- let shape = rectangle;
-
- glBegin ($GL-LINE-LOOP);
- glVertex ( 0.0, 0.0);
- glVertex ( 0.0, shape.shape-height);
- glVertex (shape.shape-width, shape.shape-height);
- glVertex (shape.shape-width, 0.0);
- glEnd ();
-end;
-
-define method contains-point? (rectangle :: <rectangle>, point :: <point>) =>
(result :: <boolean>)
- let width/2 = rectangle.shape-width / 2.0;
- let height/2 = rectangle.shape-height / 2.0;
-
- (point.point-x > 0 & point.point-x < rectangle.shape-width)
- & (point.point-y > 0 & point.point-y < rectangle.shape-height);
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// shape-menu methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method draw-content (shape :: <shape>, menu :: <shape-menu-center>)
- let radius = 60.0;
-
- glPushMatrix ();
- glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
- glBegin ($GL-TRIANGLE-FAN);
- glVertex (0.0, 0.0, 0.0);
- for (angle from 0 to $PI * 2 by $PI / 20.0)
- glVertex (cos (angle) * radius, sin (angle) * radius, 0.0);
- end;
- glVertex (cos (0) * radius, sin (0) * radius, 0.0);
- glEnd ();
-
- glLineWidth (2.0s0);
- glColor (1.0, 1.0, 1.0, 0.7);
-
- glBegin ($GL-LINE-LOOP);
- for (angle from 0 to $PI * 2 by $PI / 20.0)
- glVertex (cos (angle) * radius, sin (angle) * radius, 0.0);
- end;
- glEnd ();
-
- glBegin ($GL-TRIANGLE-FAN);
- glVertex (0.0, 0.0, 0.0);
- for (angle from 0 to $PI * 2 by $PI / 20.0)
- glVertex (cos (angle) * 5.0, sin (angle) * 5.0, 0.0);
- end;
- glVertex (cos (0) * 5.0, sin (0) * 5.0, 0.0);
- glEnd ();
-
- glBegin ($GL-LINE-LOOP);
- for (angle from 0 to $PI * 2 by $PI / 20.0)
- glVertex (cos (angle) * 5.0, sin (angle) * 5.0, 0.0);
- end;
- glEnd ();
-
- glBegin ($GL-LINES);
- glVertex ( cos ($PI * (1.0 / 4.0)) * radius, sin ($PI * (1.0 / 4.0)) *
radius);
- glVertex (-cos ($PI * (1.0 / 4.0)) * radius, -sin ($PI * (1.0 / 4.0)) *
radius);
- glVertex ( cos ($PI * (3.0 / 4.0)) * radius, sin ($PI * (3.0 / 4.0)) *
radius);
- glVertex (-cos ($PI * (3.0 / 4.0)) * radius, -sin ($PI * (3.0 / 4.0)) *
radius);
- glEnd ();
- glPopMatrix ();
-end;
-
-define method draw-overlay (shape :: <shape>, menu :: <shape-menu-center>) =>
()
- next-method ();
- let radius = 60.0;
- glPushMatrix ();
- glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
-
- glColor (1.0, 1.0, 1.0, 1.0);
-
- draw-centered-string ( 0, -40 + 5, "Cut");
- draw-centered-string (-35, 0 + 5, "Copy");
- draw-centered-string ( 35, 0 + 5, "Paste");
- draw-centered-string ( 0, 40 + 5, "Clone");
- glPopMatrix ();
-end;
-
-define method draw-effects (menu :: <shape-menu-center>, layer ::
<effect-layer>) end;
-define method draw-outline (menu :: <shape-menu-center>) end;
-
-//
----------------------------------------------------------------------------------------------
//
-
-define method draw-overlay (shape :: <shape>, menu :: <shape-menu>) => ()
- next-method ();
- let radius = 60.0;
- glPushMatrix ();
- glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
-
- glColor (1.0, 1.0, 1.0, 1.0);
- //draw-centered-string (0, -50 + 7, "Bring to Front");
- draw-centered-string (0, -75 + 5, "Bring Forward");
- draw-centered-string (0, 75 + 5, "Send Backward");
- //draw-centered-string (0, 50 + 7, "Send to Back");
- glPopMatrix ();
-end;
-
-define method draw-effects (menu :: <shape-menu>, layer :: <effect-layer>) end;
-define method draw-outline (menu :: <shape-menu>) end;
-
-define method draw-centered-string (x, y, string :: <string>)
- local draw-string (x, y, string)
- let width :: <integer> = glutxBitmapLength ($GLUT-BITMAP-HELVETICA-12,
string);
- glRasterPos (round/ (-width, 2.0) + x, y);
- glutxBitmapString ($GLUT-BITMAP-HELVETICA-12, string);
- end;
-
- draw-string (x, y, string);
- draw-string (x + 1, y, string);
+define method on-mouse-event (shape :: <shape>, event :: <mouse-event>,
+ button :: <mouse-button>)
+ => ()
+ //format-out ("on-mouse-event (%=, %=, %=)\n", shape, event, button);
end;
Added: trunk/libraries/inertia/inertia-shapes/shape-polygon.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-shapes/shape-polygon.dylan Tue Nov 8
02:52:20 2005
@@ -0,0 +1,108 @@
+module: inertia-shapes
+synopsis: Core UI shapes
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// shape-polygon.dylan
+//
+
+define class <polygon> (<shape>)
+ slot data = #[
+ #[0.0, 0.0, 0.0], #[15.0, 50.0, 0.0], #[0.0, 100.0, 0.0], #[50.0,
85.0, 0.0],
+ #[ 100.0, 100.0, 0.0], #[ 85.0, 50.0, 0.0], #[100.0, 0.0, 0.0],
#[50.0, 15.0, 0.0]
+ ];
+ slot data2 = #[
+ #[-50.0, -50.0, 0.0], #[-35.0, 0.0, 0.0], #[-50.0, 50.0, 0.0], #[0.0,
35.0, 0.0],
+ #[ 50.0, 50.0, 0.0], #[ 35.0, 0.0, 0.0], #[50.0, -50.0, 0.0], #[0.0,
-35.0, 0.0]
+ ];
+ slot vertices;
+end;
+
+define class <spinning-polygon> (<polygon>)
+ inherited slot effects = vector (make (<shadow-effect>));
+end;
+
+define method class-name (polygon :: <polygon>) "<polygon>" end;
+
+define open class <rectangle> (<shape>)
+end;
+
+// ------------------------------------------------------------------------- //
+// polygon methods definitions
+// ------------------------------------------------------------------------- //
+
+define method initialize (polygon :: <polygon>, #rest init-args,
+ #key left = 0.0, top = 0.0)
+ => ()
+ //apply (next-method, init-args);
+ next-method ();
+ polygon.shape-left := left;
+ polygon.shape-top := top;
+ polygon.z-angle := 5.0;
+
+ polygon.vertices := map (method (vertex) as(<GLdouble*>, vertex) end,
polygon.data);
+end;
+
+define method draw-content (shape :: <shape>, polygon :: <polygon>) => ()
+ gluBeginPolygon (*tess-object*);
+ for (vertex in polygon.vertices)
+ gluTessVertex (*tess-object*, vertex, as(<GLvoid*>, vertex));
+ end;
+ gluEndPolygon (*tess-object*);
+end;
+
+define method draw-outline (polygon :: <polygon>) => ()
+ glBegin ($GL-LINE-LOOP);
+ for (vertex in polygon.vertices)
+ glVertex (vertex[0], vertex[1], vertex[2]);
+ end;
+ glEnd ();
+end;
+
+define constant $X = 0;
+define constant $Y = 1;
+define constant $Z = 2;
+
+define method contains-point? (polygon :: <polygon>, point :: <point>)
+ => (result :: <boolean>)
+ let x = point.point-x; let y = point.point-y;
+ let v = polygon.data;
+ let inside :: <boolean> = #f;
+
+ for (i :: <integer> from 0 below v.size)
+ let j :: <integer> = if (i = v.size - 1) 0 else i + 1 end;
+ if (((v[i][$Y] <= y) & (v[j][$Y] > y)) | ((v[i][$Y] > y) & (v[j][$Y] <=
y)))
+ let vt = (y - v[i][$Y]) / (v[j][$Y] - v[i][$Y]);
+ if (x < v[i][$X] + vt * (v[j][$X] - v[i][$X]))
+ inside := ~inside;
+ end;
+ end;
+ end;
+
+ inside;
+end;
+
+define variable *polygon* = 0;
+define variable *speed* = 10;
+
+define variable xtimer = callback-method (n :: <integer>) => ();
+ if (*speed* > 0.01)
+ glutTimerFunc (n, xtimer, n);
+ *polygon*.z-angle := *polygon*.z-angle + *speed*;
+ *speed* := *speed* * 0.9;
+ glutPostRedisplay ();
+ else
+ *speed* := 10;
+ end;
+end;
+
+define method on-mouse-event
+ (polygon :: <spinning-polygon>, event :: <mouse-down-event>, button ::
<mouse-button>)
+ => ()
+ next-method ();
+ *polygon* := polygon;
+ glutTimerFunc (10, xtimer, 10);
+end;
+
Added: trunk/libraries/inertia/inertia-shapes/shape-rectangle.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-shapes/shape-rectangle.dylan Tue Nov
8 02:52:20 2005
@@ -0,0 +1,58 @@
+module: inertia-shapes
+synopsis: Core UI shapes
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// shape-rectangle.dylan
+//
+
+define method class-name (rectangle :: <rectangle>) "<rectangle>" end;
+
+// ------------------------------------------------------------------------- //
+// rectangle methods definitions
+// ------------------------------------------------------------------------- //
+
+define method initialize (rectangle :: <rectangle>, #rest init-args,
+ #key left = 0.0, top = 0.0, width = 100.0, height =
100.0) => ()
+ apply (next-method, init-args);
+ rectangle.shape-left := left;
+ rectangle.shape-top := top;
+ rectangle.shape-width := width;
+ rectangle.shape-height := height;
+end;
+
+define method draw-content (shape :: <shape>, rectangle :: <rectangle>) => ()
+ let width/2 = shape.shape-width / 2.0;
+ let height/2 = shape.shape-height / 2.0;
+
+ glBegin ($GL-QUADS);
+ glVertex ( 0.0, 0.0);
+ glVertex ( 0.0, shape.shape-height);
+ glVertex (shape.shape-width, shape.shape-height);
+ glVertex (shape.shape-width, 0.0);
+ glEnd ();
+end;
+
+define method draw-outline (rectangle :: <rectangle>) => ()
+ let width/2 = rectangle.shape-width / 2.0;
+ let height/2 = rectangle.shape-height / 2.0;
+ let shape = rectangle;
+
+ glBegin ($GL-LINE-LOOP);
+ glVertex ( 0.0, 0.0);
+ glVertex ( 0.0, shape.shape-height);
+ glVertex (shape.shape-width, shape.shape-height);
+ glVertex (shape.shape-width, 0.0);
+ glEnd ();
+end;
+
+define method contains-point? (rectangle :: <rectangle>, point :: <point>) =>
(result :: <boolean>)
+ let width/2 = rectangle.shape-width / 2.0;
+ let height/2 = rectangle.shape-height / 2.0;
+
+ (point.point-x > 0 & point.point-x < rectangle.shape-width)
+ & (point.point-y > 0 & point.point-y < rectangle.shape-height);
+end;
+
Added: trunk/libraries/inertia/inertia-shapes/shape-shape-menu.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-shapes/shape-shape-menu.dylan Tue Nov
8 02:52:20 2005
@@ -0,0 +1,127 @@
+module: inertia-shapes
+synopsis: Core UI shapes
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// shape-shape-menu.dylan
+//
+
+define class <shape-menu-center> (<rectangle>)
+ inherited slot fill-color = vector (0.5, 0.5, 0.5, 0.9);
+ inherited slot line-width = 1.0;
+ keyword width: = 120.0;
+ keyword height: = 120.0;
+end;
+
+define class <shape-menu> (<rectangle>)
+ inherited slot fill-color = vector (0.5, 0.5, 0.5, 0.9);
+ inherited slot line-width = 1.0;
+end;
+
+define method initialize (menu :: <shape-menu>, #rest init-args, #key) => ()
+ next-method ();
+ add-child (menu, make (<shape-menu-center>, left: menu.shape-width / 2.0 -
60.0,
+ top: menu.shape-height / 2.0 -
60.0));
+end;
+
+define method class-name (menu :: <shape-menu>) "<shape-menu>" end;
+
+// ------------------------------------------------------------------------- //
+// shape-menu methods definitions
+// ------------------------------------------------------------------------- //
+
+define method draw-content (shape :: <shape>, menu :: <shape-menu-center>)
+ let radius = 60.0;
+
+ glPushMatrix ();
+ glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
+ glBegin ($GL-TRIANGLE-FAN);
+ glVertex (0.0, 0.0, 0.0);
+ for (angle from 0 to $PI * 2 by $PI / 20.0)
+ glVertex (cos (angle) * radius, sin (angle) * radius, 0.0);
+ end;
+ glVertex (cos (0) * radius, sin (0) * radius, 0.0);
+ glEnd ();
+
+ glLineWidth (2.0s0);
+ glColor (1.0, 1.0, 1.0, 0.7);
+
+ glBegin ($GL-LINE-LOOP);
+ for (angle from 0 to $PI * 2 by $PI / 20.0)
+ glVertex (cos (angle) * radius, sin (angle) * radius, 0.0);
+ end;
+ glEnd ();
+
+ glBegin ($GL-TRIANGLE-FAN);
+ glVertex (0.0, 0.0, 0.0);
+ for (angle from 0 to $PI * 2 by $PI / 20.0)
+ glVertex (cos (angle) * 5.0, sin (angle) * 5.0, 0.0);
+ end;
+ glVertex (cos (0) * 5.0, sin (0) * 5.0, 0.0);
+ glEnd ();
+
+ glBegin ($GL-LINE-LOOP);
+ for (angle from 0 to $PI * 2 by $PI / 20.0)
+ glVertex (cos (angle) * 5.0, sin (angle) * 5.0, 0.0);
+ end;
+ glEnd ();
+
+ glBegin ($GL-LINES);
+ glVertex ( cos ($PI * (1.0 / 4.0)) * radius, sin ($PI * (1.0 / 4.0)) *
radius);
+ glVertex (-cos ($PI * (1.0 / 4.0)) * radius, -sin ($PI * (1.0 / 4.0)) *
radius);
+ glVertex ( cos ($PI * (3.0 / 4.0)) * radius, sin ($PI * (3.0 / 4.0)) *
radius);
+ glVertex (-cos ($PI * (3.0 / 4.0)) * radius, -sin ($PI * (3.0 / 4.0)) *
radius);
+ glEnd ();
+ glPopMatrix ();
+end;
+
+define method draw-overlay (shape :: <shape>, menu :: <shape-menu-center>) =>
()
+ next-method ();
+ let radius = 60.0;
+ glPushMatrix ();
+ glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
+
+ glColor (1.0, 1.0, 1.0, 1.0);
+
+ draw-centered-string ( 0, -40 + 5, "Cut");
+ draw-centered-string (-35, 0 + 5, "Copy");
+ draw-centered-string ( 35, 0 + 5, "Paste");
+ draw-centered-string ( 0, 40 + 5, "Clone");
+ glPopMatrix ();
+end;
+
+define method draw-effects (menu :: <shape-menu-center>, layer ::
<effect-layer>) end;
+define method draw-outline (menu :: <shape-menu-center>) end;
+
+// ------------------------------------------------------------------------- //
+
+define method draw-overlay (shape :: <shape>, menu :: <shape-menu>) => ()
+ next-method ();
+ let radius = 60.0;
+ glPushMatrix ();
+ glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
+
+ glColor (1.0, 1.0, 1.0, 1.0);
+ //draw-centered-string (0, -50 + 7, "Bring to Front");
+ draw-centered-string (0, -75 + 5, "Bring Forward");
+ draw-centered-string (0, 75 + 5, "Send Backward");
+ //draw-centered-string (0, 50 + 7, "Send to Back");
+ glPopMatrix ();
+end;
+
+define method draw-effects (menu :: <shape-menu>, layer :: <effect-layer>) end;
+define method draw-outline (menu :: <shape-menu>) end;
+
+define method draw-centered-string (x, y, string :: <string>)
+ local draw-string (x, y, string)
+ let width :: <integer> = glutxBitmapLength ($GLUT-BITMAP-HELVETICA-12,
string);
+ glRasterPos (round/ (-width, 2.0) + x, y);
+ glutxBitmapString ($GLUT-BITMAP-HELVETICA-12, string);
+ end;
+
+ draw-string (x, y, string);
+ draw-string (x + 1, y, string);
+end;
+
Modified: trunk/libraries/inertia/inertia-widgets.dylan
==============================================================================
--- trunk/libraries/inertia/inertia-widgets.dylan (original)
+++ trunk/libraries/inertia/inertia-widgets.dylan Tue Nov 8 02:52:20 2005
@@ -15,232 +15,13 @@
// A <widget> is a shape that more closely resembles a standard control, such
as a button, window
// or scroll-bar.
-define class <widget> (<rectangle>)
+define open class <widget> (<rectangle>)
inherited slot fill-color = vector (0.95, 0.95, 0.95, 1.0);
inherited slot line-color = vector (0.75, 0.75, 0.75, 1.0);
inherited slot line-width = 1.0;
end;
-// A <shape-editor> is used to edit shape geometries. It defines a few
send-events so that it can
-// capture mouse events.
-
-define class <shape-editor> (<widget>)
- inherited slot line-width = 1.0;
- //inherited slot fill-color = vector (1.0, 1.0, 1.0, 1.0);
- slot grabbed-shape :: false-or (<shape>) = #f;
- slot first-mouse :: <point>;
-end;
-
define class <label> (<widget>)
end;
-define class <button> (<widget>)
-end;
-
-// - push-button
--------------------------------------------------------------------------------
//
-
-define class <push-button> (<button>)
- inherited slot line-width = 1.0;
- inherited slot fill-color = vector (0.9, 0.9, 0.9, 1.0);
- inherited slot effects = vector (make (<gradient-effect>));
- slot caption :: <string> = "", init-keyword: caption:;
- keyword width: = 100.0;
- keyword height: = 25.0;
-end;
-
-define method class-name (button :: <push-button>) "<push-button>" end;
-
-// - title-bar
----------------------------------------------------------------------------------
//
-
-define class <title-bar> (<widget>)
- inherited slot fill-color = vector (0.75, 0.87, 1.0, 1.0);
- inherited slot effects = vector (make (<gradient-effect>));
- inherited slot reshape = #[#"size", #"none"];
- slot first-mouse :: <point>;
-end;
-
-define method class-name (title-bar :: <title-bar>) "<title-bar>" end;
-
-// - window-sizer
-------------------------------------------------------------------------------
//
-
-define class <window-sizer> (<widget>)
- inherited slot reshape = #[#"move", #"move"];
- slot first-mouse :: <point>;
- keyword width: = 20.0;
- keyword height: = 20.0;
-end;
-
-define method class-name (window-sizer :: <window-sizer>) "<window-sizer>" end;
-
-// - window
-------------------------------------------------------------------------------------
//
-
-define class <window> (<widget>)
- inherited slot line-width = 1.0;
- inherited slot fill-color = vector (0.95, 0.95, 0.95, 1.0);
- inherited slot effects = vector (make (<shadow-effect>));
- slot caption :: <string> = "", init-keyword: caption:;
- keyword width: = 300.0;
- keyword height: = 200.0;
-end;
-
-define method class-name (window :: <window>) "<window>" end;
-
-define method initialize (window :: <window>, #rest init-args, #key) => ()
- next-method ();
- add-child (window, make (<title-bar>, width: 300.0, height: 25.0));
- add-child (window, make (<window-sizer>, left: 280.0, top: 180.0));
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// push-button methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method draw-overlay (shape :: <shape>, menu :: <push-button>)
- next-method ();
- glColor (0.0, 0.0, 0.0, 1.0);
- glPushMatrix ();
- glTranslate (shape.extent.point-x / 2.0, shape.extent.point-y / 2.0, 0.0);
- draw-centered-string (0, 5, shape.caption);
- glPopMatrix ();
-end;
-
-define method on-mouse-event (button :: <push-button>, event ::
<mouse-enter-event>, mouse-button :: <mouse-button>)
- button.fill-color := vector (0.75, 0.87, 1.0, 1.0);
- next-method ();
- glutPostRedisplay ();
-end;
-
-define method on-mouse-event (button :: <push-button>, event ::
<mouse-exit-event>, mouse-button :: <mouse-button>)
- button.fill-color := vector (0.95, 0.95, 0.95, 1.0);
- next-method ();
- glutPostRedisplay ();
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// title-bar methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method draw-overlay (shape :: <shape>, menu :: <title-bar>)
- next-method ();
- glColor (0.0, 0.0, 0.0, 1.0);
- glPushMatrix ();
- glTranslate (shape.extent.point-x / 2.0, shape.extent.point-y / 2.0, 0.0);
- draw-centered-string (0, 5, shape.parent.caption);
- glPopMatrix ();
-end;
-
-define method on-mouse-event (title-bar :: <title-bar>, event ::
<mouse-down-event>, button == $left-button)
- title-bar.first-mouse := event.origin;
- next-method ();
-end;
-
-define method on-mouse-event (title-bar :: <title-bar>, event ::
<mouse-drag-event>, button == $left-button)
- title-bar.parent.origin := title-bar.parent.origin + (event.origin -
title-bar.first-mouse);
- next-method ();
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// window-sizer methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method on-mouse-event (window-sizer :: <window-sizer>, event ::
<mouse-down-event>, mouse-button == $left-button)
- window-sizer.first-mouse := event.origin;
- next-method ();
-end;
-
-define method on-mouse-event (window-sizer :: <window-sizer>, event ::
<mouse-drag-event>, mouse-button == $left-button)
- window-sizer.parent.extent := window-sizer.parent.extent + (event.origin -
window-sizer.first-mouse);
- //window-sizer.origin := window-sizer.origin + (event.origin -
window-sizer.first-mouse);
- next-method ();
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// window methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method send-event
- (window :: <window>, event :: <mouse-down-event>, button :: <mouse-button>)
- => (result :: <shape>)
- remove-child (window.parent, window);
- add-child (window.parent, window);
- next-method ();
-end;
-
-//
----------------------------------------------------------------------------------------------
//
-// shape-editor methods definitions
-//
----------------------------------------------------------------------------------------------
//
-
-define method draw-overlay (shape :: <shape>, editor :: <shape-editor>)
- if (editor.grabbed-shape)
- draw-grabber (editor.grabbed-shape);
- end;
-end;
-
-define method send-event
- (editor :: <shape-editor>, event :: <mouse-down-event>, button ==
$left-button)
- => (result :: <shape>)
- editor.grabbed-shape := next-method ();
- editor.first-mouse := event.origin - editor.grabbed-shape.origin;
- editor;
-end;
-
-define method send-event
- (editor :: <shape-editor>, event :: <mouse-down-event>, button ==
$right-button)
- => (result :: <shape>)
- *menu*.origin := event.origin - *menu*.extent / 2.0;
- editor;
-end;
-
-define method on-mouse-event
- (editor :: <shape-editor>, event :: <mouse-drag-event>, button ==
$left-button)
- => ()
- if (editor.grabbed-shape.mouse-mode == #"gripper")
- let delta = event.origin - editor.grabbed-shape.screen-origin;
-
- block ()
- editor.grabbed-shape.z-angle := atan2 (delta.point-y, delta.point-x) /
($PI / 180.0);
- exception (<error>)
- // Don't care if x and y are both 0
- end;
- editor.grabbed-shape.z-scale := point-length (delta) / 50.0;
- else
- editor.grabbed-shape.origin := event.origin - editor.first-mouse;
- end;
- editor;
-end;
-
-define method on-mouse-event
- (editor :: <shape-editor>, event :: <mouse-up-event>, button ::
<mouse-button>)
- => (result :: <shape>)
- editor.grabbed-shape.mouse-mode := #"normal";
- editor;
-end;
-
-define method send-event
- (editor :: <shape-editor>, event :: <mouse-up-event>, button ==
$right-button)
- => (result :: <shape>)
- *menu*.origin := *screen*.origin;
- editor;
-end;
-
-define method draw-grabber (shape :: <shape>)
- glColor (0.0, 0.0, 0.0);
- glPushMatrix ();
- glTranslate (shape.shape-left, shape.shape-top, 0.0);
- glRotate (shape.z-angle, 0.0, 0.0, 1.0);
-
- glLineWidth (1.0s0);
- glBegin ($GL-LINES);
- glVertex (0.0, 0.0);
- glVertex (50.0 * shape.z-scale, 0.0, 0.0);
- glEnd ();
-
- glBegin ($GL-QUADS);
- glVertex (50.0 * shape.z-scale + 0.0, -5.0);
- glVertex (50.0 * shape.z-scale + 0.0, 5.0);
- glVertex (50.0 * shape.z-scale + 10.0, 5.0);
- glVertex (50.0 * shape.z-scale + 10.0, -5.0);
- glEnd ();
- glPopMatrix ();
-end;
Added: trunk/libraries/inertia/inertia-widgets/widget-button.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-widgets/widget-button.dylan Tue Nov 8
02:52:20 2005
@@ -0,0 +1,62 @@
+module: inertia-shapes
+synopsis: Core UI widgets
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// widget-button.dylan
+//
+
+define class <button> (<widget>)
+ slot on-click;
+end;
+
+define class <button-clicked-event> (<mouse-event>)
+end;
+
+// - push-button
--------------------------------------------------------------------------------
//
+
+define class <push-button> (<button>)
+ inherited slot line-width = 1.0;
+ inherited slot fill-color = vector (0.9, 0.9, 0.9, 1.0);
+ inherited slot effects = vector (make (<gradient-effect>));
+ slot caption :: <string> = "", init-keyword: caption:;
+ keyword width: = 100.0;
+ keyword height: = 25.0;
+end;
+
+define method class-name (button :: <push-button>) "<push-button>" end;
+
+define method make-from-symbol (symbol == #"<push-button>", #rest init-args,
#key)
+ let object = apply (make, <push-button>, init-args);
+ object.fields[#"caption"] := make (<field>, getter: caption, setter:
caption-setter);
+ object.fields[#"on-click"] := make (<field>, getter: on-click, setter:
on-click-setter);
+ object;
+end;
+
+//
----------------------------------------------------------------------------------------------
//
+// methods definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define method draw-overlay (shape :: <shape>, menu :: <push-button>)
+ next-method ();
+ glColor (0.0, 0.0, 0.0, 1.0);
+ glPushMatrix ();
+ glTranslate (shape.extent.point-x / 2.0, shape.extent.point-y / 2.0, 0.0);
+ draw-centered-string (0, 5, shape.caption);
+ glPopMatrix ();
+end;
+
+define method on-mouse-event (button :: <push-button>, event ::
<mouse-enter-event>, mouse-button :: <mouse-button>)
+ button.fill-color := vector (0.75, 0.87, 1.0, 1.0);
+ next-method ();
+ glutPostRedisplay ();
+end;
+
+define method on-mouse-event (button :: <push-button>, event ::
<mouse-exit-event>, mouse-button :: <mouse-button>)
+ button.fill-color := vector (0.95, 0.95, 0.95, 1.0);
+ next-method ();
+ glutPostRedisplay ();
+end;
+
Added: trunk/libraries/inertia/inertia-widgets/widget-shape-editor.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-widgets/widget-shape-editor.dylan Tue Nov
8 02:52:20 2005
@@ -0,0 +1,98 @@
+module: inertia-shapes
+synopsis: Core UI widgets
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// widget-shape-editor.dylan
+//
+
+// A <shape-editor> is used to edit shape geometries. It defines a few
send-events so that it can
+// capture mouse events.
+
+define class <shape-editor> (<widget>)
+ inherited slot line-width = 1.0;
+ inherited slot fill-color = vector (1.0, 1.0, 1.0, 1.0);
+ slot grabbed-shape :: false-or (<shape>) = #f;
+ slot first-mouse :: <point>;
+end;
+
+//
----------------------------------------------------------------------------------------------
//
+// shape-editor methods definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define method draw-overlay (shape :: <shape>, editor :: <shape-editor>)
+ if (editor.grabbed-shape)
+ draw-grabber (editor.grabbed-shape);
+ end;
+end;
+
+define method send-event
+ (editor :: <shape-editor>, event :: <mouse-down-event>, button ==
$left-button)
+ => (result :: <shape>)
+ editor.grabbed-shape := next-method ();
+ editor.first-mouse := event.origin - editor.grabbed-shape.origin;
+ editor;
+end;
+
+define method send-event
+ (editor :: <shape-editor>, event :: <mouse-down-event>, button ==
$right-button)
+ => (result :: <shape>)
+ *menu*.origin := event.origin - *menu*.extent / 2.0;
+ editor;
+end;
+
+define method on-mouse-event
+ (editor :: <shape-editor>, event :: <mouse-drag-event>, button ==
$left-button)
+ => ()
+ if (editor.grabbed-shape.mouse-mode == #"gripper")
+ let delta = event.origin - editor.grabbed-shape.screen-origin;
+
+ block ()
+ editor.grabbed-shape.z-angle := atan2 (delta.point-y, delta.point-x) /
($PI / 180.0);
+ exception (<error>)
+ // Don't care if x and y are both 0
+ end;
+ editor.grabbed-shape.z-scale := point-length (delta) / 50.0;
+ else
+ editor.grabbed-shape.origin := event.origin - editor.first-mouse;
+ end;
+ editor;
+end;
+
+define method on-mouse-event
+ (editor :: <shape-editor>, event :: <mouse-up-event>, button ::
<mouse-button>)
+ => (result :: <shape>)
+ editor.grabbed-shape.mouse-mode := #"normal";
+ editor;
+end;
+
+define method send-event
+ (editor :: <shape-editor>, event :: <mouse-up-event>, button ==
$right-button)
+ => (result :: <shape>)
+ *menu*.origin := *screen*.origin;
+ editor;
+end;
+
+define method draw-grabber (shape :: <shape>)
+ glColor (0.0, 0.0, 0.0);
+ glPushMatrix ();
+ glTranslate (shape.shape-left, shape.shape-top, 0.0);
+ glRotate (shape.z-angle, 0.0, 0.0, 1.0);
+
+ glLineWidth (1.0s0);
+ glBegin ($GL-LINES);
+ glVertex (0.0, 0.0);
+ glVertex (50.0 * shape.z-scale, 0.0, 0.0);
+ glEnd ();
+
+ glBegin ($GL-QUADS);
+ glVertex (50.0 * shape.z-scale + 0.0, -5.0);
+ glVertex (50.0 * shape.z-scale + 0.0, 5.0);
+ glVertex (50.0 * shape.z-scale + 10.0, 5.0);
+ glVertex (50.0 * shape.z-scale + 10.0, -5.0);
+ glEnd ();
+ glPopMatrix ();
+end;
+
Added: trunk/libraries/inertia/inertia-widgets/widget-window.dylan
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/inertia-widgets/widget-window.dylan Tue Nov 8
02:52:20 2005
@@ -0,0 +1,126 @@
+module: inertia-shapes
+synopsis: Core UI widgets
+author: Mike Austin
+copyright: Copyright (C) 2005 Mike L. Austin. All rights reserved.
+license: MIT/BSD, see LICENCE.txt for details
+
+//
+// widget-window.dylan
+//
+
+//
----------------------------------------------------------------------------------------------
//
+// class definitions
+//
----------------------------------------------------------------------------------------------
//
+
+// - title-bar
----------------------------------------------------------------------------------
//
+
+define class <title-bar> (<widget>)
+ inherited slot fill-color = vector (0.75, 0.87, 1.0, 1.0);
+ inherited slot effects = vector (make (<gradient-effect>));
+ inherited slot reshape = #[#"size", #"none"];
+ slot first-mouse :: <point>;
+end;
+
+define method class-name (title-bar :: <title-bar>) "<title-bar>" end;
+
+// - window-sizer
-------------------------------------------------------------------------------
//
+
+define class <window-sizer> (<widget>)
+ inherited slot reshape = #[#"move", #"move"];
+ slot first-mouse :: <point>;
+ keyword width: = 25.0;
+ keyword height: = 10.0;
+end;
+
+define method class-name (window-sizer :: <window-sizer>) "<window-sizer>" end;
+
+// - window
-------------------------------------------------------------------------------------
//
+
+define class <window> (<widget>)
+ inherited slot line-width = 1.0;
+ inherited slot fill-color = vector (0.95, 0.95, 0.95, 1.0);
+ inherited slot effects = vector (make (<shadow-effect>));
+ slot caption :: <string> = "", init-keyword: caption:;
+ slot window-client :: <shape>;
+ keyword width: = 300.0;
+ keyword height: = 200.0;
+end;
+
+define method class-name (window :: <window>) "<window>" end;
+
+define method make-from-symbol (symbol == #"<window>", #rest init-args, #key)
+ let object = apply (make, <window>, init-args);
+ object;
+end;
+
+define method initialize (window :: <window>, #rest init-args, #key width =
300.0, height = 200.0, client = #f) => ()
+ next-method ();
+ if (client == #f)
+ window.window-client := make (<widget>, left: 0.0, top: 25.0, width:
width, height: height,
+ reshape: #[#"size", #"size"]);
+ else
+ client.shape-top := 25.0;
+ window.window-client := client;
+ end;
+ window.extent := make (<point>, x: window.window-client.shape-width, y:
window.window-client.shape-height + 35.0);
+ shape-add-child (window, make (<title-bar>, width: window.shape-width,
height: 25.0));
+ shape-add-child (window, make (<window-sizer>, left: window.shape-width -
25.0, top: window.shape-height - 10.0));
+ shape-add-child (window, window.window-client);
+end;
+
+//
----------------------------------------------------------------------------------------------
//
+// title-bar methods definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define method draw-overlay (shape :: <shape>, menu :: <title-bar>)
+ next-method ();
+ glColor (0.0, 0.0, 0.0, 1.0);
+ glPushMatrix ();
+ glTranslate (shape.extent.point-x / 2.0, shape.extent.point-y / 2.0, 0.0);
+ draw-centered-string (0, 5, shape.parent.caption);
+ glPopMatrix ();
+end;
+
+define method on-mouse-event (title-bar :: <title-bar>, event ::
<mouse-down-event>, button == $left-button)
+ title-bar.first-mouse := event.origin;
+ next-method ();
+end;
+
+define method on-mouse-event (title-bar :: <title-bar>, event ::
<mouse-drag-event>, button == $left-button)
+ title-bar.parent.origin := title-bar.parent.origin + (event.origin -
title-bar.first-mouse);
+ next-method ();
+end;
+
+//
----------------------------------------------------------------------------------------------
//
+// window-sizer methods definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define method on-mouse-event (window-sizer :: <window-sizer>, event ::
<mouse-down-event>, mouse-button == $left-button)
+ window-sizer.first-mouse := event.origin;
+ next-method ();
+end;
+
+define method on-mouse-event (window-sizer :: <window-sizer>, event ::
<mouse-drag-event>, mouse-button == $left-button)
+ window-sizer.parent.extent := window-sizer.parent.extent + (event.origin -
window-sizer.first-mouse);
+ next-method ();
+end;
+
+//
----------------------------------------------------------------------------------------------
//
+// window methods definitions
+//
----------------------------------------------------------------------------------------------
//
+
+define method send-event (window :: <window>, event :: <mouse-down-event>,
button :: <mouse-button>)
+ => (result :: <shape>)
+ remove-child (window.parent, window);
+ add-child (window.parent, window);
+ next-method ();
+end;
+
+define method add-child (window :: <window>, child :: <shape>) => ()
+ add-child( window.window-client, child );
+end;
+
+define method remove-child (window :: <window>, child :: <shape>) => ()
+ remove-child( window.window-client, child );
+end;
+
Modified: trunk/libraries/inertia/inertia.dev
==============================================================================
--- trunk/libraries/inertia/inertia.dev (original)
+++ trunk/libraries/inertia/inertia.dev Tue Nov 8 02:52:20 2005
@@ -1,7 +1,7 @@
[Project]
FileName=inertia.dev
Name=inertia
-UnitCount=13
+UnitCount=19
Type=1
Ver=1
ObjFiles=
@@ -20,7 +20,7 @@
OverrideOutput=0
OverrideOutputName=
HostApplication=
-Folders=tests
+Folders=inertia-shapes,inertia-widgets,tests
CommandLine=
UseCustomMakefile=0
CustomMakefile=
@@ -66,15 +66,6 @@
BuildCmd=
[Unit3]
-FileName=inertia-shapes.dylan
-Folder=
-Compile=1
-Link=1
-Priority=1000
-OverrideBuildCmd=0
-BuildCmd=
-
-[Unit4]
FileName=inertia.lid
Folder=
Compile=1
@@ -83,7 +74,7 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit5]
+[Unit4]
FileName=tests\inertia-test.lid
Folder=tests
Compile=0
@@ -92,7 +83,7 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit6]
+[Unit5]
FileName=tests\inertia-test-exports.dylan
Folder=tests
Compile=0
@@ -101,7 +92,7 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit7]
+[Unit6]
FileName=tests\inertia-test-main.dylan
Folder=tests
Compile=0
@@ -110,7 +101,7 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit8]
+[Unit7]
FileName=inertia-gl-utils.dylan
Folder=
Compile=1
@@ -119,16 +110,16 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit9]
+[Unit8]
FileName=Makefile
-Folder=inertia
+Folder=
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=
-[Unit10]
+[Unit9]
FileName=inertia-main.dylan
Folder=
Compile=1
@@ -137,7 +128,7 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit11]
+[Unit10]
FileName=inertia-events.dylan
Folder=
Compile=1
@@ -146,8 +137,8 @@
OverrideBuildCmd=0
BuildCmd=
-[Unit12]
-FileName=inertia-widgets.dylan
+[Unit11]
+FileName=inertia-effects.dylan
Folder=
Compile=1
Link=1
@@ -155,11 +146,74 @@
OverrideBuildCmd=0
BuildCmd=
+[Unit12]
+FileName=inertia-shapes\shape-polygon.dylan
+Folder=inertia-shapes
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
[Unit13]
-FileName=inertia-effects.dylan
-Folder=
+FileName=inertia-shapes\shape-rectangle.dylan
+Folder=inertia-shapes
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit14]
+FileName=inertia-shapes\shape-shape-menu.dylan
+Folder=inertia-shapes
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit15]
+FileName=inertia-widgets\widget-shape-editor.dylan
+Folder=inertia-widgets
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit16]
+FileName=inertia-widgets\widget-button.dylan
+Folder=inertia-widgets
Compile=1
Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit17]
+FileName=inertia-widgets\widget-window.dylan
+Folder=inertia-widgets
+Compile=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit18]
+FileName=inertia-shapes.dylan
+Folder=inertia
+Compile=0
+Link=0
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit19]
+FileName=inertia-widgets.dylan
+Folder=inertia
+Compile=0
+Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=
Modified: trunk/libraries/inertia/inertia.layout
==============================================================================
--- trunk/libraries/inertia/inertia.layout (original)
+++ trunk/libraries/inertia/inertia.layout Tue Nov 8 02:52:20 2005
@@ -1,6 +1,6 @@
[Editor_0]
-CursorCol=18
-CursorRow=19
+CursorCol=21
+CursorRow=28
TopLine=1
LeftChar=1
Open=1
@@ -10,12 +10,12 @@
CursorRow=17
TopLine=1
LeftChar=1
-Open=1
+Open=0
Top=0
[Editor_2]
-CursorCol=1
-CursorRow=277
-TopLine=400
+CursorCol=10
+CursorRow=11
+TopLine=1
LeftChar=1
Open=1
Top=0
@@ -34,61 +34,103 @@
Open=0
Top=0
[Editor_5]
-CursorCol=15
-CursorRow=22
-TopLine=1
+CursorCol=34
+CursorRow=104
+TopLine=53
LeftChar=1
-Open=0
+Open=1
Top=0
[Editor_6]
-CursorCol=1
-CursorRow=33
-TopLine=1
+CursorCol=32
+CursorRow=106
+TopLine=53
LeftChar=1
Open=0
Top=0
[Editors]
-Order=12,2,11,9,10,1,0,7
-Focused=11
+Order=7,2,17,18,-1,8,0
+Focused=8
[Editor_7]
Open=1
Top=0
-CursorCol=27
-CursorRow=34
+CursorCol=40
+CursorRow=16
TopLine=1
LeftChar=1
[Editor_8]
-Open=0
-Top=0
+Open=1
+Top=1
CursorCol=1
-CursorRow=11
-TopLine=1
+CursorRow=218
+TopLine=163
LeftChar=1
[Editor_10]
-CursorCol=17
-CursorRow=78
-TopLine=103
+CursorCol=1
+CursorRow=63
+TopLine=6
LeftChar=1
-Open=1
+Open=0
Top=0
[Editor_9]
-Open=1
+Open=0
Top=0
CursorCol=1
-CursorRow=99
-TopLine=42
+CursorRow=159
+TopLine=102
LeftChar=1
[Editor_11]
-Open=1
-Top=1
-CursorCol=5
-CursorRow=153
-TopLine=189
+Open=0
+Top=0
+CursorCol=1
+CursorRow=1
+TopLine=1
LeftChar=1
[Editor_12]
+Open=0
+Top=0
+CursorCol=9
+CursorRow=8
+TopLine=1
+LeftChar=1
+[Editor_13]
+CursorCol=9
+CursorRow=8
+TopLine=1
+LeftChar=1
+Open=0
+Top=0
+[Editor_14]
+CursorCol=9
+CursorRow=8
+TopLine=1
+LeftChar=1
+Open=0
+Top=0
+[Editor_15]
+Open=0
+Top=0
+CursorCol=1
+CursorRow=13
+TopLine=1
+LeftChar=1
+[Editor_16]
+CursorCol=1
+CursorRow=78
+TopLine=41
+LeftChar=1
+Open=0
+Top=0
+[Editor_17]
Open=1
Top=0
-CursorCol=23
-CursorRow=11
-TopLine=3
+CursorCol=1
+CursorRow=10
+TopLine=1
+LeftChar=1
+[Editor_18]
+Open=1
+Top=0
+CursorCol=4
+CursorRow=12
+TopLine=1
LeftChar=1
Modified: trunk/libraries/inertia/inertia.lid
==============================================================================
--- trunk/libraries/inertia/inertia.lid (original)
+++ trunk/libraries/inertia/inertia.lid Tue Nov 8 02:52:20 2005
@@ -3,8 +3,14 @@
inertia-gl-utils
inertia-geometry
inertia-shapes
+ inertia-shapes/shape-polygon
+ inertia-shapes/shape-rectangle
+ inertia-shapes/shape-shape-menu
inertia-effects
inertia-events
inertia-widgets
+ inertia-widgets/widget-shape-editor
+ inertia-widgets/widget-button
+ inertia-widgets/widget-window
inertia-main
Modified: trunk/libraries/inertia/tests/inertia-test-exports.dylan
==============================================================================
--- trunk/libraries/inertia/tests/inertia-test-exports.dylan (original)
+++ trunk/libraries/inertia/tests/inertia-test-exports.dylan Tue Nov 8
02:52:20 2005
@@ -10,15 +10,21 @@
define library inertia-test
use common-dylan;
+ use transcendental;
+ use time;
+ use melange-support;
use opengl;
use inertia;
end;
define module inertia-test
use common-dylan;
+ use transcendental;
+ use melange-support;
use opengl;
use opengl-glut;
use simple-io;
+ use time;
use inertia;
use inertia-shapes;
end;
Modified: trunk/libraries/inertia/tests/inertia-test-main.dylan
==============================================================================
--- trunk/libraries/inertia/tests/inertia-test-main.dylan (original)
+++ trunk/libraries/inertia/tests/inertia-test-main.dylan Tue Nov 8
02:52:20 2005
@@ -19,22 +19,100 @@
define method <window>_xadd-child (window :: <window>, child :: <shape>)
end;
+// --------------------------------------------------------------------------
//
+// inertia-test class definitions
+// --------------------------------------------------------------------------
//
+
+define class <clock> (<widget>)
+ inherited slot fill-color = vector (1.0, 1.0, 1.0, 1.0);
+ inherited slot reshape = #[#"size", #"size"];
+end;
+
+define method initialize (clock :: <clock>, #rest init-args, #key) => ()
+ next-method ();
+ glutTimerFunc (1000, clock-timer, 1000);
+end;
+
+define variable clock-timer = callback-method (n :: <integer>) => ();
+ glutTimerFunc (n, clock-timer, n);
+ glutPostRedisplay ();
+end;
+
+// --------------------------------------------------------------------------
//
+// clock methods definitions
+// --------------------------------------------------------------------------
//
+
+define method \/ (a :: <integer>, b :: <integer>)
+ as(<double-float>, a) / b;
+end;
+
+define constant hours-in-radians = (1 / 60) * (1 / 60) * ($double-pi * 2 / 12);
+define constant minutes-in-radians = (1 / 60) * ($double-pi * 2 / 60);
+define constant seconds-in-radians = ($double-pi * 2 / 60);
+
+define method draw-overlay (shape :: <shape>, clock :: <clock>)
+ let time = get-decoded-time (timezone: -8 * 60 * 60);
+ let size = min (shape.shape-width, shape.shape-height) / 2.0;
+ let ratio = $double-pi * 2 / 60.0;
+ let secs = modulo (time.hours, 12) * 60 * 60 + time.minutes * 60 +
time.seconds;
+ glPushMatrix ();
+ glTranslate (shape.shape-width / 2.0, shape.shape-height / 2.0, 0.0);
+ glRotate (-90.0, 0.0, 0.0, 1.0);
+
+ glColor (0.3, 0.3, 0.3);
+ with-glBegin ($GL-LINES)
+ for (tick from 0 below 12)
+ glVertex (cos (tick * ratio * 5) * (size - 6.0),
+ sin (tick * ratio * 5) * (size - 6.0));
+ glVertex (cos (tick * ratio * 5) * (size - 3.0),
+ sin (tick * ratio * 5) * (size - 3.0));
+ end;
+ end;
+
+ glColor (0.3, 0.3, 0.3);
+ with-glBegin ($GL-LINES)
+ glVertex (0.0, 0.0);
+ glVertex (cos (secs * hours-in-radians) * (size * 0.6),
+ sin (secs * hours-in-radians) * (size * 0.6));
+ glVertex (0.0, 0.0);
+ glVertex (cos (secs * minutes-in-radians) * (size - 9.0),
+ sin (secs * minutes-in-radians) * (size - 9.0));
+ glColor (0.7, 0.7, 0.7);
+ glVertex (0.0, 0.0);
+ glVertex (cos (secs * seconds-in-radians) * (size - 3.0),
+ sin (secs * seconds-in-radians) * (size - 3.0));
+ end;
+ glPopMatrix ();
+end;
+
+define method button-clicked (button :: <push-button>)
+end;
+
+*function-table*[#"button-clicked"] := button-clicked;
+
begin
- format-out ("%=\n", make-from-string (as(<symbol>, "<polygon>")));
-
- define variable *editor* = make (<shape-editor>, width: 500.0, height:
500.0);
- add-child (*editor*, make (<polygon>, left: 200.0, top: 200.0));
- add-child (*editor*, make (<spinning-polygon>, left: 300.0, top: 300.0));
- add-child (*editor*, make (<rectangle>, left: 400.0, top: 400.0));
+ define variable *editor* = make (<shape-editor>, left: 10.0, top: 10.0,
+ width: 580.0, height: 380.0,
+ reshape: #[#"size",
#"size"]);
+ add-child (*editor*, make (<polygon>, left: 50.0, top: 50.0));
+ add-child (*editor*, make (<spinning-polygon>, left: 150.0, top: 150.0));
+ add-child (*editor*, make (<rectangle>, left: 250.0, top: 250.0));
add-child (*editor*, make (<push-button>, caption: "Another"));
- define variable *window* = make (<window>, caption: "Window 1", left: 400.0,
top: 200.0);
- add-child (*window*, make (<push-button>, caption: "Press Me", reshape:
#[#"move", #"move"],
- left: 190.0, top: 165.0));
-
+ define variable *window* = make (<window>, caption: "Window 1",
+ left: 50.0, top: 50.0,
+ width: 600.0, height: 400.0);
+ add-child (*window*, *editor*);
+ add-child (*window*, make (<push-button>, caption: "Press Me",
+ reshape: #[#"move", #"move"], left: 190.0, top:
165.0));
add-child (*screen*, make (<window>, caption: "Window 2", left: 500.0, top:
300.0));
- add-child (*screen*, *editor*);
+ add-child (*screen*, make (<window>, client: make (<clock>), angle: 12.0,
+ caption: "Clock", left: 700.0, top: 50.0));
add-child (*screen*, *window*);
+
+ build-object (*screen*, "layout.ui");
+
+ format-out ("%=\n", *function-table*[#"button"].on-click);
glutMainLoop ();
end;
Added: trunk/libraries/inertia/tests/layout.ui
==============================================================================
--- (empty file)
+++ trunk/libraries/inertia/tests/layout.ui Tue Nov 8 02:52:20 2005
@@ -0,0 +1,14 @@
+object window: <window>
+ shape-left: 10
+ shape-top: 10
+ object button: <push-button>
+ caption: "It's Alive!"
+ shape-left: 10
+ shape-top: 10
+ on-click: button-clicked
+# on-click: <action>
+# method: button-clicked
+# end
+ end
+end
+
--
Gd-chatter mailing list
Gd-chatter@xxxxxxxxxxxxxxxx
https://gauss.gwydiondylan.org/mailman/listinfo/gd-chatter
|