[gsharp-devel] Architecture question
Robert Strandh
strandh at labri.fr
Wed Jul 21 10:16:21 UTC 2004
I think I see more clearly now.
It seems feasible for the score pane to define a bunch of presentation
types, such as this:
(define-presentation-type clef () :options (name x staff-step))
(define-presentation-method present (object
(type clef)
stream
(view score-view)
&key acceptably for-context-type)
(declare (ignore acceptably for-context-type))
(with-output-as-presentation (stream object 'clef)
(draw-clef stream name x staff-step)))
(define-presentation-method present (object
(type clef)
stream
(view textual-view)
&key acceptably for-context-type)
(declare (ignore acceptably for-context-type))
(format stream "[~a clef on staff step ~a]" name staff-step))
and for client code to draw using calls such as this:
(present (clef staff)
`((score-pane:clef)
:name ,(name (clef staff))
:x ,(+ x1 10)
:staff-step ,(lineno (clef staff)))
:stream pane)
It would also be nice to define a hierarchy of presentations. For
instance, there might be a presentation type `staff' and the
presentation types like `clef' would accept an argument that indicates
to which staff the objects belong.
Client code would look like this:
(present 1 ((score-pane:system) :x 100 :y 100) :stream pane)
(present mystaff
`((score-pane:staff
:system 1
:y 10 ;relative to the top of the system
:type :fiveline))
:stream pane)
(present (clef staff)
`((score-pane:clef)
:staff mystaff
:name :bass
:x 10 ; relative to the left edge of the staff
:staff-step 6)
:stream pane)
The score pane would compare client objects using (say) eql (so as to
allow for integers) and establish relationships
Question: would it be necessary for client code to sometimes just draw
things without presenting them? I kind of think so. It would then be
nice to be able to reuse the presentation types in a draw function as
opposed to the current system with draw-??? functions. In that case,
could that be a different presentation generic function, which would
have the strange behavior of not creating presentations. Or should it
just be a different view for present, say draw-view that has draws
without presenting:
(present mystaff
`((score-pane:staff
:system 1
:y 10 ;relative to the top of the system
:type :fiveline))
:stream pane
:view score-pane:draw-view)
Comments?
--
Robert Strandh
---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------
More information about the gsharp-devel
mailing list