Ejemplo n.º 1
0
void draw()
{
    unsigned char mbut = 0;
    int scrollarea1 = 0;
    int i;

    background(gray(122));

    uiSetCursor((int)mouseX,(int)mouseY);
    for (i=0; i<3; i++) uiSetButton(i, 0);
    if (mousePressed) uiSetButton(mouseButton, 1);
    createUI(vg, width, height);
    uiProcess();
    drawUI(vg, 0, 0, 0);
    {
        int x = mouseX - width/2;
        int y = mouseY - height/2;
        if (abs(x) > width/4) {
            bndJoinAreaOverlay(vg, 0, 0, width, height, 0, (x > 0));
        } else if (abs(y) > height/4) {
            bndJoinAreaOverlay(vg, 0, 0, width, height, 1, (y > 0));
        }
    }

    if (key == GLFW_KEY_ESCAPE)
    {
        quit();
    }
    else if (key == GLFW_KEY_SPACE)
    {
        saveFrame("screenshot.png");
    }
}
Ejemplo n.º 2
0
void draw(NVGcontext *vg, float w, float h) {
    bndBackground(vg, 0, 0, w, h);

    // some OUI stuff

    uiBeginLayout();

    int root = panel();
    // position root element
    uiSetSize(0,w,h);
    ((UIData*)uiGetHandle(root))->handler = roothandler;
    uiSetEvents(root, UI_SCROLL|UI_BUTTON0_DOWN);
    uiSetBox(root, UI_COLUMN);

    static int choice = -1;

    int menu = uiItem();
    uiSetLayout(menu, UI_HFILL|UI_TOP);
    uiSetBox(menu, UI_ROW);
    uiInsert(root, menu);

    int opt_blendish_demo = add_menu_option(menu, "Blendish Demo", &choice);
    int opt_oui_demo = add_menu_option(menu, "OUI Demo", &choice);
    int opt_layouts = add_menu_option(menu, "UI_LAYOUT", &choice);
    int opt_row = add_menu_option(menu, "UI_ROW", &choice);
    int opt_column = add_menu_option(menu, "UI_COLUMN", &choice);
    int opt_wrap = add_menu_option(menu, "UI_WRAP", &choice);
    if (choice < 0)
        choice = opt_blendish_demo;

    int content = uiItem();
    uiSetLayout(content, UI_FILL);
    uiInsert(root, content);

    if (choice == opt_blendish_demo) {
        int democontent = uiItem();
        uiSetLayout(democontent, UI_FILL);
        uiInsert(content, democontent);

        UIData *data = (UIData *)uiAllocHandle(democontent, sizeof(UIData));
        data->handler = 0;
        data->subtype = ST_DEMOSTUFF;
    } else if (choice == opt_oui_demo) {
        int democontent = uiItem();
        uiSetLayout(democontent, UI_TOP);
        uiSetSize(democontent, 250, 0);
        uiInsert(content, democontent);

        build_democontent(democontent);
    } else if (choice == opt_layouts) {
        build_layoutdemo(content);
    } else if (choice == opt_row) {
        build_rowdemo(content);
    } else if (choice == opt_column) {
        build_columndemo(content);
    } else if (choice == opt_wrap) {
        build_wrapdemo(content);
    }

    uiEndLayout();

    drawUI(vg, 0, BND_CORNER_NONE);
    
#if 0
    for (int i = 0; i < uiGetLastItemCount(); ++i) {
        if (uiRecoverItem(i) == -1) {
            UIitem *pitem = uiLastItemPtr(i);
            nvgBeginPath(vg);
            nvgRect(vg,pitem->margins[0],pitem->margins[1],pitem->size[0],pitem->size[1]);
            nvgStrokeWidth(vg, 2);
            nvgStrokeColor(vg, nvgRGBAf(1.0f,0.0f,0.0f,0.5f));
            nvgStroke(vg);
        }
    }
#endif

    if (choice == opt_blendish_demo) {
        UIvec2 cursor = uiGetCursor();
        cursor.x -= w/2;
        cursor.y -= h/2;
        if (abs(cursor.x) > (w/3)) {
            bndJoinAreaOverlay(vg, 0, 0, w, h, 0, (cursor.x > 0));
        } else if (abs(cursor.y) > (h/3)) {
            bndJoinAreaOverlay(vg, 0, 0, w, h, 1, (cursor.y > 0));
        }
    }
    
    uiProcess((int)(glfwGetTime()*1000.0));
}