Example #1
0
void
ProgressBar::SetMaxValue(ValueType m)
{
	if(YB_LIKELY(m > 0))
	{
		if(YB_LIKELY(value > m))
			value = m;
		max_value = m;
	}
}
Example #2
0
void
RectDrawRadioBox_Aoi(const PaintContext& pc_, RadioBox& rb)
{
	RectDrawSelector_Aoi([](const PaintContext& pc, const Size& s,
		const bool cst[], const Color ccs[], size_t c_idx){
		const auto& g(pc.Target);
		const SDst rad(min(s.Width / 2, s.Height / 2));
		const auto pt(pc.Location + Size(rad, rad));
		const Rect& bounds(pc.ClipArea);
		const Rect r(pc.Location, s);
		const bool is_enabled(cst[ControlState_Enabled]);

		DrawCircle(g, bounds, pt, rad, ccs[is_enabled ? c_idx : 0]);
		// XXX: Minimal size.
		if(YB_LIKELY(r.Width > 10 && r.Height > 10))
		{
			SDst radt(rad);

			FillCircle(g, bounds, pt, --radt, ccs[SelectorIndex_Aoi_C1
				+ (cst[ControlState_Locked] || cst[ControlState_Focused]
				? 2 : is_enabled ? c_idx : 0)]);
			if(is_enabled)
			{
				--c_idx;
				DrawCircle(g, bounds, pt, --radt,
					ccs[SelectorIndex_Aoi_C2 + c_idx]);
				DrawCircle(g, bounds, pt, --radt,
					ccs[SelectorIndex_Aoi_C3 + c_idx]);
			}
		}
		if(cst[ControlState_Ticked])
			FillCircle(g, bounds, pt, rad - 2, is_enabled ? Color(11, 130, 199)
				: MakeGray(190));
	}, pc_, rb, rb.IsSelected());
}
Example #3
0
pair<std::int16_t, std::int16_t>
FetchCursor()
{
	using pr_type = pair<std::int16_t, std::int16_t>;
	::touchPosition tp;

	::touchRead(&tp);
	// NOTE: (-1, -1) is %YSLib::Point::Invalid.
	return YB_LIKELY(tp.px != 0 && tp.py != 0) ? pr_type(tp.px - 1, tp.py - 1)
		: pr_type(-1, -1);
}
Example #4
0
void
CopyBuffer(const Graphics& dst, const Graphics& src)
{
	YAssert(dst.GetBufferPtr(), "Null pointer found.");
	YAssert(src.GetBufferPtr(), "Null pointer found.");
	YAssert(dst.GetSize() == src.GetSize(), "Source and destination sizes"
		"are not same.");

	if(YB_LIKELY(dst.GetBufferPtr() != src.GetBufferPtr()))
		std::copy_n(src.GetBufferPtr(), GetAreaOf(src.GetSize()),
			dst.GetBufferPtr());
}
Example #5
0
void
DrawCross(const Graphics& g, const Point& pt, const Size& s, Color c)
{
	if(YB_LIKELY(s.Width > 8 && s.Height > 8))
	{
		const Rect r(pt, s);
		const SPos xmin(pt.X + 4), xmax(xmin + s.Width - 8),
			ymin(pt.Y + 4), ymax(ymin + s.Height - 8);

		DrawLineSeg(g, r, xmin, ymin, xmax, ymax, c),
		DrawLineSeg(g, r, xmax - 1, ymin, xmin - 1, ymax, c);
	}
}
Example #6
0
void
DrawRectRoundCorner(const PaintContext& pc, const Size& s, Color c)
{
	const auto& g(pc.Target);
	const auto& pt(pc.Location);
	const auto& r(pc.ClipArea);
	const SPos x1(pt.X + 1), y1(pt.Y + 1), x2(pt.X + s.Width - 1),
		y2(pt.Y + s.Height - 1);

	if(YB_LIKELY(x1 <= x2 && y1 <= y2))
	{
		DrawVLineSeg(g, r, x1 - 1, y1, y2, c),
		DrawHLineSeg(g, r, y2, x1, x2, c),
		DrawVLineSeg(g, r, x2, y1, y2, c),
		DrawHLineSeg(g, r, y1 - 1, x1, x2, c);
		if(YB_LIKELY(s.Width > 4 && s.Height > 4))
		{
			DrawPoint(g, r, x1, y1, c);
			DrawPoint(g, r, x1, y2 - 1, c);
			DrawPoint(g, r, x2 - 1, y2 - 1, c);
			DrawPoint(g, r, x2 - 1, y1, c);
		}
	}
}
Example #7
0
void
DSConsoleInit(bool use_customed, Color fc, Color bc)
{
	if(YB_LIKELY(use_customed ? []{
		::videoSetMode(MODE_0_2D);
		::vramSetBankA(VRAM_A_MAIN_BG);
		return ::consoleInit({}, mainConsole.bgLayer,
			BgType_Text4bpp, BgSize_T_256x256,
			mainConsole.mapBase, mainConsole.gfxBase, true, true);
	}() : ::consoleDemoInit()))
	{
		// NOTE: Set cursor position to left top side.
		std::printf("\x1b[0;0H");

		const auto bg_palette(use_customed ? BG_PALETTE : BG_PALETTE_SUB);

		bg_palette[0] = Pixel(bc).Integer | BIT(15);
		bg_palette[255] = Pixel(fc).Integer | BIT(15);
	}
}
Example #8
0
void
ProgressBar::Refresh(PaintEventArgs&& e)
{
	const auto& g(e.Target);
	auto pt(e.Location);
	auto& r(e.ClipArea);
	Size s(GetSizeOf(*this));

	if(YB_LIKELY(s.Width > 2 && s.Height > 2))
	{
		yunseq(s.Width -= 2, s.Height -= 2, pt.X += 1, pt.Y += 1);

		const SDst w_bar(round(value * s.Width / max_value));

		FillRect(g, r, {pt, w_bar, s.Height}, ForeColor);
		pt.X += w_bar;
		if(s.Width > w_bar)
			// TODO: Finish drawing with non-solid brushes.
			if(const auto p = Background.target<SolidBrush>())
				FillRect(g, r, Rect(pt, s.Width - w_bar, s.Height), p->Color);
	}
}
Example #9
0
void
AMUnitList::AdjustViewLengthForHeight(SDst item_h, SDst h)
{
	if(YB_LIKELY(item_h != 0))
		vwList.Length = size_t((h + uTopOffset + item_h - 1) / item_h);
}