UI7 Add Containers to Layout
- Hotfix in CommandPool - Add UI7 ItemRowHeight (Universal Item Size/Height) - Add Containers to Layout - Add ColorEdit to Menu - Switch Back to COlorEdit in UI7::StyleEditor - Add DrawList Layer Sorting to UI7 (Not working as expected) - STart Work at ColorEdit container
This commit is contained in:
@@ -61,6 +61,7 @@ PD_UI7_API void Checkbox::Draw() {
|
||||
|
||||
PD_UI7_API void Checkbox::Update() {
|
||||
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||
cbs = io->ItemRowHeight;
|
||||
this->SetSize(cbs + fvec2(tdim.x + io->ItemSpace.x, 0));
|
||||
}
|
||||
} // namespace UI7
|
||||
|
||||
@@ -22,7 +22,7 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <pd/ui7/container/coloredit.hpp>
|
||||
#include <pd/ui7/container/label.hpp>
|
||||
#include <pd/ui7/containers.hpp>
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
@@ -33,8 +33,9 @@ PD_UI7_API void ColorEdit::HandleInput() {
|
||||
}
|
||||
// Assert(screen.get(), "Screen is not set up!");
|
||||
// if (screen->ScreenType() == Screen::Bottom) {
|
||||
if (io->InputHandler->DragObject(this->GetID(), fvec4(FinalPos(), size))) {
|
||||
if (io->InputHandler->DragReleased) {
|
||||
if (io->InputHandler->DragObject(this->GetID() + 2,
|
||||
fvec4(FinalPos(), size))) {
|
||||
if (io->InputHandler->DragReleasedAW) {
|
||||
is_shown = !is_shown;
|
||||
}
|
||||
}
|
||||
@@ -44,15 +45,45 @@ PD_UI7_API void ColorEdit::HandleInput() {
|
||||
PD_UI7_API void ColorEdit::Draw() {
|
||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
// io->Ren->OnScreen(screen);
|
||||
list->PathRect(FinalPos(), FinalPos() + 18, io->FrameRounding);
|
||||
list->PathRect(FinalPos(), FinalPos() + io->ItemRowHeight, io->FrameRounding);
|
||||
list->PathFill(*color_ref);
|
||||
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + 18, 0), label,
|
||||
io->Theme->Get(UI7Color_Text));
|
||||
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + io->ItemRowHeight, 0),
|
||||
label, io->Theme->Get(UI7Color_Text));
|
||||
if (is_shown) {
|
||||
if (!layout) {
|
||||
layout = Layout::New(GetID(), io);
|
||||
}
|
||||
layout->AddObject(Label::New("Hello World!", io));
|
||||
layout->SetPosition(FinalPos());
|
||||
layout->AddObjectEx(
|
||||
DynObj::New(
|
||||
[=, this](UI7::IO::Ref io, Li::DrawList::Ref l, Container* thiz) {
|
||||
thiz->SetSize(layout->GetSize());
|
||||
l->Layer(30);
|
||||
l->PathRect(thiz->GetPos(), thiz->GetPos() + thiz->GetSize(),
|
||||
io->FrameRounding);
|
||||
l->PathFill(io->Theme->Get(UI7Color_FrameBackground));
|
||||
}),
|
||||
UI7LytAdd_Front | UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle);
|
||||
auto obj = DynObj::New(
|
||||
[=, this](UI7::IO::Ref io, Li::DrawList::Ref l, Container* thiz) {
|
||||
l->PathRect(thiz->FinalPos(), thiz->FinalPos() + io->ItemRowHeight,
|
||||
io->FrameRounding);
|
||||
l->PathFill(*color_ref);
|
||||
l->DrawText(
|
||||
thiz->FinalPos() + fvec2(io->ItemSpace.x + io->ItemRowHeight, 0),
|
||||
label, io->Theme->Get(UI7Color_Text));
|
||||
});
|
||||
obj->SetSize(PD::fvec2(200, io->ItemRowHeight));
|
||||
layout->AddObject(obj);
|
||||
layout->Label("RGBA: ({}, {}, {}, {})", *((u8*)color_ref),
|
||||
*(((u8*)color_ref) + 1), *(((u8*)color_ref) + 2),
|
||||
*(((u8*)color_ref) + 3));
|
||||
layout->Label("Hex: {}", PD::Color(*color_ref).Hex(true));
|
||||
|
||||
layout->Slider<u8>("R", ((u8*)color_ref));
|
||||
layout->Slider<u8>("G", ((u8*)color_ref) + 1);
|
||||
layout->Slider<u8>("B", ((u8*)color_ref) + 2);
|
||||
layout->Slider<u8>("A", ((u8*)color_ref) + 3);
|
||||
layout->Update();
|
||||
list->Merge(layout->GetDrawList());
|
||||
// io->RegisterDrawList(GetID(), layout->GetDrawList());
|
||||
@@ -61,7 +92,8 @@ PD_UI7_API void ColorEdit::Draw() {
|
||||
|
||||
PD_UI7_API void ColorEdit::Update() {
|
||||
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||
this->SetSize(fvec2(tdim.x + io->ItemSpace.x + 18, 18));
|
||||
this->SetSize(
|
||||
fvec2(tdim.x + io->ItemSpace.x + io->ItemRowHeight, io->ItemRowHeight));
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user