Changeset 540
- Timestamp:
- 07/04/08 03:46:13 (2 months ago)
- Location:
- trunk/thune
- Files:
-
- 4 added
- 34 modified
-
array.c (modified) (1 diff)
-
boot.c (modified) (3 diffs)
-
doc/GLManual (modified) (4 diffs)
-
doc/UserManual (modified) (2 diffs)
-
eval.c (modified) (3 diffs)
-
gl/CMakeLists.txt (modified) (1 diff)
-
gl/TexFont.c (modified) (3 diffs)
-
gl/TexFont.h (modified) (1 diff)
-
gl/boot.c (modified) (1 diff)
-
gl/draw_list.c (modified) (6 diffs)
-
gl/gui.c (modified) (20 diffs)
-
gl/gui.h (modified) (5 diffs)
-
gl/gx.c (modified) (2 diffs)
-
gl/gx.h (modified) (2 diffs)
-
gl/gx.t (modified) (2 diffs)
-
gl/gx_dt.c (modified) (5 diffs)
-
gl/project.r (modified) (1 diff)
-
gl/rfont.c (modified) (3 diffs)
-
gl/rfont.h (modified) (1 diff)
-
gl/scripts/gui.t (modified) (5 diffs)
-
gl/scripts/mandelbrot.t (added)
-
gl/scripts/photobooth.t (added)
-
gl/scripts/show-font.t (added)
-
gl/test.t (modified) (1 diff)
-
gl/testfw.t (modified) (1 diff, 1 prop)
-
gl/widgets/buttonw.c (modified) (1 diff)
-
gl/widgets/labelw.c (modified) (1 diff)
-
gl/widgets/lineeditw.c (added)
-
gl/widgets/twidget.c (modified) (1 diff)
-
math.c (modified) (5 diffs)
-
mkboot.t (modified) (3 diffs)
-
print.c (modified) (3 diffs)
-
series.c (modified) (10 diffs)
-
tests/working/time.good (modified) (1 diff)
-
tests/working/time.t (modified) (2 diffs)
-
thune-gl.spec (modified) (1 diff)
-
tokenize.c (modified) (5 diffs)
-
urlan.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/array.c
r255 r540 182 182 183 183 184 /** 185 Create space in the array for count elements starting at index. 186 The memory in the new space is uninitialized. 187 */ 188 void ur_arrayExpand( UArray* arr, int elemSize, int index, int count ) 189 { 190 ur_arrayReserve( arr, elemSize, arr->used + count ); 191 192 if( index < arr->used ) 193 { 194 char* buf = arr->ptr.c + (elemSize * index); 195 memMove( buf + (elemSize * count), buf, 196 elemSize * (arr->used - index) ); 197 } 198 199 arr->used += count; 200 } 201 202 184 203 /*EOF*/ -
trunk/thune/boot.c
r539 r540 59 59 " to-block kernel-ops infuse\n" 60 60 "] proc :load ;(filename -- block)\n" 61 "[open swap string! to write close] proc :save ;(value filename -- )\n" 61 62 "[select if-some do] proc :case\n" 62 63 "['break throw] proc :break\n" … … 75 76 "[ser words block! body block!]\n" 76 77 "[\n" 77 " ser [words set body do] words length? iter\n"78 " ser [words set body do] words length? iter\n" 78 79 "]\n" 79 80 "'loop func :each.set ;(ser words body -- )\n" … … 84 85 "[[do dup iff return drop] each true] proc :all ; (blk -- logic)\n" 85 86 "[ser old new | len] [\n" 86 " old length? :len\n"87 " ser old find if-some (new len change :ser recurse)\n"88 " ser\n"87 " old length? :len\n" 88 " ser old find if-some (new len change :ser recurse)\n" 89 " ser\n" 89 90 "] func :replace.all ;(ser old new -- ser)\n" 90 91 "[reduce to-text console.out] proc :prin ;(val -- )\n" -
trunk/thune/doc/GLManual
r537 r540 64 64 :: 65 65 66 (raster! w,h,b -- raster)66 (raster! w,h,bpp -- raster) 67 67 68 68 … … 78 78 Font 79 79 ---- 80 :: 81 82 (font! ["font.name" 20 "chars abc" 256,128] -- font) 80 81 Fonts can be created from a TrueType file or from a raster and binary:: 82 83 (font! ["font-file.ttf" 20 char-set 256,128] -- font) 84 (font! [raster!/texture! binary!] -- font) 85 86 Font components can be selected with:: 87 88 font/raster 89 font/texture 90 font/binary ; Glyph data 83 91 84 92 … … 137 145 gl-max-textures ( -- count) GL_MAX_TEXTURE_UNITS 138 146 shadowmap (size -- framebuffer) Create shadowmap 147 blit (dst src coord -- dst) Copy from one raster to another 148 move-glyphs (font offset -- font) Move texture position of glyphs 139 149 ================ ====================== ====================== 140 150 … … 261 271 scale vec3!/number! glScalef() 262 272 font font! Set font used by text instruction 273 font/no-bind font! Set font, but don't bind texture 263 274 text [coord!] text Draw text in current font 264 275 sphere radius slices,stacks Draw textured GLUT sphere -
trunk/thune/doc/UserManual
r539 r540 569 569 read (file part -- data) Read beginning of file. 570 570 write (port data -- port) Write data to port. 571 load (file -- code) Read script from file.572 571 delete (file -- ) Remove file. 573 572 rename (file new -- ) Rename file. … … 599 598 Word Stack Usage Function 600 599 ========== ====================== ================= 600 load (file -- code) Read script from file. 601 save (val file -- ) Save value to file. 601 602 split-path (full -- path file) Split full path into path & file. 602 603 dirize (str -- str) Ensure trailing slash is present. -
trunk/thune/eval.c
r539 r540 764 764 return 1; 765 765 break; 766 767 case UT_DATE: 768 case UT_TIME: 769 if( ur_is(b, UT_DATE) || ur_is(b, UT_TIME) ) 770 { 771 if( ur_seconds(a) == ur_seconds(b) ) 772 return 1; 773 } 774 break; 766 775 } 767 776 return 0; … … 832 841 if( (a->ctx.wordBlk == b->ctx.wordBlk) && 833 842 (a->ctx.valBlk == b->ctx.valBlk) ) 843 return 1; 844 break; 845 846 case UT_DATE: 847 case UT_TIME: 848 if( ur_seconds(a) == ur_seconds(b) ) 834 849 return 1; 835 850 break; … … 1357 1372 ur_initType(val, UT_VEC3); 1358 1373 } 1374 break; 1375 1376 case UT_DATE: 1377 if( ur_is(val, UT_TIME) ) 1378 ur_type(val) = UT_DATE; 1379 break; 1380 1381 case UT_TIME: 1382 if( ur_is(val, UT_DATE) ) 1383 ur_type(val) = UT_TIME; 1359 1384 break; 1360 1385 } -
trunk/thune/gl/CMakeLists.txt
r537 r540 70 70 png_save.c 71 71 TexFont.c 72 raster.c 72 73 rfont.c 73 74 shader.c -
trunk/thune/gl/TexFont.c
r533 r540 132 132 it = (uint16_t*) KERN(tf); 133 133 swap16( it, it + tf->kern_size ); 134 } 135 } 136 137 138 /** 139 Change the texture position of all glyphs. 140 */ 141 void txf_moveGlyphs( TexFont* tf, int dx, int dy ) 142 { 143 TexFontGlyph* tgi = GLYPHS(tf); 144 TexFontGlyph* end = tgi + tf->glyph_count; 145 while( tgi != end ) 146 { 147 tgi->x += dx; 148 tgi->y += dy; 149 ++tgi; 134 150 } 135 151 } … … 352 368 // Most glyphs have no kerning adjustment, and those with it have only 353 369 // a handful (at least at small font sizes). 354 kern_space = count * 5; // 5 = 2glyphs + terminator370 kern_space = count * 7; // 7 = 3 glyphs + terminator 355 371 356 372 txf = (TexFont*) malloc( sizeof(TexFont) + … … 437 453 tgi->advance = FT_PIXELS(glyph->metrics.horiAdvance); 438 454 tgi->x = x /*+ tgi->xoffset*/; 455 #if 0 439 456 tgi->y = img->height - y + tgi->yoffset; 457 #else 458 tgi->y = y - tgi->yoffset; 459 #endif 440 460 441 461 #ifdef DUMP -
trunk/thune/gl/TexFont.h
r533 r540 61 61 const TexFontGlyph* right ); 62 62 extern void txf_swap( TexFont* ); 63 extern void txf_moveGlyphs( TexFont*, int dx, int dy ); 63 64 extern int txf_width( const TexFont*, const char* it, const char* end ); 64 65 extern int txf_lineSpacing( const TexFont* ); -
trunk/thune/gl/boot.c
r533 r540 27 27 " none :control-font\n" 28 28 " none :title-font\n" 29 " none :edit-font\n" 29 30 " none :label\n" 30 31 " none :area\n" 31 32 " none :window-margin\n" 32 33 " none :window\n" 33 " none :button-size -limit\n"34 " none :button-size\n" 34 35 " none :button-up\n" 35 36 " none :button-down\n" 36 37 " none :button-hover\n" 37 38 " none :label-dl\n" 39 " none :editor\n" 40 " none :editor-active\n" 41 " none :editor-cursor\n" 38 42 "]\n" 39 43 "context dup :gui-style-proto :gui-style\n" -
trunk/thune/gl/draw_list.c
r536 r540 242 242 Advances x. 243 243 */ 244 static TexFontGlyph* renderGlyphXY( const TexFont* txf, int c, 245 GLfloat* xp, GLfloat y, 244 static TexFontGlyph* renderGlyphXY( const TexFont* txf, 245 GLfloat texW, GLfloat texH, 246 int c, GLfloat* xp, GLfloat y, 246 247 const TexFontGlyph* leftGI ) 247 248 { 248 GLfloat w, h; 249 GLfloat tw, th; 249 GLfloat gw, gh; 250 250 GLfloat gx, gy; 251 251 GLfloat min_s, max_s; … … 257 257 if( tgi ) 258 258 { 259 w = (GLfloat) txf->tex_width; 260 h = (GLfloat) txf->tex_height; 261 262 tw = (GLfloat) tgi->width; 263 th = (GLfloat) tgi->height; 264 259 gw = (GLfloat) tgi->width; 260 gh = (GLfloat) tgi->height; 265 261 gx = (GLfloat) tgi->x; 266 262 gy = (GLfloat) tgi->y; 267 263 268 min_s = gx / w; 269 min_t = 1.0f - (gy / h); 270 max_s = (gx + tw) / w; 271 max_t = 1.0f - ((gy + th) / h); 264 min_s = gx / texW; 265 max_s = (gx + gw) / texW; 266 #if 0 267 min_t = 1.0f - (gy / texH); 268 max_t = 1.0f - ((gy + gh) / texH); 269 #else 270 min_t = gy / texH; 271 max_t = (gy - gh) / texH; 272 #endif 272 273 273 274 xkern = leftGI ? txf_kerning( txf, leftGI, tgi ) : 0; … … 278 279 279 280 glTexCoord2f( min_s, min_t ); glVertex2f( gx, gy ); 280 glTexCoord2f( max_s, min_t ); glVertex2f( gx + tw, gy );281 glTexCoord2f( max_s, max_t ); glVertex2f( gx + tw, gy + th );282 glTexCoord2f( min_s, max_t ); glVertex2f( gx, gy + th );281 glTexCoord2f( max_s, min_t ); glVertex2f( gx + gw, gy ); 282 glTexCoord2f( max_s, max_t ); glVertex2f( gx + gw, gy + gh ); 283 glTexCoord2f( min_s, max_t ); glVertex2f( gx, gy + gh ); 283 284 } 284 285 return tgi; … … 302 303 { 303 304 GLfloat x, y; 305 GLfloat tw, th; 304 306 TexFontGlyph* prev = 0; 307 308 tw = (GLfloat) tf->tex_width; 309 th = (GLfloat) tf->tex_height; 305 310 306 311 if( (it != end) ) … … 317 322 { 318 323 x = (GLfloat) tf->max_ascent; 319 y -= x * 1.5f; // Estimate of line spacing.324 y -= txf_lineSpacing( tf ); 320 325 x = grState.penX; 321 326 prev = 0; … … 328 333 else 329 334 { 330 prev = renderGlyphXY( tf, *it, &x, y, prev );335 prev = renderGlyphXY( tf, tw, th, *it, &x, y, prev ); 331 336 } 332 337 ++it; -
trunk/thune/gl/gui.c
r537 r540 59 59 #define WID(wp) (wp - ((GWidget*) ui->widgets.ptr.v)) 60 60 #define CLASS(wp) wclass[wp->classId] 61 #define IS_ENABLED(wp) (! (wp->flags & GW_DISABLED)) 61 62 62 63 #define EACH_CHILD(parent,it) \ … … 103 104 104 105 105 // Order must match gui-style-proto in gx.t.106 enum ContextIndexStyle107 {108 CI_STYLE_TEXTURE, // texture!109 CI_STYLE_TEX_SIZE, // coord!110 CI_STYLE_CONTROL_FONT, // font!111 CI_STYLE_TITLE_FONT, // font!112 CI_STYLE_LABEL, // Variable for use by draw lists.113 CI_STYLE_AREA, // Variable for use by draw lists.114 CI_STYLE_WINDOW_MARGIN, // coord!115 CI_STYLE_WINDOW, // Draw list116 CI_STYLE_BUTTON_SIZE, // coord!117 CI_STYLE_BUTTON_UP, // Draw list118 CI_STYLE_BUTTON_DOWN, // Draw list119 CI_STYLE_BUTTON_HOVER, // Draw list120 CI_STYLE_LABEL_DL // Draw list121 };122 123 124 106 #define WCLASS_MAX 24 125 107 static GWidgetClass wclass[ WCLASS_MAX ]; … … 256 238 257 239 258 static GWidget* base_parse( GUI* ui, GMakeState* ms , int classId)240 static GWidget* base_parse( GUI* ui, GMakeState* ms ) 259 241 { 260 242 GWidget* wp; … … 309 291 310 292 // Future... 293 UIndex eventN; 311 294 uint8_t layoutType; 312 295 uint8_t rows; 313 296 uint8_t cols; 314 uint8_t _pad[5];297 uint8_t _pad; 315 298 } 316 299 BoxData; … … 344 327 345 328 346 static GWidget* box_parse( GUI* ui, GMakeState* ms , int classId)329 static GWidget* box_parse( GUI* ui, GMakeState* ms ) 347 330 { 348 331 GWidget* wp; … … 721 704 722 705 723 static GWidget* window_parse( GUI* ui, GMakeState* ms , int classId)706 static GWidget* window_parse( GUI* ui, GMakeState* ms ) 724 707 { 725 708 GWidget* wp; 726 709 UAtom sel = ur_sel(ms->it); 727 wp = box_parse( ui, ms , classId);710 wp = box_parse( ui, ms ); 728 711 if( wp ) 729 712 { … … 740 723 BoxData* wd = BOX_DATA(wp); 741 724 (void) ui; 742 743 wp->flags |= GW_DISABLED; // Does not handle input.744 725 745 726 wd->marginL = 8; … … 769 750 770 751 752 static void window_event( GUI* ui, GWidget* wp, const GLViewEvent* ev ) 753 { 754 BoxData* wd = BOX_DATA(wp); 755 756 (void) ui; 757 758 if( wd->eventN ) 759 { 760 if( ev->type == GLV_EVENT_CLOSE ) 761 { 762 } 763 } 764 } 765 766 771 767 static void window_sizeHint( GUI* ui, GWidget* wp, GSizeHint* size ) 772 768 { … … 825 821 #include "widgets/labelw.c" 826 822 #include "widgets/twidget.c" 823 #include "widgets/lineeditw.c" 827 824 //#include "widgets/listw.c" 828 825 … … 838 835 */ 839 836 840 static int wclassCount = 7;837 static int wclassCount = 8; 841 838 842 839 static GWidgetClass wclass[ WCLASS_MAX ] = … … 858 855 859 856 { "window", 860 window_parse, window_init, window_mark, no_event,857 window_parse, window_init, window_mark, window_event, 861 858 window_sizeHint, window_layout, window_render, base_select, 862 859 0, 0, 0 }, … … 875 872 twidget_parse, twidget_init, twidget_mark, twidget_event, 876 873 expand_sizeHint, twidget_layout, twidget_render, base_select, 874 0, 0, 0 }, 875 876 { "line-edit", 877 ledit_parse, ledit_init, ledit_mark, ledit_event, 878 ledit_sizeHint, ledit_layout, ledit_render, ledit_select, 877 879 0, 0, 0 }, 878 880 … … 972 974 973 975 976 static void gui_callFocus( GUI* ui, GWidgetId id, int eventType ) 977 { 978 if( IS_VALID(id) ) 979 { 980 GWidget* w = WPTR(id); 981 if( IS_ENABLED(w) ) 982 { 983 GLViewEvent me; 984 INIT_EVENT( me, eventType, 0, 0, 0, 0 ); 985 CLASS( w ).dispatch( ui, w, &me ); 986 } 987 } 988 } 989 990 974 991 void gui_setMouseFocus( GUI* ui, GWidgetId id ) 975 992 { 976 ui->mouseFocus = id; 993 if( ui->mouseFocus != id ) 994 { 995 gui_callFocus( ui, ui->mouseFocus, GLV_EVENT_FOCUS_OUT ); 996 ui->mouseFocus = id; 997 gui_callFocus( ui, id, GLV_EVENT_FOCUS_IN ); 998 } 977 999 } 978 1000 … … 994 1016 995 1017 1018 /* 1019 Returns child of wp under event x,y, or wp if no child contains the point. 1020 */ 996 1021 static GWidget* childAt( GUI* ui, GWidget* wp, const GLViewEvent* ev ) 997 1022 { … … 1030 1055 switch( ev->type ) 1031 1056 { 1057 case GLV_EVENT_CLOSE: 1058 { 1059 GWidgetIt it; 1060 EACH_SHOWN_ROOT( it ) 1061 w = it.w; 1062 goto dispatch; 1063 EACH_END 1064 } 1065 return; 1066 1032 1067 case GLV_EVENT_BUTTON_DOWN: 1033 1068 case GLV_EVENT_BUTTON_UP: … … 1051 1086 { 1052 1087 w = WPTR(ui->mouseFocus); 1053 if( ui->mouseGrabbed || 1054 gui_widgetContains( w, ev->x, ev->y ) ) 1088 if( ui->mouseGrabbed ) 1055 1089 { 1056 1090 goto dispatch; 1057 1091 } 1058 else 1092 else if( gui_widgetContains( w, ev->x, ev->y ) ) 1059 1093 { 1060 GLViewEvent me; 1061 INIT_EVENT( me, GLV_EVENT_FOCUS_OUT, 0, 1062 ev->state, ev->x, ev->y ); 1063 CLASS( w ).dispatch( ui, w, &me ); 1094 GWidget* cw = childAt( ui, w, ev ); 1095 if( cw != w ) 1096 { 1097 gui_setMouseFocus( ui, WID(cw) ); 1098 w = cw; 1099 } 1100 goto dispatch; 1064 1101 } 1065 1102 } 1066 1103 1067 ui->mouseFocus = widgetAt( ui, ev);1104 gui_setMouseFocus( ui, widgetAt( ui, ev ) ); 1068 1105 if( IS_VALID(ui->mouseFocus) ) 1069 1106 { 1070 1107 w = WPTR(ui->mouseFocus); 1071 if( ! (w->flags & GW_DISABLED) ) 1072 { 1073 GLViewEvent me; 1074 INIT_EVENT( me, GLV_EVENT_FOCUS_IN, 0, 1075 ev->state, ev->x, ev->y ); 1076 CLASS( w ).dispatch( ui, w, &me ); 1077 goto dispatch; 1078 } 1108 goto dispatch; 1079 1109 } 1080 1110 break; … … 1363 1393 if( cl->nameAtom == atom ) 1364 1394 { 1365 wp = cl->parse( ui, ms, cl->id ); 1395 ms->classId = cl->id; 1396 wp = cl->parse( ui, ms ); 1366 1397 if( wp ) 1367 1398 { … … 1412 1443 /* 1413 1444 Returns pointer to first arg if all types match, or zero. 1445 Unlike gui_matchArg(), this function does not throw an error if it fails. 1414 1446 */ 1415 1447 const UCell* gui_matchArgs( GMakeState* ms, int argc, ... ) … … 1437 1469 if( argc ) 1438 1470 return 0; 1471 1439 1472 ms->it = it; 1440 1473 return first; 1474 } 1475 1476 1477 /* 1478 Get and verify next argument. 1479 Returns pointer to arg cell if type matches, or zero. 1480 Throws an error if fails. 1481 */ 1482 const UCell* gui_matchArg( UThread* ut, GMakeState* ms, int type )
