コード例 #1
0
ファイル: textinput.c プロジェクト: wilkie/openomf
static void textinput_render(component *c) {
    textinput *tb = widget_get_obj(c);
    int chars = strlen(tb->buf);

    video_render_sprite(&tb->sur, c->x + (c->w - tb->sur.w)/2, c->y - 2, BLEND_ALPHA, 0);

    if(component_is_selected(c)) {
        if(chars > 0) {
            tb->tconf.cforeground = color_create(80, 220, 80, 255);
            tb->buf[chars] = '\x7F';
            tb->buf[chars+1] = 0;
            text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf);
            tb->buf[chars] = 0;
        }
    } else if(component_is_disabled(c)) {
        if(chars > 0) {
            tb->tconf.cforeground = color_create(121, 121, 121, 255);
            text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf);
        }
    } else {
        if(chars > 0) {
            tb->tconf.cforeground = color_create(0, 121, 0, 255);
            text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf);
        }
    }
    if(chars == 0) {
        tb->tconf.cforeground = color_create(121, 121, 121, 255);
        text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->buf);
    }
}
コード例 #2
0
ファイル: textbutton.c プロジェクト: omf2097/openomf
static void textbutton_render(component *c) {
    textbutton *tb = widget_get_obj(c);

    // Select color and render
    if(component_is_selected(c)) {
        int t = tb->ticks / 2;
        tb->tconf.cforeground = color_create(80 - t, 220 - t*2, 80 - t, 255);
    } else if (component_is_disabled(c)) {
        tb->tconf.cforeground = color_create(121, 121, 121, 255);
    } else {
        tb->tconf.cforeground = color_create(0, 121, 0, 255);
    }
    text_render(&tb->tconf, c->x, c->y, c->w, c->h, tb->text);

    // Border
    if(tb->border_enabled) {
        video_render_sprite(&tb->border, c->x-2, c->y-2, BLEND_ALPHA, 0);
    }
}