glgui chat - part-cw/lambdanative GitHub Wiki
(glgui-chat g x y w h dh lst fnt cb)
glgui-chat adds a chat dialog (list) to the screen.
Parameter | Description |
---|---|
g | Graphical User Interface (GUI) for this widget |
x | Lower left corner along the x-axis in pixels |
y | Lower left corner along the y-axis in pixels |
w | Width of the element in pixels |
h | Height of the element in pixels |
dh | The line element height for timestamps and minimal row height for text |
lst | The chat list of lists [timestamp, name or (list name colour), string, received(0)/sent(1)/alert(2)] |
fnt | The font used to render all strings |
cb | The callback function when an element is clicked |
Attributes
Besides the parameters set in the procedure, the widget has the following attributes that can be set using glgui-widget-set!:
Attribute | Default Value | Description |
---|---|---|
hidden | False | If true, the widget is not displayed. |
bgcol1 | (color-shade White 0.2) | The background color of sent messages. |
bgcol2 | (color:shuffle #x021c4dff) | The background color of received messages. |
bgcol3 | (color:shuffle #xb8860bff) | The background color of alerts (messages spanning width of widget). |
txtcol | White | Color of message text. |
tscol | White | Color of timestamp text. |
group | False | True if widget should be rendered as a group chat. In a group chat, received messages will include the name of the message author; their name will not be displayed if they send consecutive messages. Each name appears as a different color, which is assigned by default. It can be specified by substituting the name parameter of a chat message with a list of name and color (see Example 2). |
Example
Example 1: Place a chat dialog the middle of the screen, and fill it with some text. Can be copied into DemoHelloWorld as is.
(glgui-chat gui 0 (/ (glgui-height-get) 4) (glgui-width-get) (/ (glgui-height-get) 2) 16
(list (list (- ##now 1000) "A" "Once upon a time there was a blue dinosaur." 1)
(list (- ##now 2200) "B" "Hope this will be interesting ..." 0)
(list (- ##now 2300) "B" "Okay." 0)
(list (- ##now 2500) "A" "Shell I tell you a story" 1)
(list (- ##now 2500) "B" "I am really bored right now" 0)
(list (- ##now 3000) "B" "The red fox jumps over the lazy dog." 0))
ascii_18.fnt #f)
Example 2: Place a chat near the bottom of the screen, fill it with some text, and set the group attribute to #t. Can be copied into DemoHelloWorld as is.
(set! chat (glgui-chat gui 0 (/ (glgui-height-get) 8) (glgui-width-get) (* (/ (glgui-height-get) 4) 3) 20
(list (list (- ##now 1000) "Annie" "Ok, I might be late but should be able to make it" 1)
(list (- ##now 2200) (list "Taylor" PaleVioletRed) "6 rounds of 10 questions" 0)
(list (- ##now 2300) (list "Taylor" PaleVioletRed) "8pm" 0)
(list (- ##now 2500) "Annie" "What time does it start?" 1)
(list (- ##now 2500) (list "Joe" LightGoldenrod) "Sure" 0)
(list (- ##now 3000) (list "Taylor" PaleVioletRed) "Trivia Night tomorrow, anybody want to go?" 0))
ascii_18.fnt #f))
(glgui-widget-set! gui chat 'group #t)