| 1 | (in-package :lisp-on-lines) |
| 2 | |
| 3 | |
| 4 | (define-description editable () |
| 5 | () |
| 6 | (:mixinp t)) |
| 7 | |
| 8 | (define-description T () |
| 9 | ((editp :label "Edit by Default?" |
| 10 | :value nil |
| 11 | :editp nil) |
| 12 | (identity :editp nil) |
| 13 | (type :editp nil) |
| 14 | (class :editp nil)) |
| 15 | (:in-description editable)) |
| 16 | |
| 17 | #+nil(define-layered-function (setf attribute-value) (v o a) |
| 18 | (:method (value object attribute) |
| 19 | (let ((setter (attribute-setter attribute))) |
| 20 | (if setter |
| 21 | (funcall setter value object) |
| 22 | (error "No setter in ~A for ~A" attribute object))))) |
| 23 | |
| 24 | (define-layered-class standard-attribute |
| 25 | :in-layer #.(defining-description 'editable) |
| 26 | () |
| 27 | ((edit-attribute-p |
| 28 | :initform :inherit |
| 29 | :accessor %attribute-editp |
| 30 | :initarg :editp |
| 31 | :layered t) |
| 32 | (setter |
| 33 | :initarg :setter |
| 34 | :layered t |
| 35 | :accessor attribute-setter |
| 36 | :initform nil))) |
| 37 | |
| 38 | (define-layered-function attribute-editp (object attribute) |
| 39 | (:method (object attribute) nil)) |
| 40 | |
| 41 | (define-layered-method attribute-editp |
| 42 | :in-layer #.(defining-description 'editable) |
| 43 | (object (attribute standard-attribute)) |
| 44 | |
| 45 | (if (eq :inherit (%attribute-editp attribute)) |
| 46 | (attribute-value object (find-attribute |
| 47 | (attribute-description attribute) |
| 48 | 'editp)) |
| 49 | (%attribute-editp attribute))) |
| 50 | |
| 51 | |
| 52 | (define-layered-method display-using-description |
| 53 | :in-layer #.(defining-description 'editable) |
| 54 | ((attribute standard-attribute) display object &rest args) |
| 55 | |
| 56 | (declare (ignore args)) |
| 57 | (if (attribute-editp object attribute) |
| 58 | (format *display* "This is where we'd edit") |
| 59 | (call-next-method))) |
| 60 | |
| 61 | |
| 62 | |