Beispiel #1
0
static void ledit_layout( GWidget* wp )
{
    UCell* style = glEnv.guiStyle;
    UThread* ut  = glEnv.guiUT;
    UCell* rc;
    EX_PTR;


    // Set draw list variables.

    rc = style + CI_STYLE_LABEL;
    ur_setId( rc, UT_STRING );
    ur_setSeries( rc, ep->strN, 0 );

    rc = style + CI_STYLE_AREA;
    gui_initRectCoord( rc, wp, UR_ATOM_RECT );


    // Compile draw lists.

    if( ! gDPC )
        return;

    // Make sure the tgeo vertex buffers are bound before the switch.
    // Otherwise only the first case would emit the code to do it. 
    // NOTE: This assumes the button draw programs actually use tgeo.
    dp_tgeoInit( gDPC );

    ep->dpSwitch = dp_beginSwitch( gDPC, 2 );

    rc = style + CI_STYLE_EDITOR;
    if( ur_is(rc, UT_BLOCK) )
        ur_compileDP( ut, rc, 1 );
    dp_endCase( gDPC, ep->dpSwitch );

    rc = style + CI_STYLE_EDITOR_ACTIVE;
    if( ur_is(rc, UT_BLOCK) )
        ur_compileDP( ut, rc, 1 );
    dp_endCase( gDPC, ep->dpSwitch );

    dp_endSwitch( gDPC, ep->dpSwitch, ep->state );

    setFlag( CHANGED );

#if 0
    rc = style + CI_STYLE_EDITOR_CURSOR;
    if( ur_is(rc, UT_BLOCK) )
    {
        DPCompiler dc;
        DPCompiler* save;

        save = gx_beginDP( &dc );
        if( save )
            dc.shaderProg = save->shaderProg;
        ur_compileDP( ut, rc, 1 );
        gx_endDP( ur_buffer( ep->textResN ), save );

        //dp_compile( &dc, ut, rc->series.n );
    }
#endif
}
Beispiel #2
0
static void itemview_layout( GWidget* wp )
{
    UCell* rc;
    /*
    UCell* it;
    UBuffer* blk;
    int row, rowCount;
    int col, colCount;
    int itemY;
    */
    UCell* style = glEnv.guiStyle;
    UThread* ut  = glEnv.guiUT;
    //UIndex strN = 0;
    EX_PTR;
    /*
    DPCompiler* save;
    DPCompiler dpc;
    */


#ifdef ITEM_HEADER
    if( ep->headerBlkN <= 0 )
        return;
#endif
    if( ep->dataBlkN <= 0 )
        return;

    itemview_calcItemHeight( ut, ep );

    //itemY = wp->area.y + wp->area.h - ep->itemHeight;

    if( ep->use_color == -1 )
    {
        rc = style + CI_STYLE_WIDGET_SH;
        if( ur_is(rc, UT_CONTEXT) )
        {
            const Shader* shad = shaderContext( ut, rc, 0 );
            if( shad )
            {
                ep->use_color = glGetUniformLocation( shad->program,
                                                      "use_color" );
                //printf( "KR use_color %d\n", ep->use_color );
            }
        }
    }


#if 0
    // Compile draw list for visible items.

    save = ur_beginDP( &dpc );
    if( save )
        dpc.shaderProg = save->shaderProg;


    // Header

    blk = ur_buffer( ep->headerBlkN );
    it  = blk->ptr.cell;
    colCount = ep->colCount = blk->used;

    for( col = 0; col < colCount; ++col, ++it )
    {
        rc = style + CI_STYLE_LABEL;
        if( ur_is(it, UT_STRING) )
        {
            *rc = *it;
        }

        rc = style + CI_STYLE_AREA;
        rc->coord.len = 4;
        rc->coord.n[0] = wp->area.x + (col * MIN_COLW);
        rc->coord.n[1] = itemY;
        rc->coord.n[2] = MIN_COLW;
        rc->coord.n[3] = ep->itemHeight;

        rc = style + CI_STYLE_LIST_HEADER;
        if( ur_is(rc, UT_BLOCK) )
            ur_compileDP( ut, rc, 1 );
    }
    itemY -= ep->itemHeight;


    // Items

    blk = ur_buffer( ep->dataBlkN );
    it  = blk->ptr.cell;
    rowCount = blk->used / colCount;

    for( row = 0; row < rowCount; ++row )
    {
        for( col = 0; col < colCount; ++col, ++it )
        {
            rc = style + CI_STYLE_LABEL;
            if( ur_is(it, UT_STRING) )
            {
                *rc = *it;
            }
            else
            {
                UBuffer* str;

                if( ! strN )
                    strN = ur_makeString( ut, UR_ENC_LATIN1, 32 );

                ur_initSeries( rc, UT_STRING, strN );

                str = ur_buffer( strN );
                str->used = 0;
                ur_toStr( ut, it, str, 0 );
            }

            rc = style + CI_STYLE_AREA;
            rc->coord.len = 4;
            rc->coord.n[0] = wp->area.x + (col * MIN_COLW);
            rc->coord.n[1] = itemY;
            rc->coord.n[2] = MIN_COLW;
            rc->coord.n[3] = ep->itemHeight;

            rc = style + ((row == ep->selRow) ?
                                CI_STYLE_LIST_ITEM_SELECTED :
                                CI_STYLE_LIST_ITEM);
            if( ur_is(rc, UT_BLOCK) )
                ur_compileDP( ut, rc, 1 );
        }
        itemY -= ep->itemHeight;
    }

    ur_endDP( ut, ur_buffer(ep->dp[0]), save );
#endif
}
Beispiel #3
0
static void slider_layout( GWidget* wp )
{
    UCell* rc;
    UCell* area;
    UCell* style = glEnv.guiStyle;
    UThread* ut = glEnv.guiUT;
    EX_PTR;
    int isSlider = (wp->wclass != &wclass_scrollbar);
    int horiz = (ep->orient == HORIZONTAL);
    int majorD = horiz ? wp->area.w : wp->area.h;

    if( ! gDPC )
        return;

    // Set slider knob length.

    if( isSlider )
    {
        rc = style + CI_STYLE_SLIDER_SIZE;
        ep->knobLen = rc->coord.n[0];
    }
    else
    {
        struct Value* da = &ep->data;
        ep->knobLen = (int16_t) (da->vsize * majorD /
                                (da->max - da->min + da->vsize));
    }

    ep->td = slider_knobTrans( ep, (float) (majorD - ep->knobLen),
                               ep->data.max - ep->data.min );


    // Set draw list variables.

    area = style + CI_STYLE_AREA;
    gui_initRectCoord( area, wp, UR_ATOM_RECT );


    // Compile draw lists.

    rc = style + (isSlider ? CI_STYLE_SLIDER_GROOVE : CI_STYLE_SCROLL_BAR);
    if( ur_is(rc, UT_BLOCK) )
        ur_compileDP( ut, rc, 1 );

    rc = style + (isSlider ? CI_STYLE_SLIDER : CI_STYLE_SCROLL_KNOB);
        //(horiz ? CI_STYLE_SLIDER_H : CI_STYLE_SLIDER_V);
    if( ur_is(rc, UT_BLOCK) )
    {
        float tx, ty;
        if( horiz )
        {
            tx = (float) ep->td;
            ty = 0.0f;
            area->coord.n[2] = ep->knobLen;   // Area width.
        }
        else
        {
            tx = 0.0f;
#ifdef YTOP
            ty = (float) ep->td;
#else
            ty = (float) (wp->area.h - ep->knobLen - ep->td);
#endif
            area->coord.n[3] = ep->knobLen;   // Area height.
        }

        ep->dpTrans = dp_beginTransXY( gDPC, tx, ty );
        ur_compileDP( ut, rc, 1 );
        dp_endTransXY( gDPC );
    }
}