void HxGLSLVertexView::update()
{
    if (portDrawStyle.isNew())
    {
        setRenderMode((DrawStyles)portDrawStyle.getValue());

        portSphereScale.setVisible( portDrawStyle.getValue() != POINTS );
    }

    if (portData.isNew())
    {
        HxVertexSet* data = hxconnection_cast<HxVertexSet>(portData);
        if (data)
        {
            const McVec3f size = data->getBoundingBoxSize();

            float min_size = MC_MIN3(size[0], size[1],size[2]) / 30.0f;

            portSphereScale.setMinMax(0, min_size);
            portSphereScale.setValue( min_size / 2.0f);
        }
    }
}
Beispiel #2
0
static void
grid_scroll(grid_t* grid, BOOL is_vertical, WORD opcode, int factor)
{
    SCROLLINFO si;
    int old_scroll_x = grid->scroll_x;
    int old_scroll_y = grid->scroll_y;

    si.cbSize = sizeof(SCROLLINFO);
    si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS;

    if(is_vertical) {
        GetScrollInfo(grid->win, SB_VERT, &si);
        switch(opcode) {
            case SB_BOTTOM: grid->scroll_y = si.nMax; break;
            case SB_LINEUP: grid->scroll_y -= factor * MC_MIN3(grid->def_row_height, 40, si.nPage); break;
            case SB_LINEDOWN: grid->scroll_y += factor * MC_MIN3(grid->def_row_height, 40, si.nPage); break;
            case SB_PAGEUP: grid->scroll_y -= si.nPage; break;
            case SB_PAGEDOWN: grid->scroll_y += si.nPage; break;
            case SB_THUMBPOSITION: grid->scroll_y = si.nPos; break;
            case SB_THUMBTRACK: grid->scroll_y = si.nTrackPos; break;
            case SB_TOP: grid->scroll_y = 0; break;
        }

        if(grid->scroll_y > si.nMax - (int)si.nPage)
            grid->scroll_y = si.nMax - (int)si.nPage;
        if(grid->scroll_y < si.nMin)
            grid->scroll_y = si.nMin;
        if(old_scroll_y == grid->scroll_y)
            return;

        SetScrollPos(grid->win, SB_VERT, grid->scroll_y, TRUE);
    } else {
        GetScrollInfo(grid->win, SB_HORZ, &si);
        switch(opcode) {
            case SB_BOTTOM: grid->scroll_x = si.nMax; break;
            case SB_LINELEFT: grid->scroll_x -= factor * MC_MIN3(grid->def_col_width, 40, si.nPage); break;
            case SB_LINERIGHT: grid->scroll_x += factor * MC_MIN3(grid->def_col_width, 40, si.nPage); break;
            case SB_PAGELEFT: grid->scroll_x -= si.nPage; break;
            case SB_PAGERIGHT: grid->scroll_x += si.nPage; break;
            case SB_THUMBPOSITION: grid->scroll_x = si.nPos; break;
            case SB_THUMBTRACK: grid->scroll_x = si.nTrackPos; break;
            case SB_TOP: grid->scroll_x = 0; break;
        }

        if(grid->scroll_x > si.nMax - (int)si.nPage)
            grid->scroll_x = si.nMax - (int)si.nPage;
        if(grid->scroll_x < si.nMin)
            grid->scroll_x = si.nMin;
        if(old_scroll_x == grid->scroll_x)
            return;

        SetScrollPos(grid->win, SB_HORZ, grid->scroll_x, TRUE);
    }

    if(!grid->no_redraw) {
        RECT rect;

        GetClientRect(grid->win, &rect);
        if(is_vertical)
            rect.top = grid_header_height(grid);
        else
            rect.left = grid_header_width(grid);

        ScrollWindowEx(grid->win, old_scroll_x - grid->scroll_x,
                       old_scroll_y - grid->scroll_y, &rect, &rect, NULL, NULL,
                       SW_ERASE | SW_INVALIDATE);
    }
}