コード例 #1
0
ファイル: vbox.c プロジェクト: konker/dreamchess
int gg_vbox_set_focus_pos(gg_widget_t *widget, int x , int y)
{
    gg_box_t *box = GG_BOX(widget);
    gg_container_t *container = GG_CONTAINER(widget);
    int size = gg_container_get_size(container);
    int cur_y = box->height_a - box->height;
    int prev = box->sel;

    box->sel = size;

    while (gg_select_prev(GG_SELECT(widget), 0, 0))
    {
        gg_widget_t *child = gg_container_get_child(container, box->sel);

        cur_y += child->height_a;
        if (cur_y > y)
        {
            if (!child->input || !child->enabled || !
                child->set_focus_pos(child, x, child->height_a - (cur_y - y)))
                break;
            else
                return 1;
        }
        cur_y += box->spacing;
    }

    box->sel = prev;
    return 0;
}
コード例 #2
0
ファイル: ticker.c プロジェクト: konker/dreamchess
int gg_ticker_input(gg_widget_t *widget, gg_event_t event) {
	gg_select_t *select = GG_SELECT(widget);
	gg_box_t *box = GG_BOX(widget);
	gg_widget_t *child;

	event.mouse.x -= widget->width_a - GG_TICKER(widget)->offset;

	if (select->sel == -1)
		return 0;

	if (event.type == GG_EVENT_MOUSE)
	{
		int nr = 0;
		while (nr < select->sel)
		{
			gg_widget_t *child = gg_container_get_child(GG_CONTAINER(widget), nr);

			event.mouse.x -= child->width_a;
			event.mouse.x -= box->spacing;
			nr++;
		}
	}

	child = gg_container_get_child(GG_CONTAINER(widget), select->sel);

	if (child->input && child->input(child, event))
		return 1;

	return 0;
}
コード例 #3
0
ファイル: vbox.c プロジェクト: dreamchess/dreamchess
int gg_vbox_input(gg_widget_t *widget, gg_event_t event) {
	gg_select_t *select = GG_SELECT(widget);
	gg_box_t *box = GG_BOX(widget);
	gg_widget_t *child;
	gg_rect_t focus;
	int retval = 0, x, y;

	if (select->sel == -1)
		return 0;

	if (event.type == GG_EVENT_MOUSE) {
		int nr = gg_container_get_size(GG_CONTAINER(widget));

		event.mouse.y -= box->height_a - box->height;
		while (--nr > select->sel) {
			gg_widget_t *child = gg_container_get_child(GG_CONTAINER(widget), nr);

			event.mouse.y -= child->height_a;
			event.mouse.y -= box->spacing;
		}
	}

	child = gg_container_get_child(GG_CONTAINER(widget), select->sel);

	if (event.type == GG_EVENT_MOUSE) {
		if (event.mouse.x < 0 || event.mouse.x >= child->width_a || event.mouse.y < 0 ||
			event.mouse.y >= child->height_a)
			return 0;
	}

	if (child->input(child, event))
		return 1;

	focus = child->get_focus_pos(child);
	x = focus.x + focus.width / 2;

	if (event.type == GG_EVENT_KEY && event.key == GG_KEY_UP) {
		retval = gg_select_prev(select, 1, 1);
		child = gg_container_get_child(GG_CONTAINER(widget), select->sel);
		y = 0;
	}

	if (event.type == GG_EVENT_KEY && event.key == GG_KEY_DOWN) {
		retval = gg_select_next(select, 1, 1);
		child = gg_container_get_child(GG_CONTAINER(widget), select->sel);
		y = child->height_a - 1;
	}

	if (retval) {
		child->set_focus_pos(child, x, y);
		return retval;
	}

	return 0;
}
コード例 #4
0
ファイル: ticker.c プロジェクト: konker/dreamchess
int gg_ticker_set_focus_pos(gg_widget_t *widget, int x, int y) {
	gg_box_t *box = GG_BOX(widget);
	gg_container_t *container = GG_CONTAINER(widget);
	int cur_x = widget->width_a - GG_TICKER(widget)->offset;

	box->sel = -1;
	GG_TICKER(widget)->focus_x = x;

	while (gg_select_next(GG_SELECT(widget), 0, 0))
	{
		gg_widget_t *child = gg_container_get_child(container, box->sel);

		if (x >= cur_x && cur_x + child->width_a > x) {
			if (!child->input || !child->enabled)
				box->sel = -1;
			return 1;
		}
		cur_x += child->width_a + box->spacing;
	}

	box->sel = -1;
	return 0;
}
コード例 #5
0
ファイル: vbox.c プロジェクト: konker/dreamchess
void gg_vbox_set_selected(gg_widget_t *widget, int index )
{
    gg_select_t *select = GG_SELECT(widget);
    select->sel=index;
}