# Stage 1.8

- Renderer now vould use more screen Objects
- Register default Top and Bottom Screens (for Overlays and UI7)
- Make ToHex an Inline header func
- Add GetCompilerVersion
- Add Library Compile And Version Info to common
- Remove z of vertex object and shader in position
- Add Container base and SubContainers to UI7
- Add abillity to Join Multiple Objects in Same Line and Center them
- Fix LayerOrder Bug for updating texts in DrawList
This commit is contained in:
2025-02-02 20:32:07 +01:00
parent 055588ce8b
commit f87c103d8d
32 changed files with 619 additions and 293 deletions

View File

@ -0,0 +1,36 @@
#include <pd/ui7/container/button.hpp>
namespace PD {
namespace UI7 {
void Button::HandleInput(Hid::Ref inp) {
/// Ensure to only check input once
if (inp_done) {
return;
}
/// Ensure it gets sed to false and stays if not pressed
pressed = false;
color = UI7Color_Button;
Assert(screen.get(), "Screen is not set up!");
if (screen->ScreenType() == Screen::Bottom) {
if (inp->IsHeld(inp->Touch) &&
LI::Renderer::InBox(inp->TouchPos(), vec4(pos, size))) {
color = UI7Color_ButtonHovered;
}
if (inp->IsUp(inp->Touch) &&
LI::Renderer::InBox(inp->TouchPosLast(), vec4(pos, size))) {
color = UI7Color_ButtonActive;
pressed = true;
}
}
inp_done = true;
}
void Button::Draw() {
Assert(ren.get() && list.get() && linked_theme,
"Did you run Container::Init correctly?");
ren->OnScreen(screen);
list->AddRectangle(pos, size, linked_theme->Get(color));
list->AddText(pos + size * 0.5 - tdim * 0.5, label,
linked_theme->Get(UI7Color_Text));
}
} // namespace UI7
} // namespace PD

View File

@ -0,0 +1,38 @@
#include <pd/ui7/container/checkbox.hpp>
namespace PD {
namespace UI7 {
void Checkbox::HandleInput(Hid::Ref inp) {
/// Ensure to only check input once
if (inp_done) {
return;
}
color = UI7Color_FrameBackground;
/// Ensure it gets sed to false and stays if not pressed
Assert(screen.get(), "Screen is not set up!");
if (screen->ScreenType() == Screen::Bottom) {
if (inp->IsHeld(inp->Touch) &&
LI::Renderer::InBox(inp->TouchPos(), vec4(pos, size))) {
color = UI7Color_FrameBackgroundHovered;
}
if (inp->IsUp(inp->Touch) &&
LI::Renderer::InBox(inp->TouchPosLast(), vec4(pos, size))) {
color = UI7Color_FrameBackgroundHovered;
usr_ref = !usr_ref;
}
}
inp_done = true;
}
void Checkbox::Draw() {
Assert(ren.get() && list.get() && linked_theme,
"Did you run Container::Init correctly?");
ren->OnScreen(screen);
list->AddRectangle(pos, cbs, linked_theme->Get(color));
if (usr_ref) {
list->AddRectangle(pos + 2, cbs - 4, linked_theme->Get(UI7Color_Checkmark));
}
list->AddText(pos + vec2(cbs.x() + 5, cbs.y() * 0.5 - tdim.y() * 0.5), label,
linked_theme->Get(UI7Color_Text));
}
} // namespace UI7
} // namespace PD

View File

@ -0,0 +1,12 @@
#include <pd/ui7/container/container.hpp>
namespace PD {
namespace UI7 {
void Container::HandleScrolling(vec2 scrolling, vec4 viewport) {
pos -= vec2(0, scrolling.y());
if (!LI::Renderer::InBox(pos, size, viewport)) {
skippable = true;
}
}
} // namespace UI7
} // namespace PD

View File

@ -0,0 +1,13 @@
#include <pd/ui7/container/image.hpp>
namespace PD {
namespace UI7 {
void Image::Draw() {
Assert(ren.get() && list.get() && linked_theme,
"Did you run Container::Init correctly?");
Assert(img.get(), "Image is nullptr!");
ren->OnScreen(screen);
list->AddImage(pos, img);
}
} // namespace UI7
} // namespace PD

View File

@ -0,0 +1,12 @@
#include <pd/ui7/container/label.hpp>
namespace PD {
namespace UI7 {
void Label::Draw() {
Assert(ren.get() && list.get() && linked_theme,
"Did you run Container::Init correctly?");
ren->OnScreen(screen);
list->AddText(pos, label, linked_theme->Get(UI7Color_Text));
}
} // namespace UI7
} // namespace PD