Update
- Add data getter to DrawList - Add NoOOS (Out Of screen Rendering) flag to text renderer (requires a textbox) - UI7 Label Wrapping (optinal and beta)
This commit is contained in:
@@ -198,6 +198,7 @@ class PD_LITHIUM_API DrawList {
|
|||||||
}
|
}
|
||||||
pClipRects.pop();
|
pClipRects.pop();
|
||||||
}
|
}
|
||||||
|
const std::vector<Command::Ref>& Data() const { return pDrawList; }
|
||||||
/** One linear Clip rect Setup */
|
/** One linear Clip rect Setup */
|
||||||
void pClipCmd(Command* cmd);
|
void pClipCmd(Command* cmd);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ enum LiTextFlags_ {
|
|||||||
LiTextFlags_Wrap = 1 << 3, ///< Wrap Text: May be runs better with TMS
|
LiTextFlags_Wrap = 1 << 3, ///< Wrap Text: May be runs better with TMS
|
||||||
LiTextFlags_Short = 1 << 4, ///< Short Text: May be runs better with TMS
|
LiTextFlags_Short = 1 << 4, ///< Short Text: May be runs better with TMS
|
||||||
LiTextFlags_Scroll = 1 << 5, ///< Not implemented [scoll text if to long]
|
LiTextFlags_Scroll = 1 << 5, ///< Not implemented [scoll text if to long]
|
||||||
|
LiTextFlags_NoOOS = 1 << 6, ///< No Out of Screen Rendering
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -104,7 +105,7 @@ class PD_LITHIUM_API Font {
|
|||||||
std::string pWrapText(const std::string& txt, float scale,
|
std::string pWrapText(const std::string& txt, float scale,
|
||||||
const PD::fvec2& max, PD::fvec2& dim);
|
const PD::fvec2& max, PD::fvec2& dim);
|
||||||
std::string pShortText(const std::string& txt, float scale,
|
std::string pShortText(const std::string& txt, float scale,
|
||||||
const PD::fvec2& max, PD::fvec2& dim);
|
const PD::fvec2& max, PD::fvec2& dim);
|
||||||
|
|
||||||
/** Data Section */
|
/** Data Section */
|
||||||
int PixelHeight;
|
int PixelHeight;
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ class PD_UI7_API Label : public Container {
|
|||||||
* @note This function is usally called by Menu::Update
|
* @note This function is usally called by Menu::Update
|
||||||
* */
|
* */
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
/**
|
||||||
|
* Override Update func to support Text modifications
|
||||||
|
*/
|
||||||
|
void Update() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fvec2 tdim; ///< Text Size
|
fvec2 tdim; ///< Text Size
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ class PD_UI7_API IO {
|
|||||||
fvec2 MinSliderDragSize = 10.f; // Min height (Vt) and Min Width (Hz)
|
fvec2 MinSliderDragSize = 10.f; // Min height (Vt) and Min Width (Hz)
|
||||||
bool ShowMenuBorder = true;
|
bool ShowMenuBorder = true;
|
||||||
bool ShowFrameBorder = false; // not implemented yet
|
bool ShowFrameBorder = false; // not implemented yet
|
||||||
|
bool WrapLabels = false; // Beta state
|
||||||
float OverScrollMod = 0.15f;
|
float OverScrollMod = 0.15f;
|
||||||
u64 DoubleClickTime = 500; // Milliseconds
|
u64 DoubleClickTime = 500; // Milliseconds
|
||||||
std::list<std::pair<UI7::ID, Li::DrawList::Ref>> DrawListRegestry;
|
std::list<std::pair<UI7::ID, Li::DrawList::Ref>> DrawListRegestry;
|
||||||
|
|||||||
@@ -272,6 +272,15 @@ PD_LITHIUM_API void Font::CmdTextEx(std::vector<Command::Ref> &cmds,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto &it : lines) {
|
for (auto &it : lines) {
|
||||||
|
if (flags & LiTextFlags_NoOOS) {
|
||||||
|
if (rpos.y + off.y + lh < 0) {
|
||||||
|
off.y += lh;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (rpos.y + off.y > box.y && box.y != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (flags & LiTextFlags_Short) {
|
if (flags & LiTextFlags_Short) {
|
||||||
fvec2 tmp_dim;
|
fvec2 tmp_dim;
|
||||||
it = pShortText(it, scale, box - pos, tmp_dim);
|
it = pShortText(it, scale, box - pos, tmp_dim);
|
||||||
|
|||||||
@@ -31,10 +31,27 @@ PD_UI7_API void Label::Draw() {
|
|||||||
if (pCLipRectUsed) {
|
if (pCLipRectUsed) {
|
||||||
list->PushClipRect(pClipRect);
|
list->PushClipRect(pClipRect);
|
||||||
}
|
}
|
||||||
list->DrawText(FinalPos(), label, io->Theme->Get(UI7Color_Text));
|
list->DrawTextEx(FinalPos(), label, io->Theme->Get(UI7Color_Text),
|
||||||
|
LiTextFlags_NoOOS, PD::fvec2(0, io->CurrentViewPort.w));
|
||||||
if (pCLipRectUsed) {
|
if (pCLipRectUsed) {
|
||||||
list->PopClipRect();
|
list->PopClipRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PD_UI7_API void Label::Update() {
|
||||||
|
/**
|
||||||
|
* Todo: This is a hacky workaround
|
||||||
|
* Needs proper optimisation
|
||||||
|
* Needs a max size (to support sligning dynaically by the window size)
|
||||||
|
*/
|
||||||
|
if (io->WrapLabels) {
|
||||||
|
this->label =
|
||||||
|
io->Font->pWrapText(this->label, io->FontScale,
|
||||||
|
PD::fvec2(io->CurrentViewPort.z - FinalPos().x * 4,
|
||||||
|
io->CurrentViewPort.w),
|
||||||
|
this->tdim);
|
||||||
|
SetSize(tdim);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -81,7 +81,9 @@ PD_UI7_API void Menu::Separator() {
|
|||||||
pIO->Theme->Get(UI7Color_TextDead));
|
pIO->Theme->Get(UI7Color_TextDead));
|
||||||
});
|
});
|
||||||
// Set size before pushing (cause Cursor Move will require it)
|
// Set size before pushing (cause Cursor Move will require it)
|
||||||
r->SetSize(fvec2(pLayout->Size.x - 10, 1));
|
r->SetSize(fvec2(
|
||||||
|
pLayout->Size.x - pIO->MenuPadding.x * 2 - pLayout->InitialCursorOffset.x,
|
||||||
|
1));
|
||||||
pLayout->AddObject(r);
|
pLayout->AddObject(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +111,9 @@ PD_UI7_API void Menu::SeparatorText(const std::string& label) {
|
|||||||
fvec2(pLayout->Size.x, self->GetSize().y));
|
fvec2(pLayout->Size.x, self->GetSize().y));
|
||||||
});
|
});
|
||||||
// Set size before pushing (cause Cursor Move will require it)
|
// Set size before pushing (cause Cursor Move will require it)
|
||||||
r->SetSize(
|
r->SetSize(fvec2(
|
||||||
fvec2(pLayout->Size.x - 10, pIO->Font->PixelHeight * pIO->FontScale));
|
pLayout->Size.x - pIO->MenuPadding.x * 2 - pLayout->InitialCursorOffset.x,
|
||||||
|
pIO->Font->PixelHeight * pIO->FontScale));
|
||||||
pLayout->AddObject(r);
|
pLayout->AddObject(r);
|
||||||
}
|
}
|
||||||
PD_UI7_API void Menu::HandleFocus() {
|
PD_UI7_API void Menu::HandleFocus() {
|
||||||
|
|||||||
Reference in New Issue
Block a user