Skip to content

Commit 6bae3ad

Browse files
committed
新增微信例子
1 parent 3c53ebb commit 6bae3ad

8 files changed

Lines changed: 109 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ QQ群:Lisp兴趣小组239401374
2828

2929
<img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/new-gui.jpg" width="400px" /><img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/new-gui2.jpg" width="400px" />
3030

31-
<img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/game-demo.png" width="400px" /><img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/gui-demo.png" width="400px" />
31+
<img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/game-demo.png" width="400px" /><img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/wechat-demo.png" width="400px" />
3232

3333

3434
<img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/draw-image.png" width="400px" /> <img src="https://raw.githubusercontent.com/evilbinary/scheme-lib/master/data/screenshot/box2d-demo.png" width="400px" />

apps/wechat-demo.ss

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
;Copyright 2016-2080 evilbinary.
3+
;作者:evilbinary on 10/20/18.
4+
;邮箱:rootdebug@163.com
5+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6+
(import (scheme)
7+
(glfw glfw)
8+
(gui graphic)
9+
(gui duck)
10+
(gui stb)
11+
(gles gles1)
12+
(gui window)
13+
(gui layout)
14+
(gui widget)
15+
(cffi cffi)
16+
(gui video)
17+
(utils libutil) (utils macro) )
18+
19+
(define window '() )
20+
(define width 840)
21+
(define height 700)
22+
;;(cffi-log #t)
23+
24+
(define avatar-demo '())
25+
26+
(define (chat-item w h name tip time)
27+
(let ((it (view w h))
28+
)
29+
(widget-add-draw
30+
it
31+
(lambda (w p)
32+
(let ((x (vector-ref w %gx))
33+
(y (vector-ref w %gy)))
34+
(draw-text (+ x 68.0) (+ y 16) name #x4a4a4a)
35+
(draw-text (+ x 68.0) (+ y 40.0) tip #xb0b0b0)
36+
(draw-text (+ x 220.0) (+ y 16.0) time #xbababa)
37+
38+
(draw-image (+ x 12.0) (+ y 16.0) 48.0 48.0 avatar-demo)
39+
)
40+
))
41+
(widget-set-padding it 15.0 20.0 20.0 20.0)
42+
it
43+
))
44+
45+
(define (wechat-app)
46+
(set! window (window-create width height "微信"))
47+
(window-set-fps-pos 750.0 0.0)
48+
;;(window-set-fps-pos 0.0 0.0)
49+
(window-show-fps #t)
50+
;;init res
51+
(set! avatar-demo (load-texture "duck.png"))
52+
53+
;;widget add here
54+
(let ((main (view (* 1.0 width) %match-parent))
55+
(left (view 70.0 %match-parent ))
56+
(mid (view 266.0 %match-parent))
57+
(right (view 500.0 %match-parent ))
58+
(avatar (image 46.0 46.0 "duck.png"))
59+
(chat (image 32.0 32.0 "chat.png"))
60+
(contact (image 26.0 26.0 "contact.png"))
61+
(collect (image 26.0 26.0 "collect.png"))
62+
(setting (image 26.0 26.0 "setting.png"))
63+
(wechat (image 70.0 70.0 "wechat.png"))
64+
65+
)
66+
67+
(widget-add main left)
68+
(widget-add main mid)
69+
(widget-add main right)
70+
71+
(widget-set-margin avatar 10.0 10.0 40.0 40.0)
72+
(widget-set-margin chat 18.0 10.0 40.0 40.0)
73+
(widget-set-margin contact 20.0 10.0 40.0 40.0)
74+
(widget-set-margin collect 20.0 10.0 40.0 40.0)
75+
(widget-set-margin setting 20.0 10.0 340.0 40.0)
76+
77+
(widget-set-margin wechat 200.0 200.0 280.0 40.0)
78+
79+
(widget-add left avatar)
80+
(widget-add left chat)
81+
(widget-add left contact)
82+
(widget-add left collect)
83+
(widget-add left setting)
84+
(widget-add right wechat)
85+
86+
(let loop
87+
((i 0)
88+
(item (chat-item %match-parent 70.0 "鸭子" "哇哈哈" "12:02")))
89+
(if (< i 40)
90+
(begin
91+
(widget-set-attrs item 'background #xf3f3f3)
92+
(widget-add mid item)
93+
(loop (+ i 1) (chat-item %match-parent 70.0 "Lisp兴趣小组" "测试消息" "12:02")))
94+
))
95+
96+
(widget-set-attrs left 'background #x262626)
97+
(widget-set-attrs right 'background #x00ffffff)
98+
(widget-add main)
99+
)
100+
101+
;;run
102+
(window-loop window)
103+
(window-destroy window)
104+
)
105+
106+
(wechat-app)
107+
108+

bin/chat.png

4.61 KB
Loading

bin/collect.png

8.93 KB
Loading

bin/contact.png

7.14 KB
Loading

bin/setting.png

6.65 KB
Loading

bin/wechat.png

7.74 KB
Loading

data/screenshot/wechat-demo.png

164 KB
Loading

0 commit comments

Comments
 (0)