Skip to content

Commit

Permalink
poiu events
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Jan 7, 2017
1 parent 47b7327 commit 975afde
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
1 change: 1 addition & 0 deletions cl-bodge.asd
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
:serial t
:components ((:file "packages")
(:file "poiu")
(:file "events")
(:file "elements")
(:file "text-renderer")
(:file "rendering-backend")
Expand Down
39 changes: 35 additions & 4 deletions poiu/elements.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,48 @@
;;;
;;;
;;;
(defclass widget () ())
(defclass widget ()
((name :initarg :name :initform nil :reader name-of)))


;;;
;;;
;;;
(defclass label-button (widget)
((label :initarg :label :initform (error ":label missing"))))


(defun make-label-button (text)
(make-instance 'label-button :label text))
(defun make-label-button (text &key name)
(make-instance 'label-button :label text :name name))


(defmethod compose ((this label-button))
(with-slots (label) this
(%nk:button-label *handle* label)))
(unless (= (%nk:button-label *handle* label) 0)
;; fixme: propagate event system here somehow
(post (make-button-click-event this) (events)))))


;;;
;;;
;;;
(defclass label (widget)
((text :initarg :text :initform (error ":text missing"))
(align :initarg :align :initform (error ":align missing"))))


(defun text-align->nk (align)
(ecase align
(:left %nk:+text-align-left+)))


(defun make-text-label (text &key name (align :left))
(make-instance 'label
:text text
:name name
:align (text-align->nk align)))


(defmethod compose ((this label))
(with-slots (text align) this
(%nk:label *handle* text align)))
11 changes: 11 additions & 0 deletions poiu/events.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(in-package :cl-bodge.poiu)


(defevent button-click-event ()
(poiu-button))



(defun register-poiu-events (event-system)
(register-event-classes event-system
'button-click-event))
10 changes: 8 additions & 2 deletions poiu/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
(defpackage :cl-bodge.poiu
(:nicknames :ge.poiu)
(:use :cl :cl-bodge.engine :cl-bodge.utils :cl-bodge.graphics :plus-c
:cl-bodge.canvas :autowrap :cl-bodge.text :cl-bodge.assets)
:cl-bodge.canvas :autowrap :cl-bodge.text :cl-bodge.assets :cl-bodge.event)
(:export make-poiu-context
clear-poiu-context

make-poiu
compose-poiu
name-of
window
make-window
make-menu-bar
make-static-row-layout
make-dynamic-row-layout
make-label-button
make-text-label

with-poiu-input
register-cursor-position
register-mouse-input))
register-mouse-input

button-click-event
poiu-button-from
register-poiu-events))

0 comments on commit 975afde

Please sign in to comment.