Add FontStack to UI7 and uncomment layer lines
This commit is contained in:
@@ -49,12 +49,13 @@ PD_API void Button::HandleInput() {
|
||||
PD_API void Button::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->SetFont(GetFont());
|
||||
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
|
||||
list->PathFill(io->Theme.Get(color));
|
||||
// list->LayerUp();
|
||||
list->LayerUp();
|
||||
list->DrawText(FinalPos() + size * 0.5 - tdim * 0.5, label.c_str(),
|
||||
io->Theme.Get(UI7Color_Text));
|
||||
// list->LayerDown();
|
||||
list->LayerDown();
|
||||
}
|
||||
|
||||
PD_API void Button::Update() {
|
||||
|
||||
@@ -48,6 +48,7 @@ PD_API void Checkbox::HandleInput() {
|
||||
PD_API void Checkbox::Draw() {
|
||||
// Assert(list.get() && io.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->SetFont(GetFont());
|
||||
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
|
||||
list->PathFill(io->Theme.Get(color));
|
||||
if (usr_ref) {
|
||||
|
||||
@@ -44,6 +44,7 @@ PD_API void ColorEdit::HandleInput() {
|
||||
PD_API void ColorEdit::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->SetFont(GetFont());
|
||||
list->PathRect(FinalPos(), FinalPos() + io->ItemRowHeight, io->FrameRounding);
|
||||
list->PathFill(*color_ref);
|
||||
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + io->ItemRowHeight, 0),
|
||||
@@ -55,6 +56,7 @@ PD_API void ColorEdit::Draw() {
|
||||
layout->SetPosition(FinalPos());
|
||||
DynObj* r = io->DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l, Container* thiz) {
|
||||
list->SetFont(thiz->GetFont());
|
||||
thiz->SetSize(layout->GetSize());
|
||||
// l->Layer(30);
|
||||
l->PathRect(thiz->GetPos(), thiz->GetPos() + thiz->GetSize(),
|
||||
@@ -65,6 +67,7 @@ PD_API void ColorEdit::Draw() {
|
||||
UI7LytAdd_NoScrollHandle);
|
||||
r = io->DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l, Container* thiz) {
|
||||
list->SetFont(thiz->GetFont());
|
||||
l->PathRect(thiz->FinalPos(), thiz->FinalPos() + io->ItemRowHeight,
|
||||
io->FrameRounding);
|
||||
l->PathFill(*color_ref);
|
||||
|
||||
@@ -86,11 +86,11 @@ PD_API void DragData<T>::Draw() {
|
||||
FinalPos() + fvec2(off_x, 0) + td + io->FramePadding,
|
||||
io->FrameRounding);
|
||||
list->PathFill(io->Theme.Get(UI7Color_Button));
|
||||
// list->LayerUp();
|
||||
list->LayerUp();
|
||||
list->DrawTextEx(FinalPos() + fvec2(off_x, 0), p.c_str(),
|
||||
io->Theme.Get(UI7Color_Text), LiTextFlags_AlignMid,
|
||||
td + io->FramePadding);
|
||||
// list->LayerDown();
|
||||
list->LayerDown();
|
||||
off_x += td.x + io->ItemSpace.x + io->FramePadding.x;
|
||||
}
|
||||
list->DrawText(FinalPos() + fvec2(off_x, io->FramePadding.y * 0.5),
|
||||
@@ -101,6 +101,7 @@ template <typename T>
|
||||
PD_API void DragData<T>::Update() {
|
||||
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||
// Probably need to find a faster solution (caching sizes calculated here)
|
||||
list->SetFont(GetFont());
|
||||
float off_x = 0;
|
||||
for (size_t i = 0; i < elm_count; i++) {
|
||||
std::string p;
|
||||
|
||||
@@ -29,11 +29,11 @@ PD_API void Image::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// Assert(img.get(), "Image is nullptr!");
|
||||
// io->Ren->OnScreen(screen);
|
||||
// list->LayerUp();
|
||||
list->LayerUp();
|
||||
list->BindTexture(img);
|
||||
list->DrawRectFilled(FinalPos(), newsize, 0xffffffff);
|
||||
list->UnbindTexture();
|
||||
// list->LayerDown();
|
||||
list->LayerDown();
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
@@ -28,6 +28,7 @@ namespace UI7 {
|
||||
PD_API void Label::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->SetFont(GetFont());
|
||||
list->DrawTextEx(FinalPos(), label.c_str(), io->Theme.Get(UI7Color_Text),
|
||||
LiTextFlags_NoOOS,
|
||||
PD::fvec2(0, io->CurrentViewPort.pSize.w));
|
||||
|
||||
@@ -70,6 +70,7 @@ template <typename T>
|
||||
PD_API void Slider<T>::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->SetFont(GetFont());
|
||||
std::string p;
|
||||
if constexpr (std::is_floating_point_v<T>) {
|
||||
p = std::format("{:.{}f}", *data, precision);
|
||||
@@ -84,10 +85,10 @@ PD_API void Slider<T>::Draw() {
|
||||
FinalPos() + fvec2(slp + slw - 2, td.y - 2) + io->FramePadding,
|
||||
io->FrameRounding);
|
||||
list->PathFill(io->Theme.Get(UI7Color_ButtonActive));
|
||||
// list->LayerUp();
|
||||
list->LayerUp();
|
||||
list->DrawTextEx(FinalPos(), p.c_str(), io->Theme.Get(UI7Color_Text),
|
||||
LiTextFlags_AlignMid, fvec2(width, td.y) + io->FramePadding);
|
||||
// list->LayerDown();
|
||||
list->LayerDown();
|
||||
list->DrawText(FinalPos() + fvec2(width + io->FramePadding.x * 2.f,
|
||||
io->FramePadding.y * 0.5),
|
||||
label.c_str(), io->Theme.Get(UI7Color_Text));
|
||||
|
||||
+8
-5
@@ -104,6 +104,7 @@ PD_API void Menu::SeparatorText(const std::string& label) {
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l,
|
||||
UI7::Container* self) {
|
||||
l->SetFont(self->GetFont());
|
||||
fvec2 size = self->GetSize();
|
||||
fvec2 tdim = io->Font->GetTextBounds(label.c_str(), io->FontScale);
|
||||
fvec2 pos = self->FinalPos();
|
||||
@@ -218,7 +219,7 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
if (!(Flags & UI7MenuFlags_NoResize)) {
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||
// //l->Layer(1);
|
||||
l->SetLayer(1);
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(0, 20));
|
||||
l->PathAdd(self->FinalPos() + self->GetSize());
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(20, 0));
|
||||
@@ -234,7 +235,7 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
/** Background */
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||
// l->Layer(0);
|
||||
l->SetLayer(0);
|
||||
l->PathRectEx(self->FinalPos(), self->FinalPos() + self->GetSize(), 10.f,
|
||||
LiPathRectFlags_KeepTop | LiPathRectFlags_KeepBot);
|
||||
l->PathFill(io->Theme.Get(UI7Color_Background));
|
||||
@@ -252,11 +253,12 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj(
|
||||
[=, this](UI7::IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||
// l->Layer(20);
|
||||
l->SetFont(self->GetFont());
|
||||
l->SetLayer(20);
|
||||
/** Header Bar */
|
||||
l->DrawRectFilled(self->FinalPos(), self->GetSize(),
|
||||
io->Theme.Get(UI7Color_Header));
|
||||
// l->Layer(21);
|
||||
l->SetLayer(21);
|
||||
/** Inline if statement to shift the Text if collapse sym is shown */
|
||||
/** What the hell is this code btw (didn't found a better way) */
|
||||
l->DrawText(self->FinalPos() +
|
||||
@@ -277,7 +279,7 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l,
|
||||
UI7::Container* self) {
|
||||
/** This sym actually requires layer 21 (i dont know why) */
|
||||
// l->Layer(21);
|
||||
l->SetLayer(21);
|
||||
/**
|
||||
* Symbol (Position Swapping set by pIsOpen ? openpos : closepos;)
|
||||
*/
|
||||
@@ -353,6 +355,7 @@ PD_API bool Menu::BeginTreeNode(const ID& id) {
|
||||
// Object
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([=, this](IO* io, Li::Drawlist* l, Container* self) {
|
||||
l->SetFont(self->GetFont());
|
||||
fvec2 ts = self->FinalPos() + fvec2(0, 7);
|
||||
fvec2 pl[2] = {fvec2(10, 5), fvec2(0, 10)};
|
||||
if (n->second) {
|
||||
|
||||
Reference in New Issue
Block a user