Changeset 528
- Timestamp:
- 05/30/08 18:36:20 (4 months ago)
- Location:
- trunk/thune
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gl/gui.c
r527 r528 29 29 [x] Layout 30 30 [/] Input 31 [ ] Replace old widget code (gx.t) with widget class for all-Thune code.32 [ ] Convert all demos.33 31 */ 34 32 … … 90 88 ms.x = ex; \ 91 89 ms.y = ey 90 92 91 93 92 #define SET_AREA(wp,rect) \ … … 201 200 static GWidget* base_parse( GUI* ui, GMakeState* ms, int classId ) 202 201 { 203 GWidget* wp = gui_allocWidget( ui, classId ); 204 if( wp ) 205 ++ms->it; 206 else 207 ms->error = "allocWidget failed"; 202 GWidget* wp; 203 GUI_PARSE_ALLOC( wp ) 204 ++ms->it; 208 205 return wp; 209 206 } … … 331 328 { 332 329 no_block: 333 ms->error = "box requires block!"; 334 return 0; 330 GUI_PARSE_ERR( "box requires block!" ); 335 331 } 336 332 if( ur_is(bc, UT_COORD) ) … … 343 339 goto no_block; 344 340 345 wp = gui_allocWidget( ui, classId );346 if( wp ) 341 GUI_PARSE_ALLOC( wp ) 342 347 343 { 348 344 GMakeState cms; … … 364 360 } 365 361 ms->it = bc + 1; 366 }367 else368 {369 ms->error = "allocWidget failed";370 362 } 371 363 return wp; … … 829 821 GWidget* wp; 830 822 ButtonData* wd; 831 //UThread* ut = ui->ut; 832 const UCell* sc = ms->it + 1; 833 const UCell* bc = ms->it + 2; 834 835 if( ((ms->end - ms->it) < 3) || 836 (! ur_is(sc, UT_STRING)) || 837 (! ur_is(bc, UT_BLOCK)) ) 838 { 839 ms->error = "button requires string! and block!"; 840 return 0; 841 } 842 843 wp = gui_allocWidget( ui, classId ); 844 if( ! wp ) 845 { 846 ms->error = "allocWidget failed"; 847 return 0; 848 } 849 850 wd = BUTTON_DATA(wp); 851 wd->labelN = sc->series.n; 852 wd->codeN = bc->series.n; 853 854 ms->it += 3; 855 return wp; 823 const UCell* arg0; 824 825 arg0 = gui_matchArgs( ms, 2, UT_STRING, UT_BLOCK ); 826 if( arg0 ) 827 { 828 GUI_PARSE_ALLOC( wp ) 829 830 wd = BUTTON_DATA(wp); 831 wd->labelN = arg0->series.n; 832 wd->codeN = (arg0 + 1)->series.n; 833 return wp; 834 } 835 836 GUI_PARSE_ERR( "button requires string! and block!" ); 856 837 } 857 838 … … 958 939 if( wd->codeN ) 959 940 { 960 if( UR_EVAL_ ERROR == ur_eval( ui->ut, wd->codeN, 0 ) )941 if( UR_EVAL_OK != ur_eval( ui->ut, wd->codeN, 0 ) ) 961 942 { 962 // TODO: Throw or catch error.943 UG_GUI_THROW; 963 944 } 964 945 } … … 1062 1043 1063 1044 #include "widgets/twidget.c" 1064 1065 1066 static int wclassCount = 6; 1045 #include "widgets/listw.c" 1046 1047 /* 1048 :tok 1049 'expand (tok make-widget) 1050 | 'hbox block! (tok make-widget) 1051 | 'vbox block! (tok make-widget) 1052 | 'window block! (tok make-widget) 1053 | 'button string! block! (tok make-widget) 1054 | 't-widget block! (tok make-widget) 1055 | 'list block! block! (tok make-widget) 1056 */ 1057 1058 static int wclassCount = 7; 1067 1059 1068 1060 static GWidgetClass wclass[ WCLASS_MAX ] = … … 1098 1090 0, 0, 0 }, 1099 1091 1092 { "list", // "block! block!" 1093 listw_parse, listw_init, listw_mark, listw_event, 1094 expand_sizeHint, listw_layout, listw_render, 1095 0, 0, 0 }, 1096 1100 1097 /* 1101 1098 { "option", 1102 1099 { "choice", 1103 { "list",1104 1100 { "menu", 1105 1101 { "data", // label … … 1588 1584 1589 1585 /* 1586 Returns pointer to first arg if all types match, or zero. 1587 */ 1588 const UCell* gui_matchArgs( GMakeState* ms, int argc, ... ) 1589 { 1590 va_list args; 1591 int type; 1592 const UCell* it; 1593 const UCell* first = ms->it + 1; 1594 1595 if( (ms->end - first) < argc ) 1596 return 0; 1597 it = first; 1598 1599 va_start( args, argc ); 1600 while( argc ) 1601 { 1602 type = va_arg( args, int ); 1603 if( ur_type(it) != type ) 1604 break; 1605 ++it; 1606 --argc; 1607 } 1608 va_end( args ); 1609 1610 if( argc ) 1611 return 0; 1612 ms->it = it; 1613 return first; 1614 } 1615 1616 1617 /* 1590 1618 Only mark and sweep on top-level (parent-less) widgets. 1591 1619 */ -
trunk/thune/gl/gui.h
r527 r528 67 67 int16_t maxW; 68 68 int16_t maxH; 69 int8_tweightX;70 int8_tweightY;71 int8_tpolicyX;72 int8_tpolicyY;69 uint8_t weightX; 70 uint8_t weightY; 71 uint8_t policyX; 72 uint8_t policyY; 73 73 } 74 74 GSizeHint; … … 149 149 150 150 GWidget* gui_allocWidget( GUI*, int classId ); 151 //void gui_freeWidget( GUI*, GWidgetId );152 151 GWidget* gui_widgetPtr( GUI*, GWidgetId ); 153 152 void gui_link( GUI*, GWidget* parent, GWidgetId child ); 154 //void gui_unlink( GUI*, GWidgetId );155 153 void gui_enable( GUI*, GWidget*, int active ); 156 154 void gui_show( GUI*, GWidget*, int show ); … … 158 156 void gui_render( GUI*, GWidgetId ); 159 157 GWidget* gui_parseLayout( GUI*, GWidget* parent, GMakeState* ); 158 const UCell* gui_matchArgs( GMakeState* ms, int argc, ... ); 160 159 GWidget* gui_root( const GUI* ui, GWidgetId id ); 161 160 void gui_initRectCoord( UCell*, GWidget*, int len ); … … 165 164 166 165 166 #define GUI_PARSE_ERR(msg) \ 167 ms->error = msg; \ 168 return 0 169 170 #define GUI_PARSE_ALLOC(wp) \ 171 wp = gui_allocWidget(ui, classId); \ 172 if(! wp) { GUI_PARSE_ERR( "allocWidget failed" ); } 173 174 167 175 #endif /*GUI_H*/ -
trunk/thune/gl/gx.c
r527 r528 209 209 { 210 210 #if 1 211 // Set mouse deltas here so no one else need to calculate them.211 // Set mouse deltas here so no one else needs to calculate them. 212 212 if( env->prevMouseX == MOUSE_UNSET ) 213 213 { … … 500 500 501 501 UR_CALL_UNUSED_TOS 502 503 // Set handler in case UG_GUI_THROW has removed it. 504 glv_setEventHandler( gView, eventHandler ); 502 505 503 506 if( inv && (ur_sel(inv) == UR_ATOM_WAIT) ) -
trunk/thune/gl/gx.h
r527 r528 208 208 #define ur_fboTexPool(c) ((UCellFramebuffer*) (c))->glTexPool 209 209 210 #define UG_GUI_THROW glv_setEventHandler(gxEnv.view, 0) 211 210 212 211 213 #endif /*GX_H*/ -
trunk/thune/gl/widgets/twidget.c
r527 r528 49 49 { 50 50 GWidget* wp; 51 int ok; 52 const UCell* arg0; 51 53 UThread* ut = ui->ut; 52 int ok; 53 const UCell* bc = ms->it + 1; 54 55 if( ((ms->end - ms->it) < 2) || (! ur_is(bc, UT_BLOCK)) ) 56 { 57 ms->error = "t-widget requires block!"; 58 return 0; 59 } 60 61 wp = gui_allocWidget( ui, classId ); 62 if( ! wp ) 63 { 64 ms->error = "allocWidget failed"; 65 return 0; 66 } 67 68 UR_S_PUSH( *bc ); 69 ok = ur_evalCStr( ut, "t-widget-context", 16 ); 70 if( ok != UR_EVAL_OK ) 71 return 0; 72 73 assert( ur_is(UR_TOS, UT_CONTEXT) ); 74 ur_copyCell( wp->cell, *UR_TOS ); 75 UR_S_DROP; 76 77 ms->it += 2; 78 return wp; 54 55 arg0 = gui_matchArgs( ms, 1, UT_BLOCK ); 56 if( arg0 ) 57 { 58 GUI_PARSE_ALLOC( wp ) 59 60 UR_S_PUSH( *arg0 ); 61 ok = ur_evalCStr( ut, "t-widget-context", 16 ); 62 if( ok != UR_EVAL_OK ) 63 return 0; 64 65 assert( ur_is(UR_TOS, UT_CONTEXT) ); 66 ur_copyCell( wp->cell, *UR_TOS ); 67 UR_S_DROP; 68 69 return wp; 70 } 71 GUI_PARSE_ERR( "t-widget requires block!" ); 79 72 } 80 73 … … 233 226 UR_S_DROP; 234 227 } 228 else 229 { 230 UG_GUI_THROW; 231 } 235 232 } 236 233 } -
trunk/thune/thune.c
r527 r528 668 668 669 669 case OP_THROW: // (val -- val) 670 UR_CALL_OP = OP_THROW; 670 671 goto op_throw; 671 672
