# 0.3.1-1
- Add Deltatime usage for Overscroll as well as a config value for ids multiplier - Add Function to Layout to remove all ID Objects - Add step and precision to DragData as well as setting min and max to their type limits - Use the Address for now for the id of the DragData (cause with tree nodes opened backwars all DragData will share the same data reference) - Add a fix to MaxPosition in Layout to be actually the max Position on X axis
This commit is contained in:
@ -48,7 +48,7 @@ void DragData<T>::HandleInput() {
|
||||
for (size_t i = 0; i < elm_count; i++) {
|
||||
std::string p;
|
||||
if constexpr (std::is_floating_point_v<T>) {
|
||||
p = std::format("{:.1f}", data[i]);
|
||||
p = std::format("{:.{}f}", data[i], precision);
|
||||
} else {
|
||||
p = std::format("{}", data[i]);
|
||||
}
|
||||
@ -57,9 +57,9 @@ void DragData<T>::HandleInput() {
|
||||
if (io->DragObject(
|
||||
this->GetID() + i + 1,
|
||||
vec4(FinalPos() + vec2(off_x, 0), tdim + io->FramePadding))) {
|
||||
data[i] = std::clamp(
|
||||
T(data[i] + (io->DragPosition[0] - io->DragLastPosition[0])),
|
||||
this->min, this->max);
|
||||
data[i] = std::clamp(T(data[i] + (step * (io->DragPosition[0] -
|
||||
io->DragLastPosition[0]))),
|
||||
this->min, this->max);
|
||||
}
|
||||
off_x += tdim.x() + io->ItemSpace.x() + io->FramePadding.x();
|
||||
}
|
||||
@ -75,7 +75,7 @@ void DragData<T>::Draw() {
|
||||
for (size_t i = 0; i < elm_count; i++) {
|
||||
std::string p;
|
||||
if constexpr (std::is_floating_point_v<T>) {
|
||||
p = std::format("{:.1f}", data[i]);
|
||||
p = std::format("{:.{}f}", data[i], precision);
|
||||
} else {
|
||||
p = std::format("{}", data[i]);
|
||||
}
|
||||
@ -88,14 +88,26 @@ void DragData<T>::Draw() {
|
||||
list->Layer(list->Layer() - 1);
|
||||
off_x += td.x() + io->ItemSpace.x() + io->FramePadding.x();
|
||||
}
|
||||
list->AddText(FinalPos() + vec2(off_x, 0), label,
|
||||
list->AddText(FinalPos() + vec2(off_x, io->FramePadding.y() * 0.5), label,
|
||||
io->Theme->Get(UI7Color_Text));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DragData<T>::Update() {
|
||||
Assert(io.get(), "Did you run Container::Init correctly?");
|
||||
this->SetSize(vec2(tdim.x() + io->ItemSpace.x() + 20, 20));
|
||||
// Probably need to find a faster solution (caching sizes calculated here)
|
||||
float off_x = 0;
|
||||
for (size_t i = 0; i < elm_count; i++) {
|
||||
std::string p;
|
||||
if constexpr (std::is_floating_point_v<T>) {
|
||||
p = std::format("{:.{}f}", data[i], precision);
|
||||
} else {
|
||||
p = std::format("{}", data[i]);
|
||||
}
|
||||
vec2 tdim = io->Ren->GetTextDimensions(p);
|
||||
off_x += tdim.x() + io->ItemSpace.x() + io->FramePadding.x();
|
||||
}
|
||||
this->SetSize(vec2(tdim.x() + off_x, tdim.y() + io->FramePadding.y()));
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
@ -44,7 +44,7 @@ void Layout::CursorMove(const vec2& size) {
|
||||
Cursor[1] + size[1] + IO->ItemSpace[1]);
|
||||
}
|
||||
// Logical Issue here as x should use a max check
|
||||
MaxPosition = vec2(SamelineCursor[0], Cursor[1]);
|
||||
MaxPosition = vec2(std::max(MaxPosition[0], SamelineCursor[0]), Cursor[1]);
|
||||
}
|
||||
|
||||
bool Layout::ObjectWorkPos(vec2& movpos) {
|
||||
|
@ -249,7 +249,7 @@ void UI7::Menu::PostHandler() {
|
||||
if (Layout->ScrollOffset[1] > Layout->MaxPosition[1] - Layout->Size.y() &&
|
||||
Layout->MaxPosition[1] != 0.f &&
|
||||
Layout->MaxPosition[1] >= Layout->Size.y() - io->MenuPadding[1]) {
|
||||
Layout->ScrollOffset[1] -= 3.f;
|
||||
Layout->ScrollOffset[1] -= io->OverScrollMod * io->Delta;
|
||||
if (Layout->ScrollOffset[1] <
|
||||
Layout->MaxPosition[1] - Layout->Size.y()) {
|
||||
Layout->ScrollOffset[1] = Layout->MaxPosition[1] - Layout->Size.y();
|
||||
@ -258,7 +258,7 @@ void UI7::Menu::PostHandler() {
|
||||
|
||||
/// Do the Same as above just for Overscroll back to the top
|
||||
if (Layout->ScrollOffset[1] < 0) {
|
||||
Layout->ScrollOffset[1] += 3.f;
|
||||
Layout->ScrollOffset[1] += io->OverScrollMod * io->Delta;
|
||||
if (Layout->ScrollOffset[1] > 0) {
|
||||
Layout->ScrollOffset[1] = 0;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace UI7 {
|
||||
void Theme::Default(Theme& theme) {
|
||||
theme.Set(UI7Color_Text, Color("#FFFFFFFF"));
|
||||
theme.Set(UI7Color_TextDead, Color("#AAAAAAFF"));
|
||||
theme.Set(UI7Color_Background, Color("#222222aa"));
|
||||
theme.Set(UI7Color_Background, Color("#222222ff"));
|
||||
theme.Set(UI7Color_Button, Color("#111111FF"));
|
||||
theme.Set(UI7Color_ButtonDead, Color("#080808FF"));
|
||||
theme.Set(UI7Color_ButtonActive, Color("#2A2A2AFF"));
|
||||
@ -52,7 +52,7 @@ void Theme::Flashbang(Theme& theme) {
|
||||
theme.Set(UI7Color_Button, Color("#ccccccFF"));
|
||||
theme.Set(UI7Color_ButtonDead, Color("#bbbbbbFF"));
|
||||
theme.Set(UI7Color_ButtonActive, Color("#ccccccFF"));
|
||||
theme.Set(UI7Color_ButtonHovered, Color("#cbcbcbFF"));
|
||||
theme.Set(UI7Color_ButtonHovered, Color("#acacacFF"));
|
||||
theme.Set(UI7Color_Header, Color("#ddddddFF"));
|
||||
theme.Set(UI7Color_HeaderDead, Color("#cdcdcdFF"));
|
||||
theme.Set(UI7Color_Selector, Color("#222222FF"));
|
||||
|
@ -260,6 +260,8 @@ void UI7::Context::StyleEditor(bool* show) {
|
||||
m->DragData("FramePadding", (float*)&io->FramePadding, 2, 0.f, 100.f);
|
||||
m->DragData("ItemSpace", (float*)&io->ItemSpace, 2, 0.f, 100.f);
|
||||
m->DragData("MinSliderSize", (float*)&io->MinSliderDragSize, 2, 1.f, 100.f);
|
||||
m->DragData("OverScroll Modifier", &io->OverScrollMod, 1, 0.01f,
|
||||
std::numeric_limits<float>::max(), 0.01f, 2);
|
||||
m->SeparatorText("Theme");
|
||||
if (m->Button("Dark")) {
|
||||
UI7::Theme::Default(*io->Theme.get());
|
||||
@ -270,8 +272,9 @@ void UI7::Context::StyleEditor(bool* show) {
|
||||
}
|
||||
/// Small trick to print without prefix
|
||||
#define ts(x) m->ColorEdit(std::string(#x).substr(9), &io->Theme->GetRef(x));
|
||||
#define ts2(x) \
|
||||
m->DragData(std::string(#x).substr(9), (u8*)&io->Theme->GetRef(x), 4, (u8)0, (u8)255);
|
||||
#define ts2(x) \
|
||||
m->DragData(std::string(#x).substr(9), (u8*)&io->Theme->GetRef(x), 4, (u8)0, \
|
||||
(u8)255);
|
||||
ts2(UI7Color_Background);
|
||||
ts2(UI7Color_Button);
|
||||
ts2(UI7Color_ButtonDead);
|
||||
|
Reference in New Issue
Block a user