Beispiel #1
0
int
rtb_button_init(struct rtb_button *self)
{
	if (RTB_SUBCLASS(RTB_ELEMENT(self), rtb_elem_init, &super))
		return -1;

	rtb_label_init(&self->label);
	rtb_elem_add_child(RTB_ELEMENT(self), RTB_ELEMENT(&self->label),
			RTB_ADD_HEAD);

	self->label.align = RTB_ALIGN_MIDDLE;
	self->outer_pad.x =
		self->outer_pad.y = 0.f;

	self->on_event  = on_event;
	self->attached  = attached;
	self->layout_cb = rtb_layout_hpack_center;
	self->size_cb   = rtb_size_hfit_children;
	self->reflow    = reflow;

	return 0;
}
Beispiel #2
0
struct rtb_window *
rtb_window_open_under(struct rutabaga *r, intptr_t parent,
		int w, int h, const char *title)
{
	struct rtb_style_data stdata;
	struct rtb_window *self;

	assert(r);
	assert(h > 0);
	assert(w > 0);
	assert(!r->win);

	self = window_impl_open(r, w, h, title, parent);
	if (!self)
		goto err_window_impl;

	init_gl();

	if (RTB_SUBCLASS(RTB_SURFACE(self), rtb_surface_init, &super))
		goto err_surface_init;

	self->w = w;
	self->h = h;

	self->surface = RTB_SURFACE(self);

	stdata = rtb_style_get_defaults();
	self->style_list = stdata.style;
	self->style_fonts = calloc(stdata.nfonts, sizeof(*self->style_fonts));

	if (shaders_init(self))
		goto err_shaders;

	if (ibos_init(self))
		goto err_ibos;

	if (rtb_font_manager_init(&self->font_manager,
				self->dpi.x, self->dpi.y))
		goto err_font;

	rtb_elem_set_layout(RTB_ELEMENT(self), rtb_layout_vpack_top);

	self->on_event   = win_event;
	self->mark_dirty = mark_dirty;
	self->attached   = attached;

	self->flags = RTB_ELEM_CLICK_FOCUS;

	/* for core profiles */
	glGenVertexArrays(1, &self->vao);
	glBindVertexArray(self->vao);

	self->rtb = r;
	r->win = self;

	self->mouse.current_cursor = RTB_MOUSE_CURSOR_DEFAULT;

	return self;

err_font:
	ibos_fini(self);
err_ibos:
	shaders_fini(self);
err_shaders:
err_surface_init:
	window_impl_close(self);
err_window_impl:
	return NULL;
}