示例#1
0
void
sge::gui::widget::edit::on_draw(
	sge::gui::renderer::base &_renderer,
	sge::renderer::context::ffp &_context
)
{
	// TODO: Add a signal to sge that tells us when a layout changes
	static_text_ =
		this->make_static_text();

	style_.draw_edit(
		_renderer,
		_context,
		this->layout().area()
	);

	_renderer.draw_static_text(
		_context,
		static_text_
	);

	if(
		!has_focus_
		||
		!show_cursor_
	)
		return;

	sge::font::rect const cursor_rect(
		static_text_.text().cursor_rect(
			position_
		)
	);

	_renderer.fill_rect(
		_context,
		sge::rucksack::rect(
			cursor_rect.pos()
			+
			static_text_.pos(),
			sge::font::dim(
				// TODO: How do we specify the width?
				2,
				cursor_rect.size().h()
			)
		),
		style_.text_color().get()
	);
}
示例#2
0
void
sge::gui::widget::text::on_draw(
	sge::gui::renderer::base &_renderer,
	sge::renderer::context::ffp &_context
)
{
	style_.draw_text(
		_renderer,
		_context,
		this->layout().area()
	);

	sge::font::draw::static_text const static_text(
		renderer_,
		font_,
		value_,
		sge::font::text_parameters(
			sge::font::align_h::variant{
				sge::font::align_h::center(
					sge::font::align_h::max_width(
						layout_.size().w()
					)
				)
			}
		)
		.flags(
			sge::font::flags_field{
				sge::font::flags::no_multi_line
			}
		),
		fcppt::math::vector::structure_cast<
			sge::font::vector,
			fcppt::cast::size_fun
		>(
			layout_.position()
		)
		+
		sge::font::vector(
			0,
			sge::font::v_center(
				font_.metrics().height(),
				layout_.size().h()
			)
		),
		text_color_.get(),
		sge::renderer::texture::emulate_srgb::no
	);

	_renderer.draw_static_text(
		_context,
		static_text
	);
}
示例#3
0
void
sge::gui::widget::image::on_draw(
	sge::gui::renderer::base &_renderer,
	sge::renderer::context::ffp &_context
)
{
	style_.draw_image(
		_renderer,
		_context,
		this->layout().area()
	);

	_renderer.draw_image(
		_context,
		texture_,
		layout_.position()
		+
		(
			(
				layout_.size()
				-
				fcppt::math::dim::structure_cast<
					sge::rucksack::dim,
					fcppt::cast::size_fun
				>(
					fcppt::math::dim::to_signed(
						texture_.area().size()
					)
				)
			)
			/
			fcppt::literal<
				sge::rucksack::scalar
			>(
				2
			)
		).get_unsafe()
	);
}