# Changes 0.2.8

- Fix Flickering problem in StaticText api
- Fix Lagacy and Container HandleScrolling InBox checks
- Add IO Flags define for future
- Implement Single Object Dragging API by IO Context
- Add TreeNodes
- Use ioMenuPadding and ItemSpace
- Add StyleEditorMenu
- Rework ContainerApi to take functions from IO and add an Update function template for Updating internal values if required
- Use new DragApi for MenuCollabse, MenuDragging, MenuResize, SliderDragging and TreeNodes Open/Close
- Add Helper Defines for Metrics Menu [INTERNAL]
- Add TimeTrace as Tree to Metrics as well as other new Data
- Add GetRawObject to StaticText for custom rendering like ui7
- Add DrawlistRegestry to correctly render Menus in their own layer ranges
This commit is contained in:
2025-03-08 13:52:11 +01:00
parent e282d0ec7e
commit 09b1937a8d
22 changed files with 536 additions and 266 deletions

View File

@ -24,6 +24,7 @@ SOFTWARE.
*/
#include <pd/ui7/container/container.hpp>
#include <pd/ui7/io.hpp>
namespace PD {
namespace UI7 {
@ -42,13 +43,9 @@ class Button : public Container {
* @param pos Base Position
* @param lr Reference to the Renderer
*/
Button(const std::string& label, vec2 pos, LI::Renderer::Ref lr) {
this->screen = lr->CurrentScreen();
Button(const std::string& label, UI7::IO::Ref io) {
this->label = label;
this->SetPos(pos);
this->tdim = lr->GetTextDimensions(label);
color = UI7Color_Button;
this->SetSize(tdim + vec2(8, 4));
this->tdim = io->Ren->GetTextDimensions(label);
}
~Button() = default;
@ -66,11 +63,14 @@ class Button : public Container {
* */
void Draw() override;
/** Function to Update Size if framepadding changes */
void Update() override;
private:
vec2 tdim; ///< Text size
UI7Color color; ///< current button color
std::string label; ///< Label of the Button
bool pressed = false; ///< ispressed value
vec2 tdim; ///< Text size
UI7Color color = UI7Color_Button; ///< current button color
std::string label; ///< Label of the Button
bool pressed = false; ///< ispressed value
};
} // namespace UI7
} // namespace PD

View File

@ -38,19 +38,13 @@ class Checkbox : public Container {
/**
* Constructor for Checkbox Object
* @param label Label of the Checkbox
* @param pos Base Position
* @param usr_ref Reference to the bool value to update
* @param lr Reference to the renderer (for text size calculation)
* @param io IO Reference
*/
Checkbox(const std::string& label, vec2 pos, bool& usr_ref,
LI::Renderer::Ref lr)
Checkbox(const std::string& label, bool& usr_ref, UI7::IO::Ref io)
: usr_ref(usr_ref) {
this->screen = lr->CurrentScreen();
this->label = label;
this->SetPos(pos);
this->tdim = lr->GetTextDimensions(label);
color = UI7Color_FrameBackground;
this->SetSize(cbs + vec2(tdim.x() + 5, 0));
this->tdim = io->Ren->GetTextDimensions(label);
}
~Checkbox() = default;
/**
@ -65,12 +59,15 @@ class Checkbox : public Container {
* */
void Draw() override;
/** Update Size if framepadding changed */
void Update() override;
private:
vec2 tdim; ///< Text Size
vec2 cbs = vec2(18); ///< Checkbox size
UI7Color color; ///< Checkbox background Color
std::string label; ///< Checkbox Label
bool& usr_ref; ///< User bool reference
vec2 tdim; ///< Text Size
vec2 cbs = vec2(18); ///< Checkbox size
UI7Color color = UI7Color_FrameBackground; ///< Checkbox background Color
std::string label; ///< Checkbox Label
bool& usr_ref; ///< User bool reference
};
} // namespace UI7
} // namespace PD

View File

@ -28,6 +28,7 @@ SOFTWARE.
#include <pd/core/vec.hpp>
#include <pd/drivers/hid.hpp>
#include <pd/ui7/drawlist.hpp>
#include <pd/ui7/io.hpp>
namespace PD {
namespace UI7 {
@ -54,14 +55,13 @@ class Container : public SmartCtor<Container> {
/**
* Init Function Required by every Object that uses
* Render or Input functions
* @param r Renderer Reference
* @param io IO Reference
* @param l DrawList Reference
* @param lt Theme Reference
*/
void Init(LI::Renderer::Ref r, UI7::DrawList::Ref l, UI7::Theme::Ref lt) {
void Init(UI7::IO::Ref io, UI7::DrawList::Ref l) {
list = l;
theme = lt;
ren = r;
this->io = io;
this->screen = io->Ren->CurrentScreen();
}
/** Setter for Position */
@ -106,6 +106,8 @@ class Container : public SmartCtor<Container> {
virtual void HandleInput(Hid::Ref inp) {}
/** Tamplate function for Object rendering */
virtual void Draw() {}
/** Template function to update internal data (if needed) */
virtual void Update() {}
/**
* Function to unlock Input after Rendering is done in
@ -140,10 +142,8 @@ class Container : public SmartCtor<Container> {
vec2 size;
/** Reference to the Drawlist to Draw to*/
UI7::DrawList::Ref list;
/** Reference to the theme to use*/
UI7::Theme::Ref theme;
/** Reference to the Renderer*/
LI::Renderer::Ref ren;
/** IO Reference for Renderer and Theme */
UI7::IO::Ref io;
/** Reference to the parent container*/
Container::Ref parent;
/** Object ID (0 if unused)*/

View File

@ -35,14 +35,10 @@ class Image : public Container {
/**
* Constructor for the Image Object
* @param img Image Texture Reference
* @param pos Base Position
* @param lr Renderer Reference [to determinate screen]
* @param size Custom Size of the Image
*/
Image(Texture::Ref img, vec2 pos, LI::Renderer::Ref lr, vec2 size = 0.f) {
this->screen = lr->CurrentScreen();
Image(Texture::Ref img, vec2 size = 0.f) {
this->img = img;
this->SetPos(pos);
this->newsize = size;
if (size.x() != 0 || size.y() != 0) {
this->SetSize(size);

View File

@ -35,15 +35,11 @@ class Label : public Container {
/**
* Constructor for Label Object
* @param label Label [Text] to Draw
* @param pos Base Position
* @param lr Renderer Reference
*/
Label(const std::string& label, vec2 pos, LI::Renderer::Ref lr) {
this->screen = lr->CurrentScreen();
Label(const std::string& label, LI::Renderer::Ref lr) {
this->label = label;
this->SetPos(pos);
this->tdim = lr->GetTextDimensions(label);
color = UI7Color_Text;
this->SetSize(tdim);
}
~Label() = default;
@ -55,9 +51,9 @@ class Label : public Container {
void Draw() override;
private:
vec2 tdim; ///< Text Size
UI7Color color; ///< Color
std::string label; ///< Text to Render
vec2 tdim; ///< Text Size
UI7Color color = UI7Color_Text; ///< Color
std::string label; ///< Text to Render
};
} // namespace UI7
} // namespace PD