Skip to content

Commit 61ab953

Browse files
committed
新增样式
1 parent 4ddcec8 commit 61ab953

12 files changed

Lines changed: 1117 additions & 76 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ bin/*.boot
1111
bin/imgui.ini
1212
lib/scheme/scheme
1313

14-
lib/libglut
15-
lib/libscm
14+
lib/libglut
15+
lib/libscm
1616

apps/calc.ss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
(let ((exp "") (clear #t))
2222
(glut-init)
2323
(imgui-init)
24-
;(android)
24+
(imgui-reset-style 7)
25+
;(android)
2526
;(imgui-scale (* 1.5 (android-get-density)) (* 1.5 (android-get-density)))
2627
(glut-touch-event (lambda (type x y)
2728
(imgui-touch-event type x y)

gui/glut.ss

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
glut-hide-soft-input
2828
glut-event-get
2929

30+
glut-init-window-size
31+
glut-init-window-position
32+
3033
glut-init-callback
3134
glut-on-key-event-callback
3235
glut-on-touch-event-callback
@@ -45,6 +48,13 @@
4548

4649
(define lib (load-lib lib-name))
4750

51+
(define-syntax define-glut
52+
(syntax-rules ()
53+
((_ ret name args)
54+
(define name
55+
(foreign-procedure (lower-camel-case (string-split (symbol->string 'name) #\- )) args ret)))))
56+
57+
(define glut-init-proc '())
4858

4959
(define glut-display-proc '())
5060
(define glut-reshape-proc '())
@@ -53,9 +63,21 @@
5363
(define glut-motion-event-proc '())
5464
(define glut-mouse-event-proc '())
5565

56-
(define glut-init
66+
(define glut-init-op
5767
(foreign-procedure "glut_init" () void))
68+
69+
(define (glut-init . args)
70+
(if (= 0 (length args) )
71+
(glut-init-op)
72+
(if (procedure? (car args))
73+
(begin
74+
(set! glut-init-proc (car args) )
75+
(glut-init-op)
76+
)
77+
)))
5878

79+
80+
5981
(define glut-main-loop
6082
(foreign-procedure "glut_main_loop" () void))
6183

@@ -75,6 +97,11 @@
7597
(define glut-set-soft-input-mode
7698
(foreign-procedure "glut_set_soft_input_mode" (int int) void))
7799

100+
;;c function
101+
(define-glut void glut-init-window-size (int int ) )
102+
(define-glut void glut-init-window-position (int int ) )
103+
104+
78105
(define is-soft-input-show #f)
79106
(define glut-show-soft-input (lambda ()
80107
(if (not is-soft-input-show)
@@ -90,11 +117,13 @@
90117
))
91118

92119
(define (glut-init-callback)
93-
1
120+
(if (procedure? glut-init-proc)
121+
(glut-init-proc)
122+
)
94123
)
95124

96125
(define (glut-on-key-event-callback . args)
97-
;(glut-log (format "on-key-event callback arg==~a ~a\n" (length args) (car args) ) )
126+
(glut-log (format "on-key-event callback arg==~a ~a\n" (length args) (car args) ) )
98127
(if (procedure? glut-key-event-proc)
99128
(if (= 2 (length args) )
100129
(glut-key-event-proc (car args) (cadr args))

gui/imgui.ss

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
imgui-pvec2
2727
imgui-uvec2
2828

29+
imgui-load-style
30+
imgui-save-style
31+
imgui-reset-style
32+
2933
imgui-get-io
3034
imgui-text
3135
imgui-new-frame
@@ -45,6 +49,8 @@
4549
imgui-is-mouse-clicked
4650
imgui-is-mouse-down
4751
imgui-image
52+
imgui-tree-node
53+
imgui-tree-pop
4854

4955
;consts
5056
imgui-set-cond-always
@@ -60,24 +66,7 @@
6066
imgui-separator
6167
)
6268

63-
(import (scheme) (utils libutil) )
64-
(define (split str)
65-
(let f ((i 0) (n (string-length str)))
66-
(cond
67-
((= i n) (list (substring str 0 n) ))
68-
((char=? (string-ref str i) #\-)
69-
(cons (substring str 0 i)
70-
(split (substring str (+ i 1) n))))
71-
(else (f (+ i 1) n)))))
72-
(define (lower-camel-case l)
73-
(let loop
74-
((x l) (s "" ) (i 0) )
75-
(if (null? x)
76-
s
77-
(begin
78-
(if (> i 0)
79-
(string-set! (car x) 0 (char-upcase (string-ref (car x) 0))))
80-
(loop (cdr x) (string-append s (car x)) (+ i 1))))))
69+
(import (scheme) (utils libutil) )
8170

8271
(define lib-name
8372
(case (machine-type)
@@ -92,7 +81,7 @@
9281
(syntax-rules ()
9382
((_ ret name args)
9483
(define name
95-
(foreign-procedure (lower-camel-case (split (symbol->string 'name) )) args ret)))))
84+
(foreign-procedure (lower-camel-case (string-split (symbol->string 'name) #\- )) args ret)))))
9685

9786

9887
(define-ftype imgui-vec2 (struct [x float] [y float]))
@@ -121,6 +110,10 @@
121110
(define-c-function void* imgui-pvec2 (float float) )
122111
(define-c-function void imgui-uvec2 (void*) )
123112

113+
;;样式加载和修改
114+
(define-c-function boolean imgui-load-style (string) )
115+
(define-c-function boolean imgui-save-style (string) )
116+
(define-c-function boolean imgui-reset-style (int) )
124117

125118
(define-imgui void* imgui-get-io () )
126119
(define-imgui void imgui-render () )
@@ -135,6 +128,9 @@
135128
(define-imgui boolean imgui-button (string void*) )
136129
(define-imgui boolean imgui-small-button (string void*) )
137130
(define-imgui boolean imgui-checkbox (string u8*) )
131+
(define-imgui boolean imgui-tree-node (string) )
132+
(define-imgui void imgui-tree-pop () )
133+
138134

139135
(define-imgui boolean imgui-input-text (string string int int void* void*))
140136
(define-imgui boolean imgui-input-text-multiline (string string int int void* void* void* ) )

lib/libimgui/Android.mk

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,27 @@ SCM=$(LOCAL_PATH)/../libscm
2424

2525
LOCAL_MODULE := imgui
2626
LOCAL_SRC_FILES := imgui_impl_gl.cpp \
27-
imgui/imgui.cpp \
28-
imgui/imgui_draw.cpp \
29-
imgui/imgui_demo.cpp \
30-
cimgui/cimgui.cpp \
31-
cimgui/drawList.cpp \
32-
cimgui/fontAtlas.cpp \
27+
$(IMGUI)/imgui.cpp \
28+
$(IMGUI)/imgui_draw.cpp \
29+
$(IMGUI)/imgui_demo.cpp \
30+
$(CIMGUI)/cimgui.cpp \
31+
$(CIMGUI)/drawList.cpp \
32+
$(CIMGUI)/fontAtlas.cpp \
3333
main.cpp \
34-
keyboard.cpp
34+
keyboard.cpp \
35+
addons/imguistyleserializer/imguistyleserializer.cpp \
36+
3537

3638

3739

3840
LOCAL_ARM_MODE := arm
3941

40-
LOCAL_C_INCLUDES := imgui -I$(SCM)
42+
LOCAL_C_INCLUDES := imgui -I$(SCM) addons
4143

4244

43-
LOCAL_CFLAGS += -I. -I./c/ -I$(IMGUI) -I$(SCM)
44-
LOCAL_CXXFLAGS+= -I. -I./c/ -I$(IMGUI) -I$(SCM) -std=c++11
45+
LOCAL_CFLAGS += -I. -I./c/ -I$(IMGUI) -I$(SCM) -Iaddons -I$(LOCAL_PATH)/addons/imguistyleserializer
46+
LOCAL_CXXFLAGS+= -I. -I./c/ -I$(IMGUI) -I$(SCM) -DANDROID -std=c++11 \
47+
-I$(LOCAL_PATH)/addons/ -I$(LOCAL_PATH)/addons/imguistyleserializer
4548

4649
LOCAL_CFLAGS += -g -Wall -DANDROID -DINLINES -DGC_MACROS -fPIC -Wno-unused-parameter -pie -fPIE -fpermissive -std=c++11
4750

lib/libimgui/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ OBJS = main.o \
1515
cimgui/drawList.o \
1616
cimgui/fontAtlas.o \
1717
imgui_impl_glb.o \
18+
addons/imguistyleserializer/imguistyleserializer.o \
19+
1820
#test.o
1921

2022
LIBS =-L../libscm -lscm
2123
CFLAGS = -Wall -Wformat
22-
CXXFLAGS= -Wall -Wformat -Iimgui -I../libscm -g -std=c++11 -DLOG
24+
CXXFLAGS= -Wall -Wformat -Iimgui -I../libscm -g -std=c++11 -DLOG \
25+
-Iaddons/ \
26+
-Iaddons/imguistyleserializer
2327

2428
UNAME_S := $(shell uname -s)
2529
ifeq ($(UNAME_S), Linux) #LINUX

lib/libimgui/addons/imgui_user.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef IMGUI_INCLUDE_IMGUI_USER_INL
2+
#define IMGUI_INCLUDE_IMGUI_USER_INL
3+
4+
#ifndef NO_IMGUISTYLESERIALIZER
5+
#include "./imguistyleserializer/imguistyleserializer.h"
6+
#endif //NO_IMGUISTYLESERIALIZER
7+
#ifndef NO_IMGUICODEEDITOR
8+
//#include "./imguicodeeditor/imguicodeeditor.h"
9+
#endif //NO_IMGUICODEEDITOR
10+
11+
12+
#endif
13+
14+

0 commit comments

Comments
 (0)