示例#1
0
文件: window.c 项目: wrl/rutabaga
int
rtb_window_draw(struct rtb_window *self, int force_redraw)
{
	const struct rtb_style_property_definition *prop;
	struct rtb_window_event ev;

	if (self->state == RTB_STATE_UNATTACHED
			|| self->visibility == RTB_FULLY_OBSCURED)
		return 0;

	ev.type = RTB_FRAME_START;
	ev.source = RTB_EVENT_GENUINE;
	ev.window = self;
	rtb_dispatch_raw(RTB_ELEMENT(self), RTB_EVENT(&ev));

	if (!self->dirty || force_redraw)
		return 0;

	glViewport(0, 0, self->w, self->h);

	prop = rtb_style_query_prop(RTB_ELEMENT(self),
			"background-color", RTB_STYLE_PROP_COLOR, 1);

	glEnable(GL_DITHER);
	glEnable(GL_BLEND);
	glEnable(GL_SCISSOR_TEST);

	glClearColor(
			prop->color.r,
			prop->color.g,
			prop->color.b,
			prop->color.a);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	rtb_render_push(RTB_ELEMENT(self));
	self->draw(RTB_ELEMENT(self));
	rtb_render_pop(RTB_ELEMENT(self));

	self->dirty = 0;

	ev.type = RTB_FRAME_END;
	rtb_dispatch_raw(RTB_ELEMENT(self), RTB_EVENT(&ev));

	return 1;
}
示例#2
0
文件: button.c 项目: artfwo/rutabaga
static int
dispatch_click_event(struct rtb_button *self, const struct rtb_mouse_event *e)
{
	struct rtb_button_event event = *((struct rtb_button_event *) e);

	event.type = RTB_BUTTON_CLICK;
	event.cursor.x -= self->x;
	event.cursor.y -= self->y;

	return rtb_handle(RTB_ELEMENT(self), RTB_EVENT(&event));
}
示例#3
0
文件: button.c 项目: artfwo/rutabaga
static int
handle_key_press(struct rtb_button *self, const struct rtb_key_event *e)
{
	struct rtb_button_event event = {
		.type   = RTB_BUTTON_CLICK,
		.source = RTB_EVENT_SYNTHETIC
	};

	if ((e->keysym == RTB_KEY_NORMAL && e->character == ' ')
			|| (e->keysym == RTB_KEY_ENTER)) {
		rtb_handle(RTB_ELEMENT(self), RTB_EVENT(&event));
		return 1;
	}

	return 0;
}