# 0.2.5
Add DrawLine to DrawList Fix Text Separator Alignment
This commit is contained in:
@ -112,6 +112,22 @@ void DrawList::AddImage(vec2 pos, Texture::Ref img, vec2 size) {
|
||||
ren->CurrentScreen()->ScreenType() == Screen::Bottom, cmd));
|
||||
}
|
||||
|
||||
void DrawList::AddLine(const vec2& a, const vec2& b, const UI7Color& clr,
|
||||
int t) {
|
||||
if (!ren->InBox(a, ren->GetViewport()) ||
|
||||
!ren->InBox(b, ren->GetViewport())) {
|
||||
return;
|
||||
}
|
||||
auto line = ren->CreateLine(a, b, t);
|
||||
auto cmd = LI::Command::New();
|
||||
ren->UseTex();
|
||||
ren->SetupCommand(cmd);
|
||||
cmd->Layer(base + layer);
|
||||
ren->QuadCommand(cmd, line, vec4(0.f, 1.f, 1.f, 0.f), clr);
|
||||
commands.push_back(std::make_pair(
|
||||
ren->CurrentScreen()->ScreenType() == Screen::Bottom, cmd));
|
||||
}
|
||||
|
||||
void DrawList::Clear() { commands.clear(); }
|
||||
|
||||
void DrawList::Process() {
|
||||
|
@ -320,14 +320,29 @@ void UI7::Menu::SeparatorText(const std::string& label) {
|
||||
if (HandleScrolling(pos, size)) {
|
||||
return;
|
||||
}
|
||||
auto alignment = GetAlignment();
|
||||
vec2 rpos =
|
||||
AlignPos(pos, view_area.z() - 10, view_area, alignment); // RenderPos
|
||||
/// Label pos for better overview
|
||||
vec2 lpos = pos + vec2((view_area.z() - 10) * 0.5 - tdim.x() * 0.5, 0);
|
||||
main->AddRectangle(pos + vec2(0, tdim.y() * 0.5),
|
||||
vec2(lpos.x() - pos.x() - 5, size.y()),
|
||||
theme->Get(UI7Color_TextDead));
|
||||
main->AddRectangle(pos + vec2(lpos.x() + tdim.x(), tdim.y() * 0.5),
|
||||
vec2(size.x() - (lpos.x() + tdim.x()), size.y()),
|
||||
theme->Get(UI7Color_TextDead));
|
||||
vec2 lpos = rpos;
|
||||
if (alignment & UI7Align_Center) {
|
||||
lpos += vec2((view_area.z() - 10) * 0.5 - tdim.x() * 0.5, 0);
|
||||
} else if (alignment & UI7Align_Right) {
|
||||
lpos = vec2(view_area.z() - 10 - tdim.x(), rpos.y());
|
||||
if (scrolling[1]) {
|
||||
lpos.x() -= 8;
|
||||
}
|
||||
}
|
||||
if (!(alignment & UI7Align_Left)) {
|
||||
main->AddRectangle(pos + vec2(0, tdim.y() * 0.5),
|
||||
vec2(lpos.x() - pos.x() - 5, size.y()),
|
||||
theme->Get(UI7Color_TextDead));
|
||||
}
|
||||
if (!(alignment & UI7Align_Right)) {
|
||||
main->AddRectangle(pos + vec2(lpos.x() + tdim.x(), tdim.y() * 0.5),
|
||||
vec2(size.x() - (lpos.x() + tdim.x()), size.y()),
|
||||
theme->Get(UI7Color_TextDead));
|
||||
}
|
||||
main->AddText(lpos, label, theme->Get(UI7Color_Text), 0,
|
||||
vec2(view_area.z(), 20));
|
||||
}
|
||||
|
Reference in New Issue
Block a user