# 0.2.6-2

- Add Scissor (CLIP RECT) to lithium commands and UI7 Drawlist API
- Enable ClipRect to UI7::Menu (probably create a enable/disable flag)
This commit is contained in:
2025-03-05 20:18:00 +01:00
parent 229d54f088
commit 5375d0f3a9
13 changed files with 148 additions and 57 deletions

View File

@ -35,6 +35,10 @@ void DrawList::AddRectangle(vec2 pos, vec2 szs, const UI7Color& clr) {
ren->UseTex();
ren->SetupCommand(cmd);
cmd->Layer(base + layer);
if (!clip_rects.empty()) {
cmd->SetScissorMode(LI::ScissorMode_Normal);
cmd->ScissorRect(clip_rects.top());
}
ren->QuadCommand(cmd, rect, vec4(0.f, 1.f, 1.f, 0.f), clr);
commands.push_back(std::make_pair(
ren->CurrentScreen()->ScreenType() == Screen::Bottom, cmd));
@ -49,6 +53,10 @@ void DrawList::AddTriangle(vec2 pos0, vec2 pos1, vec2 pos2,
ren->UseTex();
ren->SetupCommand(cmd);
cmd->Layer(base + layer);
if (!clip_rects.empty()) {
cmd->SetScissorMode(LI::ScissorMode_Normal);
cmd->ScissorRect(clip_rects.top());
}
ren->TriangleCommand(cmd, pos0, pos1, pos2, clr);
commands.push_back(std::make_pair(
ren->CurrentScreen()->ScreenType() == Screen::Bottom, cmd));
@ -76,6 +84,10 @@ void DrawList::AddText(vec2 pos, const std::string& text, const UI7Color& clr,
e->second->SetPos(pos);
e->second->SetColor(clr);
e->second->SetLayer(layer);
if (!clip_rects.empty()) {
e->second->SetScissorMode(LI::ScissorMode_Normal);
e->second->ScissorRect(clip_rects.top());
}
e->second->Draw();
////// STILL LEAVING THE OLD CODE BELOW AS IT IS MAYBE NEEDED //////
@ -107,6 +119,10 @@ void DrawList::AddImage(vec2 pos, Texture::Ref img, vec2 size) {
ren->UseTex(img);
ren->SetupCommand(cmd);
cmd->Layer(base + layer);
if (!clip_rects.empty()) {
cmd->SetScissorMode(LI::ScissorMode_Normal);
cmd->ScissorRect(clip_rects.top());
}
ren->QuadCommand(cmd, rect, img->GetUV(), 0xffffffff);
commands.push_back(std::make_pair(
ren->CurrentScreen()->ScreenType() == Screen::Bottom, cmd));
@ -123,6 +139,10 @@ void DrawList::AddLine(const vec2& a, const vec2& b, const UI7Color& clr,
ren->UseTex();
ren->SetupCommand(cmd);
cmd->Layer(base + layer);
if (!clip_rects.empty()) {
cmd->SetScissorMode(LI::ScissorMode_Normal);
cmd->ScissorRect(clip_rects.top());
}
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));

View File

@ -108,6 +108,7 @@ void UI7::Menu::Update(float delta) {
if (!scroll_anim.IsFinished()) {
scrolling_off = scroll_anim;
}
main->PushClipRect(vec4(5, tbh, view_area.z() - 12, view_area.w()));
std::vector<int> tbr;
for (int i = 0; i < (int)objects.size(); i++) {
auto& it = objects[i];
@ -131,6 +132,7 @@ void UI7::Menu::Update(float delta) {
for (auto it : tbr) {
idobjs.erase(idobjs.begin() + it);
}
main->PopClipRect();
this->back->Process();
this->main->Process();
this->front->Process();