# 0.3.0
- Fix minor issues - Add Custom UV Support to Drawlist and Menu Image - Add DoubleClick to IO Input API - Add Flashbang Theme (Not completly done) - Fix Menu glitch when scrolling was possible when not allowed
This commit is contained in:
parent
b94dfc0c53
commit
ba77dc9b42
@ -52,7 +52,7 @@ execute_process(
|
||||
)
|
||||
|
||||
# Set Project
|
||||
project(palladium LANGUAGES C CXX VERSION 0.2.9)
|
||||
project(palladium LANGUAGES C CXX VERSION 0.3.0)
|
||||
|
||||
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
|
||||
|
||||
|
@ -37,9 +37,10 @@ class Image : public Container {
|
||||
* @param img Image Texture Reference
|
||||
* @param size Custom Size of the Image
|
||||
*/
|
||||
Image(Texture::Ref img, vec2 size = 0.f) {
|
||||
Image(Texture::Ref img, vec2 size = 0.f, LI::Rect uv = vec4(0.f)) {
|
||||
this->img = img;
|
||||
this->newsize = size;
|
||||
this->cuv = uv;
|
||||
if (size.x() != 0 || size.y() != 0) {
|
||||
this->SetSize(size);
|
||||
} else {
|
||||
@ -57,6 +58,7 @@ class Image : public Container {
|
||||
private:
|
||||
Texture::Ref img; ///< Texture reference to the Image
|
||||
vec2 newsize = 0.f; ///< New Size
|
||||
LI::Rect cuv; ///< Custom UV
|
||||
};
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
@ -69,8 +69,10 @@ class DrawList : public SmartCtor<DrawList> {
|
||||
* @param pos Position
|
||||
* @param img Image Texture Reference
|
||||
* @param size Optional Size of the Image
|
||||
* @param uv Custom UV coords
|
||||
*/
|
||||
void AddImage(vec2 pos, Texture::Ref img, vec2 size = 0.f);
|
||||
void AddImage(vec2 pos, Texture::Ref img, vec2 size = 0.f,
|
||||
LI::Rect uv = vec4(0.f));
|
||||
/**
|
||||
* Render a Line from Position A to Position B
|
||||
* @param a Pos a
|
||||
|
@ -57,7 +57,10 @@ class ID {
|
||||
~ID() = default;
|
||||
|
||||
/** Get The ID Initial Name */
|
||||
std::string GetName() const { return name; }
|
||||
const std::string& GetName() const { return name; }
|
||||
|
||||
/** Getter for the raw 32bit int id */
|
||||
const u32& RawID() const { return id; }
|
||||
|
||||
/** Return the ID when casting to u32 */
|
||||
operator u32() const { return id; }
|
||||
|
@ -69,19 +69,13 @@ class IO : public SmartCtor<IO> {
|
||||
vec2 MenuPadding = 5.f;
|
||||
vec2 FramePadding = 5.f;
|
||||
vec2 ItemSpace = vec2(5.f, 2.f);
|
||||
u64 DoubleClickTime = 500; // Milliseconds
|
||||
std::vector<std::pair<UI7::ID, DrawList::Ref>> DrawListRegestry;
|
||||
DrawList::Ref Back;
|
||||
DrawList::Ref Front;
|
||||
u32 NumVertices = 0; ///< Debug Vertices Num
|
||||
u32 NumIndices = 0; ///< Debug Indices Num
|
||||
|
||||
// Layer Rules
|
||||
int ContextBackLayer = 10;
|
||||
int MenuBackLayer = 20;
|
||||
int MenuMainLayer = 30;
|
||||
int MenuFrontLayer = 40;
|
||||
int ContextFrontLayer = 50;
|
||||
|
||||
// DrawListApi
|
||||
void RegisterDrawList(const UI7::ID& id, DrawList::Ref v) {
|
||||
DrawListRegestry.push_back(std::make_pair(id, v));
|
||||
@ -97,8 +91,10 @@ class IO : public SmartCtor<IO> {
|
||||
vec2 DragLastPosition = 0;
|
||||
vec4 DragDestination = 0;
|
||||
Timer::Ref DragTime;
|
||||
bool DragReleased = false; ///< Drag Releaded in Box
|
||||
bool DragReleasedAW = false; ///< Drag Released Anywhere
|
||||
u64 DragLastReleased = 0;
|
||||
bool DragReleased = false; ///< Drag Releaded in Box
|
||||
bool DragReleasedAW = false; ///< Drag Released Anywhere
|
||||
bool DragDoubleRelease = false; ///< Double Click
|
||||
/** Check if an object is Dragged already */
|
||||
bool IsObjectDragged() const { return DraggedObject != 0; }
|
||||
/**
|
||||
@ -147,6 +143,13 @@ class IO : public SmartCtor<IO> {
|
||||
// and Only if still in Box
|
||||
DragReleased = Ren->InBox(Inp->TouchPosLast(), area);
|
||||
DragReleasedAW = true; // Advanced
|
||||
u64 d_rel = Sys::GetTime();
|
||||
if (d_rel - DragLastReleased < DoubleClickTime) {
|
||||
DragDoubleRelease = true;
|
||||
DragLastReleased = 0; // Set 0 to prevent double exec
|
||||
} else {
|
||||
DragLastReleased = d_rel;
|
||||
}
|
||||
// Ensure timer is paused
|
||||
DragTime->Pause();
|
||||
DragTime->Reset();
|
||||
|
@ -80,7 +80,7 @@ class Menu : public SmartCtor<Menu> {
|
||||
* @param img Texture reference of the image
|
||||
* @param size a Custom Size if needed
|
||||
*/
|
||||
void Image(Texture::Ref img, vec2 size = 0.f);
|
||||
void Image(Texture::Ref img, vec2 size = 0.f, LI::Rect uv = vec4(0));
|
||||
|
||||
/**
|
||||
* Color Edit Object that opens a popup editor if clicked
|
||||
|
@ -69,6 +69,11 @@ class Theme : public SmartCtor<Theme> {
|
||||
* @param theme Theme Reference
|
||||
*/
|
||||
static void Default(Theme& theme);
|
||||
/**
|
||||
* White Mode Theme
|
||||
* @param Theme theme reference
|
||||
*/
|
||||
static void Flashbang(Theme& theme);
|
||||
|
||||
/** Revert the last Color Change */
|
||||
Theme& Pop() {
|
||||
|
@ -37,7 +37,7 @@ SOFTWARE.
|
||||
* Major Minor Patch Build
|
||||
* 0x01010000 -> 1.1.0-0
|
||||
*/
|
||||
#define UI7_VERSION 0x00020901
|
||||
#define UI7_VERSION 0x00030000
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
|
@ -50,8 +50,10 @@ void Button::Draw() {
|
||||
Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||
io->Ren->OnScreen(screen);
|
||||
list->AddRectangle(FinalPos(), size, io->Theme->Get(color));
|
||||
list->Layer(list->Layer() + 1);
|
||||
list->AddText(FinalPos() + size * 0.5 - tdim * 0.5, label,
|
||||
io->Theme->Get(UI7Color_Text));
|
||||
list->Layer(list->Layer() - 1);
|
||||
}
|
||||
|
||||
void Button::Update() {
|
||||
|
@ -29,7 +29,7 @@ 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->AddImage(FinalPos(), img, newsize);
|
||||
list->AddImage(FinalPos(), img, newsize, this->cuv);
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
@ -95,28 +95,11 @@ void DrawList::AddText(vec2 pos, const std::string& text, const UI7Color& clr,
|
||||
ren->CurrentScreen()->ScreenType() == Screen::Bottom, it));
|
||||
}
|
||||
e->GetRawObject()->ReCopy();
|
||||
|
||||
////// STILL LEAVING THE OLD CODE BELOW AS IT IS MAYBE NEEDED //////
|
||||
////// IF STATIC TEXT SYSTEM SHOULD HAVE AN DISABLE OPTION //////
|
||||
|
||||
// Dont create a Command here as TextCommand has autosetup
|
||||
// cause it needs to generate multiple commands if
|
||||
// Font uses multiple textures
|
||||
// Oh and Handle Layer management here as well
|
||||
// int l = ren->Layer();
|
||||
// ren->Layer(base + layer);
|
||||
// std::vector<LI::Command::Ref> cmds;
|
||||
// ren->TextCommand(cmds, pos, clr, text, flags, box);
|
||||
// ren->Layer(l);
|
||||
// for (auto c : cmds) {
|
||||
// commands.push_back(
|
||||
// std::make_pair(ren->CurrentScreen()->ScreenType() == Screen::Bottom,
|
||||
// c));
|
||||
// }
|
||||
}
|
||||
|
||||
void DrawList::AddImage(vec2 pos, Texture::Ref img, vec2 size) {
|
||||
void DrawList::AddImage(vec2 pos, Texture::Ref img, vec2 size, LI::Rect uv) {
|
||||
size = size == 0.f ? img->GetSize() : size;
|
||||
uv = (uv.Top() == 0.0f && uv.Bot() == 0.0f) ? img->GetUV() : uv;
|
||||
if (!ren->InBox(pos, size, ren->GetViewport())) {
|
||||
return;
|
||||
}
|
||||
@ -129,7 +112,7 @@ void DrawList::AddImage(vec2 pos, Texture::Ref img, vec2 size) {
|
||||
cmd->SetScissorMode(LI::ScissorMode_Normal);
|
||||
cmd->ScissorRect(clip_rects.top());
|
||||
}
|
||||
ren->QuadCommand(cmd, rect, img->GetUV(), 0xffffffff);
|
||||
ren->QuadCommand(cmd, rect, uv, 0xffffffff);
|
||||
commands.push_back(std::make_pair(
|
||||
ren->CurrentScreen()->ScreenType() == Screen::Bottom, cmd));
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ void UI7::IO::Update() {
|
||||
DragTime->Update();
|
||||
DragReleased = false;
|
||||
DragReleasedAW = false;
|
||||
DragDoubleRelease = false;
|
||||
Framerate = 1000.f / Delta;
|
||||
DrawListRegestry.clear();
|
||||
RegisterDrawList("CtxBackList", Back);
|
||||
|
@ -85,8 +85,8 @@ void UI7::Menu::Checkbox(const std::string& label, bool& v) {
|
||||
r->HandleScrolling(scrolling_off, view_area);
|
||||
}
|
||||
|
||||
void UI7::Menu::Image(Texture::Ref img, vec2 size) {
|
||||
Container::Ref r = ObjectPush(PD::New<UI7::Image>(img, size));
|
||||
void UI7::Menu::Image(Texture::Ref img, vec2 size, LI::Rect uv) {
|
||||
Container::Ref r = ObjectPush(PD::New<UI7::Image>(img, size, uv));
|
||||
r->SetPos(AlignPos(Cursor(), r->GetSize(), view_area, GetAlignment()));
|
||||
CursorMove(r->GetSize());
|
||||
r->Init(io, main);
|
||||
@ -538,6 +538,7 @@ bool UI7::Menu::BeginTreeNode(const UI7::ID& id) {
|
||||
}
|
||||
return n->second;
|
||||
}
|
||||
|
||||
void UI7::Menu::EndTreeNode() {
|
||||
icursoroff.x() -= 10.f;
|
||||
cursor.x() -= 10;
|
||||
@ -591,6 +592,9 @@ void UI7::Menu::MoveHandler() {
|
||||
if (has_touch &&
|
||||
io->DragObject(name + "tmv",
|
||||
vec4(view_area.xy(), vec2(view_area.z(), tbh)))) {
|
||||
if (io->DragDoubleRelease) {
|
||||
is_open = !is_open;
|
||||
}
|
||||
view_area =
|
||||
vec4(view_area.xy() + (io->DragPosition - io->DragLastPosition),
|
||||
view_area.zw());
|
||||
@ -626,7 +630,8 @@ void UI7::Menu::CollapseHandler() {
|
||||
|
||||
void UI7::Menu::PostScrollHandler() {
|
||||
if (has_touch && io->DragObject(id, view_area) && scrolling[1] &&
|
||||
flags & UI7MenuFlags_VtScrolling) {
|
||||
flags & UI7MenuFlags_VtScrolling &&
|
||||
max[1] - view_area.w() + io->MenuPadding[1] > 0) {
|
||||
if (io->DragReleased) {
|
||||
scroll_mod = (io->DragPosition - io->DragLastPosition);
|
||||
} else {
|
||||
|
@ -44,5 +44,24 @@ void Theme::Default(Theme& theme) {
|
||||
theme.Set(UI7Color_ListEven, Color("#CCCCCCFF"));
|
||||
theme.Set(UI7Color_ListOdd, Color("#BBBBBBFF"));
|
||||
}
|
||||
|
||||
void Theme::Flashbang(Theme& theme) {
|
||||
theme.Set(UI7Color_Text, Color("#000000FF"));
|
||||
theme.Set(UI7Color_TextDead, Color("#333333FF"));
|
||||
theme.Set(UI7Color_Background, Color("#eeeeeeFF"));
|
||||
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_Header, Color("#ddddddFF"));
|
||||
theme.Set(UI7Color_HeaderDead, Color("#cdcdcdFF"));
|
||||
theme.Set(UI7Color_Selector, Color("#222222FF"));
|
||||
theme.Set(UI7Color_Checkmark, Color("#ccccccFF"));
|
||||
theme.Set(UI7Color_FrameBackground, Color("#aaaaaaFF"));
|
||||
theme.Set(UI7Color_FrameBackgroundHovered, Color("#909090FF"));
|
||||
theme.Set(UI7Color_Progressbar, Color("#00FF00FF"));
|
||||
theme.Set(UI7Color_ListEven, Color("#CCCCCCFF"));
|
||||
theme.Set(UI7Color_ListOdd, Color("#BBBBBBFF"));
|
||||
}
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
@ -178,6 +178,18 @@ void UI7::Context::MetricsMenu(bool* show) {
|
||||
m->Label(std::format("NumIndices: {} -> {} Tris", io->NumIndices,
|
||||
io->NumIndices / 3));
|
||||
m->Label("Menus: " + std::to_string(menus.size()));
|
||||
if (m->BeginTreeNode("Font")) {
|
||||
for (u32 i = 0; i <= 0x00ff; i++) {
|
||||
auto& c = io->Ren->Font()->GetCodepoint(i);
|
||||
if (!c.invalid()) {
|
||||
m->Image(c.tex(), c.size(), c.uv());
|
||||
if ((i % 15) != 0 || i == 0) {
|
||||
m->SameLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
m->EndTreeNode();
|
||||
}
|
||||
m->SeparatorText("TimeTrace");
|
||||
if (m->BeginTreeNode("Traces (" +
|
||||
std::to_string(Sys::GetTraceMap().size()) + ")")) {
|
||||
@ -280,6 +292,13 @@ void UI7::Context::StyleEditor(bool* show) {
|
||||
io->ItemSpace += 1;
|
||||
}
|
||||
m->SeparatorText("Theme");
|
||||
if (m->Button("Dark")) {
|
||||
UI7::Theme::Default(*io->Theme.get());
|
||||
}
|
||||
m->SameLine();
|
||||
if (m->Button("Flashbang")) {
|
||||
UI7::Theme::Flashbang(*io->Theme.get());
|
||||
}
|
||||
/// Small trick to print without prefix
|
||||
#define ts(x) m->ColorEdit(std::string(#x).substr(9), &io->Theme->GetRef(x));
|
||||
ts(UI7Color_Background);
|
||||
|
Loading…
Reference in New Issue
Block a user