Check-in [7419b3e4b6]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplified code
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7419b3e4b64f17fc164b9023399b7be17950fae6
User & Date: bernd 2013-11-24 00:06:31
Context
2013-11-26
18:18
Added Freetype-GL swig file check-in: a3a8ae93a7 user: bernd tags: trunk
2013-11-24
00:06
Simplified code check-in: 7419b3e4b6 user: bernd tags: trunk
2013-11-22
00:25
Test slightly rewritten check-in: c180975216 user: bernd tags: trunk
Changes

Changes to button2.png.

cannot compute difference between binary files

Changes to button3.png.

cannot compute difference between binary files

Changes to widgets.fs.

39
40
41
42
43
44
45

46
47
48

49
50
51
52
53
54
55
..
57
58
59
60
61
62
63
64



65
66
67
68


69
70
71
72
73
74
75
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102



103
104
105
106
107
108
109
...
115
116
117
118
119
120
121


122
123

124
125
126
127
128
129
130
    field: d \ below baseline
    method draw
    method hglue
    method vglue
    method hglue@ \ cached variant
    method vglue@ \ cached variant
    method xywh

end-class widget

:noname x @ y @ h @ - w @ h @ d @ + ; widget to xywh


widget class
    field: child-w
    field: act
    method resized
    method map
end-class box
................................................................................
tex: style-tex \ 8 x 8 subimages, each sized 128x128
style-tex 1024 dup rgba-newtex

widget class
    field: frame#
    field: frame-color
end-class tile




: #>st ( x y frame -- ) \ using frame#
    8 /mod
    s>f f+ .125e f* fswap
    s>f f+ .125e f* fswap >st ;



: draw-rectangle { f: x1 f: y1 f: x2 f: y2 -- }
    i? >v
    x1 y2 >xy frame-color @ rgba>c n> 0e 1e frame# @ #>st v+
    x2 y2 >xy frame-color @ rgba>c n> 1e 1e frame# @ #>st v+
    x2 y1 >xy frame-color @ rgba>c n> 1e 0e frame# @ #>st v+
    x1 y1 >xy frame-color @ rgba>c n> 0e 0e frame# @ #>st v+
................................................................................
    field: border
end-class frame

Create button-st  0e sf, 0.25e sf, 0.75e sf, 1e sf,
Create button-border 0 c, 1 c, 3 c, 2 c,
Create button-triangles
0 c, 1 c, 4 c,   1 c, 4 c, 5 c,
1 c, 2 c, 5 c,   2 c, 5 c, 6 c,
2 c, 3 c, 6 c,   3 c, 6 c, 7 c,

4 c, 5 c, 8 c,   5 c, 8 c, 9 c,
5 c, 6 c, 9 c,   6 c, 9 c, 10 c,
6 c, 7 c, 10 c,  7 c, 10 c, 11 c,

8 c, 9 c, 12 c,   9 c, 12 c, 13 c,
9 c, 10 c, 13 c,  10 c, 13 c, 14 c,
10 c, 11 c, 14 c, 11 c, 14 c, 15 c,
here button-triangles - Constant button-triangles#




: frame-draw ( -- )
    frame# @ frame-color @ border @ xywh { f c b x y w h }
    i? >v
    4 0 DO
	4 0 DO
	    x b I button-border + c@ >r
................................................................................
	    c rgba>c
	    n>
	    I sfloats button-st + sf@
	    J sfloats button-st + sf@ f #>st v+
	LOOP
    LOOP
    v>


    button-triangles button-triangles# bounds DO
	dup I c@ + i,

    LOOP drop
; ' frame-draw frame to draw

: <draw ( -- )  v0 i0
    program glUseProgram  style-tex
    -1e 1e >apxy
    .01e 100e 100e >ap







>



>







 








>
>
>

|
<
<
>
>







 







<
<
<
<
<
<
<
<
<
<

>
>
>







 







>
>
|
|
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
..
59
60
61
62
63
64
65
66
67
68
69
70
71


72
73
74
75
76
77
78
79
80
..
90
91
92
93
94
95
96










97
98
99
100
101
102
103
104
105
106
107
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    field: d \ below baseline
    method draw
    method hglue
    method vglue
    method hglue@ \ cached variant
    method vglue@ \ cached variant
    method xywh
    method xywhd
end-class widget

:noname x @ y @ h @ - w @ h @ d @ + ; widget to xywh
:noname x @ y @ w @ h @ d @ ; widget to xywhd

widget class
    field: child-w
    field: act
    method resized
    method map
end-class box
................................................................................
tex: style-tex \ 8 x 8 subimages, each sized 128x128
style-tex 1024 dup rgba-newtex

widget class
    field: frame#
    field: frame-color
end-class tile

8 Value style-w#
8 Value style-h#

: #>st ( x y frame -- ) \ using frame#
    style-w# /mod


    s>f f+ style-w# fm/ fswap
    s>f f+ style-h# fm/ fswap >st ;

: draw-rectangle { f: x1 f: y1 f: x2 f: y2 -- }
    i? >v
    x1 y2 >xy frame-color @ rgba>c n> 0e 1e frame# @ #>st v+
    x2 y2 >xy frame-color @ rgba>c n> 1e 1e frame# @ #>st v+
    x2 y1 >xy frame-color @ rgba>c n> 1e 0e frame# @ #>st v+
    x1 y1 >xy frame-color @ rgba>c n> 0e 0e frame# @ #>st v+
................................................................................
    field: border
end-class frame

Create button-st  0e sf, 0.25e sf, 0.75e sf, 1e sf,
Create button-border 0 c, 1 c, 3 c, 2 c,
Create button-triangles
0 c, 1 c, 4 c,   1 c, 4 c, 5 c,










here button-triangles - Constant button-triangles#
Create button-triangle-off
0 c, 1 c, 2 c,  4 c, 5 c, 6 c,  8 c, 9 c, 10 c,
here button-triangle-off - Constant button-triangle-off#

: frame-draw ( -- )
    frame# @ frame-color @ border @ xywh { f c b x y w h }
    i? >v
    4 0 DO
	4 0 DO
	    x b I button-border + c@ >r
................................................................................
	    c rgba>c
	    n>
	    I sfloats button-st + sf@
	    J sfloats button-st + sf@ f #>st v+
	LOOP
    LOOP
    v>
    button-triangle-off button-triangle-off# bounds DO
	dup I c@ +
	button-triangles button-triangles# bounds DO
	    dup I c@ + i,
	LOOP drop
    LOOP drop
; ' frame-draw frame to draw

: <draw ( -- )  v0 i0
    program glUseProgram  style-tex
    -1e 1e >apxy
    .01e 100e 100e >ap