/* line-edit word!/string! <max-chars> */ static GWidget* ledit_make( UThread* ut, UBlockIter* bi, const GWidgetClass* wclass ) { LineEdit* ep; const UCell* arg[2]; int maxChars = 32; if( ! gui_parseArgs( ut, bi, wclass, ledit_args, arg ) ) return 0; if( ur_isShared( arg[0]->series.buf ) ) { ur_error( ut, UR_ERR_SCRIPT, "line-edit cannot modify shared string" ); return 0; } if( arg[1] ) maxChars = ur_int(arg[1]); ep = (LineEdit*) gui_allocWidget( sizeof(LineEdit), wclass ); ep->wid.flags |= CHANGED; //ep->state = LEDIT_STATE_DISPLAY; ep->strN = arg[0]->series.buf; ep->maxChars = maxChars; ep->vboN = ledit_vbo( ut, maxChars ); return (GWidget*) ep; }
static GWidget* slider_make( UThread* ut, UBlockIter* bi, const GWidgetClass* wclass ) { GSlider* ep; const UCell* arg[4]; if( ! gui_parseArgs( ut, bi, wclass, slider_args, arg ) ) return 0; ep = (GSlider*) gui_allocWidget( sizeof(GSlider), wclass ); ep->state = BTN_STATE_UP; // Optional orientaion. if( arg[0] ) { const char* word = ur_atomCStr( ut, arg[0]->word.atom ); ep->orient = (word[0] == 'h') ? HORIZONTAL : VERTICAL; } else if( wclass == &wclass_scrollbar ) { ep->orient = VERTICAL; } if( ur_is(arg[1], UT_COORD) ) { ep->data.val = ep->data.min = (float) arg[1]->coord.n[0]; ep->data.max = (float) arg[1]->coord.n[1]; ep->data.vsize = (float) arg[1]->coord.n[2]; ep->dataType = UT_INT; } else { ep->data.val = ep->data.min = arg[1]->vec3.xyz[0]; ep->data.max = arg[1]->vec3.xyz[1]; ep->data.vsize = arg[1]->vec3.xyz[2]; ep->dataType = UT_DECIMAL; } slider_setValue( ep, arg[2] ); // Optional action block. if( arg[3] ) ep->actionN = arg[3]->series.buf; return (GWidget*) ep; }
static GWidget* itemview_make( UThread* ut, UBlockIter* bi, const GWidgetClass* wclass ) { GItemView* ep; UIndex itemBlkN; const UCell* arg[3]; //int ok; if( ! gui_parseArgs( ut, bi, wclass, itemview_args, arg ) ) return 0; ep = (GItemView*) gui_allocWidget( sizeof(GItemView), wclass ); assert( sizeof(GLint) == sizeof(GLsizei) ); ur_arrInit( ep->fc + 0, sizeof(GLint), 0 ); ur_arrInit( ep->fc + 1, sizeof(GLint), 0 ); glGenBuffers( 2, ep->vbo ); ep->vboSize[0] = ep->vboSize[1] = 0; ep->use_color = -1; ep->selCol = -1; ep->selRow = -1; ep->itemCount = 0; ep->itemWidth = 0; ep->itemHeight = 0; ep->scrollY = 0; ep->modVbo = 0; ep->updateMethod = IV_UPDATE_2; ep->layoutBlkN = UR_INVALID_BUF; ep->selectBgBlkN = UR_INVALID_BUF; ep->bindCtxN = UR_INVALID_BUF; ep->actionBlkN = UR_INVALID_BUF; itemBlkN = arg[0]->series.buf; if( ur_isShared( itemBlkN ) ) ep->dataBlkN = UR_INVALID_BUF; else ep->dataBlkN = itemBlkN; // Optional action block. if( arg[2] ) ep->actionBlkN = arg[2]->series.buf; //-------------------------------------------- // Parse layout block [size coord! item block! selected block!] { UBlockIterM bi; UBuffer* ctx; if( ur_blkSliceM( ut, &bi, arg[1] ) != UR_OK ) goto fail; if( (bi.end - bi.it) < 3 ) goto bad_layout; ctx = gui_styleContext( ut ); if( ctx ) ur_bind( ut, bi.buf, ctx, UR_BIND_THREAD ); if( ur_is(bi.it, UT_COORD) ) { // Fixed layout. static char itemStr[] = "item"; UBuffer* blk; if( ! ur_is(bi.it + 1, UT_BLOCK) || ! ur_is(bi.it + 2, UT_BLOCK) ) goto bad_layout; ep->itemWidth = bi.it->coord.n[0]; ep->itemHeight = bi.it->coord.n[1]; //printf( "KR item dim %d,%d\n", ep->itemWidth, ep->itemHeight ); ++bi.it; ep->layoutBlkN = bi.it->series.buf; ep->bindCtxN = ur_makeContext( ut, 1 ); // gc! ctx = ur_buffer( ep->bindCtxN ); ur_ctxAppendWord( ctx, ur_intern( ut, itemStr, 4 ) ); if( ! (blk = ur_bufferSerM( bi.it )) ) goto fail; ur_bind( ut, blk, ctx, UR_BIND_THREAD ); ++bi.it; ep->selectBgBlkN = bi.it->series.buf; } #ifdef ITEMVIEW_BOX_LAYOUT else { // Automatic layout. glEnv.guiParsingItemView = 1; ok = gui_makeWidgets( ut, arg[1], &ep->wid, 0 ); glEnv.guiParsingItemView = 0; if( ! ok ) goto fail; //ep->wid.child->flags |= GW_HIDDEN; } #endif } return (GWidget*) ep; bad_layout: ur_error( ut, UR_ERR_SCRIPT, "Invalid item-view layout" ); fail: itemview_free( (GWidget*) ep ); return 0; }