Compare commits
79
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eafe5c9be5
|
||
|
|
d18e397eaf
|
||
|
|
fc5a357caa
|
||
|
|
a1cb3bf290
|
||
|
|
8c1063640c
|
||
|
|
85f50df154
|
||
|
|
32c94e0776
|
||
|
|
6b5f30b334
|
||
|
|
42cb7ce2ed
|
||
|
|
26a8c230c6
|
||
|
|
0a5a86459b
|
||
|
|
0f25a70901
|
||
|
|
6a22b26a3d
|
||
|
|
245cc0f314
|
||
|
|
cb437d41a0
|
||
|
|
322ce785b9
|
||
|
|
b29e298d55
|
||
|
|
2801b876e6
|
||
|
|
f1540f0098
|
||
|
|
54584728c3
|
||
|
|
daaf473af7
|
||
|
|
9ed3ed233d
|
||
|
|
dd97aab749
|
||
|
|
0746295013
|
||
|
|
2984354884
|
||
|
|
4d2470b0c6
|
||
|
|
cfb6a9b3dd
|
||
|
|
799e779fe6
|
||
|
|
7f708a565e
|
||
|
|
280ce524bf
|
||
|
|
b99fc39444
|
||
|
|
6dbf5a4812
|
||
|
|
ff3b241dd2
|
||
|
|
7a1751589e
|
||
|
|
8a4b3c119d
|
||
|
|
1f7d96a455
|
||
|
|
c9768010f2
|
||
|
|
679de3ae94
|
||
|
|
af7fc026df
|
||
|
|
5bc8046ebe
|
||
|
|
8215baac99
|
||
|
|
a776addf11
|
||
|
|
1cf3b6f8e6
|
||
|
|
b5321ca1a1
|
||
|
|
4498c2c0fb
|
||
|
|
818b086f08
|
||
|
|
e560496512
|
||
|
|
7b6e611f12
|
||
|
|
72deaad28d
|
||
|
|
2e652a3c24
|
||
|
|
784421fa6c
|
||
|
|
bc06a3fee8
|
||
|
|
d2ab60c824
|
||
|
|
a8fe58ef0f
|
||
|
|
eea0e9844f
|
||
|
|
4777c85f9a
|
||
|
|
b49c0bd3dc
|
||
|
|
4db5d98cb2
|
||
|
|
794e06b890
|
||
|
|
d8efcd41b1
|
||
|
|
4dab1987d1
|
||
|
|
6fab4a07a9
|
||
|
|
baad2ce15c
|
||
|
|
a86c13b9a3
|
||
|
|
3b0b103eb3
|
||
|
|
6beef97cdf
|
||
|
|
afe30a5dbd
|
||
|
|
e6cd8b7d24
|
||
|
|
66602a79e0
|
||
|
|
a28b7318d2
|
||
|
|
71563e8979
|
||
|
|
7d89ab1c47
|
||
|
|
186fce803e
|
||
|
|
66412ca8e0
|
||
|
|
e04046720b
|
||
|
|
d4c59e5b61
|
||
|
|
fe9194b907
|
||
|
|
4924d86bc0
|
||
|
|
41b612ec0a
|
+1
-1
@@ -1 +1 @@
|
|||||||
vendor/* linguist-vendored
|
vendor/* linguist-vendored
|
||||||
@@ -52,7 +52,6 @@ set(PD_SOURCES
|
|||||||
source/lithium/drawlist.cpp
|
source/lithium/drawlist.cpp
|
||||||
source/lithium/font.cpp
|
source/lithium/font.cpp
|
||||||
source/lithium/math.cpp
|
source/lithium/math.cpp
|
||||||
source/lithium/pools.cpp
|
|
||||||
|
|
||||||
# UI7
|
# UI7
|
||||||
source/ui7/io.cpp
|
source/ui7/io.cpp
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ option(PD_ENABLE_CITRO3D "Enable Citro3D Support (3DS)" OFF)
|
|||||||
option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
|
option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
|
||||||
option(PD_ENABLE_HID_GLFW "Enable GLFW Input Driver" ON)
|
option(PD_ENABLE_HID_GLFW "Enable GLFW Input Driver" ON)
|
||||||
option(PD_ENABLE_HID_NX "Enable NX Input Driver" OFF)
|
option(PD_ENABLE_HID_NX "Enable NX Input Driver" OFF)
|
||||||
option(PD_ENABLE_HID3DS "Enable 3ds Input Driver" OFF)
|
|
||||||
|
|
||||||
if(NOT WIN32) # cause we are not on windows...
|
if(NOT WIN32) # cause we are not on windows...
|
||||||
set(PD_ENABLE_DIRECTX9 OFF)
|
set(PD_ENABLE_DIRECTX9 OFF)
|
||||||
@@ -22,7 +21,6 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
|||||||
set(PD_ENABLE_CITRO3D ON)
|
set(PD_ENABLE_CITRO3D ON)
|
||||||
set(PD_ENABLE_HID_GLFW OFF)
|
set(PD_ENABLE_HID_GLFW OFF)
|
||||||
set(PD_ENABLE_HID_NX OFF)
|
set(PD_ENABLE_HID_NX OFF)
|
||||||
set(PD_ENABLE_HID3DS ON)
|
|
||||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||||
set(PD_ENABLE_OPENGL2 OFF)
|
set(PD_ENABLE_OPENGL2 OFF)
|
||||||
set(PD_ENABLE_OPENGL3 ON)
|
set(PD_ENABLE_OPENGL3 ON)
|
||||||
@@ -38,7 +36,6 @@ add_library(pd-system STATIC
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_3ds.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_glfw.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_glfw.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_nx.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/source/hid_nx.cpp
|
||||||
)
|
)
|
||||||
@@ -67,7 +64,6 @@ target_compile_definitions(pd-system
|
|||||||
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
|
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
|
||||||
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:PD_ENABLE_HID_GLFW>
|
$<$<BOOL:${PD_ENABLE_HID_GLFW}>:PD_ENABLE_HID_GLFW>
|
||||||
$<$<BOOL:${PD_ENABLE_HID_NX}>:PD_ENABLE_HID_NX>
|
$<$<BOOL:${PD_ENABLE_HID_NX}>:PD_ENABLE_HID_NX>
|
||||||
$<$<BOOL:${PD_ENABLE_HID3DS}>:PD_ENABLE_HID3DS>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Palladium
|
# Palladium
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <pd/drivers/hid.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
|
||||||
class Hid3DS : public HidDriver {
|
|
||||||
public:
|
|
||||||
Hid3DS();
|
|
||||||
~Hid3DS();
|
|
||||||
|
|
||||||
void Update() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct Impl;
|
|
||||||
Impl* impl;
|
|
||||||
};
|
|
||||||
} // namespace PD
|
|
||||||
@@ -7,5 +7,4 @@
|
|||||||
#include <pd_system/gfx_opengl3.hpp>
|
#include <pd_system/gfx_opengl3.hpp>
|
||||||
|
|
||||||
// Hid
|
// Hid
|
||||||
#include <pd_system/hid_3ds.hpp>
|
#include <pd_system/hid_glfw.hpp>
|
||||||
#include <pd_system/hid_glfw.hpp>
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
#include <pd_system/hid_3ds.hpp>
|
|
||||||
#if defined(PD_ENABLE_HID3DS) && defined(__3DS__)
|
|
||||||
#include <3ds.h>
|
|
||||||
namespace PD {
|
|
||||||
struct Hid3DS::Impl {
|
|
||||||
std::string* Text;
|
|
||||||
bool InTextMode = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
Hid3DS::Hid3DS() : HidDriver("Hid3DS") {
|
|
||||||
impl = new Impl;
|
|
||||||
|
|
||||||
pFlags |= PDHidBackendFlags_HasGamepad;
|
|
||||||
pFlags |= PDHidBackendFlags_HasTouch;
|
|
||||||
|
|
||||||
pGamepad[KEY_A] = HidInternal::Gamepad::A;
|
|
||||||
pGamepad[KEY_B] = HidInternal::Gamepad::B;
|
|
||||||
pGamepad[KEY_X] = HidInternal::Gamepad::X;
|
|
||||||
pGamepad[KEY_Y] = HidInternal::Gamepad::Y;
|
|
||||||
pGamepad[KEY_START] = HidInternal::Gamepad::Start;
|
|
||||||
pGamepad[KEY_SELECT] = HidInternal::Gamepad::Select;
|
|
||||||
pGamepad[KEY_L] = HidInternal::Gamepad::L;
|
|
||||||
pGamepad[KEY_R] = HidInternal::Gamepad::R;
|
|
||||||
pGamepad[KEY_DUP] = HidInternal::Gamepad::DUp;
|
|
||||||
pGamepad[KEY_DDOWN] = HidInternal::Gamepad::DDown;
|
|
||||||
pGamepad[KEY_DLEFT] = HidInternal::Gamepad::DLeft;
|
|
||||||
pGamepad[KEY_DRIGHT] = HidInternal::Gamepad::DRight;
|
|
||||||
pGamepad[KEY_CPAD_UP] = HidInternal::Gamepad::CPUp;
|
|
||||||
pGamepad[KEY_CPAD_DOWN] = HidInternal::Gamepad::CPDown;
|
|
||||||
pGamepad[KEY_CPAD_LEFT] = HidInternal::Gamepad::CPLeft;
|
|
||||||
pGamepad[KEY_CPAD_RIGHT] = HidInternal::Gamepad::CPRight;
|
|
||||||
pGamepad[KEY_CSTICK_UP] = HidInternal::Gamepad::CSUp;
|
|
||||||
pGamepad[KEY_CSTICK_DOWN] = HidInternal::Gamepad::CSDown;
|
|
||||||
pGamepad[KEY_CSTICK_LEFT] = HidInternal::Gamepad::CSLeft;
|
|
||||||
pGamepad[KEY_CSTICK_RIGHT] = HidInternal::Gamepad::CSRight;
|
|
||||||
pGamepad[KEY_ZL] = HidInternal::Gamepad::ZL;
|
|
||||||
pGamepad[KEY_ZR] = HidInternal::Gamepad::ZR;
|
|
||||||
pGamepad[KEY_TOUCH] = HidInternal::Gamepad::Touch;
|
|
||||||
}
|
|
||||||
|
|
||||||
Hid3DS::~Hid3DS() { delete impl; }
|
|
||||||
|
|
||||||
void Hid3DS::Update() {
|
|
||||||
HidDriver::Update(); // clear stats
|
|
||||||
hidScanInput();
|
|
||||||
u32 kd = hidKeysDown();
|
|
||||||
u32 kh = hidKeysHeld();
|
|
||||||
u32 ku = hidKeysUp();
|
|
||||||
|
|
||||||
for (const auto& b : pGamepad) {
|
|
||||||
if (b.first & kd) {
|
|
||||||
pGamepadEvents[0][Event::Down] |= b.second;
|
|
||||||
}
|
|
||||||
if (b.first & kh) {
|
|
||||||
pGamepadEvents[0][Event::Held] |= b.second;
|
|
||||||
}
|
|
||||||
if (b.first & ku) {
|
|
||||||
pGamepadEvents[0][Event::Up] |= b.second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (pLocked) {
|
|
||||||
SwapTab();
|
|
||||||
}*/
|
|
||||||
touchPosition t;
|
|
||||||
hidTouchRead(&t);
|
|
||||||
pMouse[0] = fvec2(t.px, t.py);
|
|
||||||
}
|
|
||||||
} // namespace PD
|
|
||||||
#else
|
|
||||||
struct GLFWgamepadstate {};
|
|
||||||
namespace PD {
|
|
||||||
|
|
||||||
Hid3DS::Hid3DS() : HidDriver("Hid3DS") {}
|
|
||||||
|
|
||||||
Hid3DS::~Hid3DS() {}
|
|
||||||
|
|
||||||
void Hid3DS::Update() {
|
|
||||||
HidDriver::Update(); // clear stats
|
|
||||||
}
|
|
||||||
} // namespace PD
|
|
||||||
#endif
|
|
||||||
@@ -65,7 +65,7 @@ HidGlfw::HidGlfw(GLFWwindow* win) : HidDriver("HidGlfw") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HidGlfw::~HidGlfw() { delete impl; }
|
HidGlfw::~HidGlfw() {}
|
||||||
|
|
||||||
void HidGlfw::Update() {
|
void HidGlfw::Update() {
|
||||||
HidDriver::Update(); // clear stats
|
HidDriver::Update(); // clear stats
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ struct HidNX::Impl {
|
|||||||
|
|
||||||
HidNX::HidNX() : HidDriver("HidNX") { impl = new Impl; }
|
HidNX::HidNX() : HidDriver("HidNX") { impl = new Impl; }
|
||||||
|
|
||||||
HidNX::~HidNX() { delete impl; }
|
HidNX::~HidNX() {}
|
||||||
|
|
||||||
void HidNX::Update() {
|
void HidNX::Update() {
|
||||||
HidDriver::Update(); // clear stats
|
HidDriver::Update(); // clear stats
|
||||||
|
|||||||
+12
-50
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
#include <pd/core/mat.hpp>
|
#include <pd/core/mat.hpp>
|
||||||
#include <pd/drivers/interface.hpp>
|
#include <pd/drivers/interface.hpp>
|
||||||
#include <pd/lithium/drawlist.hpp>
|
#include <pd/lithium/command.hpp>
|
||||||
#include <pd/lithium/pools.hpp>
|
|
||||||
#include <pd/lithium/texture.hpp>
|
#include <pd/lithium/texture.hpp>
|
||||||
|
|
||||||
using PDGfxBackendFlags = PD::u32;
|
using PDGfxBackendFlags = PD::u32;
|
||||||
@@ -38,7 +37,7 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
return Li::Texture();
|
return Li::Texture();
|
||||||
}
|
}
|
||||||
virtual void DeleteTexture(const Li::Texture& tex) {}
|
virtual void DeleteTexture(const Li::Texture& tex) {}
|
||||||
virtual void Draw(const Li::Drawlist& commands) {}
|
virtual void Draw(const Pool<Li::Command>& commands) {}
|
||||||
Li::Texture::Ptr GetWhiteTexture() { return &pWhite; }
|
Li::Texture::Ptr GetWhiteTexture() { return &pWhite; }
|
||||||
PDGfxBackendFlags GetFlags() { return Flags; }
|
PDGfxBackendFlags GetFlags() { return Flags; }
|
||||||
|
|
||||||
@@ -111,67 +110,28 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
pWhite = LoadTexture(img, 16, 16);
|
pWhite = LoadTexture(img, 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(const Li::Drawlist& dl) override {
|
void Draw(const Pool<Li::Command>& commands) override {
|
||||||
const auto& commands = dl.Data();
|
|
||||||
if (commands.size() == 0) return;
|
|
||||||
pCountCommands += commands.size();
|
pCountCommands += commands.size();
|
||||||
|
|
||||||
size_t vtotal = dl.GetNumVertices();
|
|
||||||
size_t itotal = dl.GetNumIndices();
|
|
||||||
|
|
||||||
size_t start_vtx = pVtxPool.size();
|
|
||||||
pVtxPool.Allocate(vtotal);
|
|
||||||
CurrentVertex += vtotal;
|
|
||||||
|
|
||||||
size_t start_idx = pIdxPool.size();
|
|
||||||
pIdxPool.Allocate(itotal);
|
|
||||||
CurrentIndex += itotal;
|
|
||||||
|
|
||||||
size_t current_vtx = start_vtx;
|
|
||||||
size_t current_idx = start_idx;
|
|
||||||
|
|
||||||
const auto& vpool = Li::GetVertexPool();
|
|
||||||
const auto& ipool = Li::GetIndexPool();
|
|
||||||
/** Build Pools */
|
|
||||||
for (size_t i = 0; i < commands.size(); i++) {
|
|
||||||
const auto& cmd = commands[i];
|
|
||||||
if (cmd.VertexCount > 0) {
|
|
||||||
std::memcpy(pVtxPool.begin() + current_vtx,
|
|
||||||
vpool.begin() + cmd.FirstVertex,
|
|
||||||
cmd.VertexCount * sizeof(Li::Vertex));
|
|
||||||
}
|
|
||||||
for (size_t idx = 0; idx < cmd.IndexCount; idx++) {
|
|
||||||
u16 local_idx = ipool[cmd.FirstIndex + idx];
|
|
||||||
pIdxPool[current_idx + idx] = static_cast<u16>(current_vtx + local_idx);
|
|
||||||
}
|
|
||||||
current_vtx += cmd.VertexCount;
|
|
||||||
current_idx += cmd.IndexCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
UploadPools();
|
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
size_t ioff = start_idx;
|
UploadPools();
|
||||||
|
|
||||||
while (index < commands.size()) {
|
while (index < commands.size()) {
|
||||||
CurrentTex = commands[index].Tex;
|
CurrentTex = commands[index].Tex;
|
||||||
CurrentTexIsSDF = commands[index].SDF;
|
CurrentTexIsSDF = commands[index].SDF;
|
||||||
if (!CurrentTex) {
|
if (!CurrentTex) {
|
||||||
CurrentTex = pWhite.GetID();
|
CurrentTex = pWhite.GetID();
|
||||||
}
|
}
|
||||||
|
size_t startidx = commands[index].FirstIndex;
|
||||||
size_t num_indices = 0;
|
size_t num_indices = 0;
|
||||||
while (index < commands.size() &&
|
while (index < commands.size() &&
|
||||||
CurrentTexIsSDF == commands[index].SDF &&
|
CurrentTexIsSDF == commands[index].SDF &&
|
||||||
(CurrentTex == commands[index].Tex ||
|
(CurrentTex == commands[index].Tex ||
|
||||||
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0))) {
|
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0)) &&
|
||||||
|
commands[index].FirstIndex == startidx + num_indices) {
|
||||||
num_indices += commands[index].IndexCount;
|
num_indices += commands[index].IndexCount;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (num_indices > 0) {
|
Submit(num_indices, startidx);
|
||||||
Submit(num_indices, ioff);
|
pCountDrawcalls++;
|
||||||
ioff += num_indices;
|
|
||||||
pCountDrawcalls++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +211,9 @@ class PD_API Gfx {
|
|||||||
static void SetViewPort(const ivec2& vp) { driver->SetViewPort(vp); }
|
static void SetViewPort(const ivec2& vp) { driver->SetViewPort(vp); }
|
||||||
static void SetViewPort(int w, int h) { driver->SetViewPort(w, h); }
|
static void SetViewPort(int w, int h) { driver->SetViewPort(w, h); }
|
||||||
static void Reset() { driver->Reset(); }
|
static void Reset() { driver->Reset(); }
|
||||||
static void Draw(const Li::Drawlist& dl) { driver->Draw(dl); }
|
static void Draw(const Pool<Li::Command>& commands) {
|
||||||
|
driver->Draw(commands);
|
||||||
|
}
|
||||||
static Li::Texture LoadTexture(const std::vector<PD::u8>& pixels, int w,
|
static Li::Texture LoadTexture(const std::vector<PD::u8>& pixels, int w,
|
||||||
int h,
|
int h,
|
||||||
TextureFormat type = TextureFormat::RGBA32,
|
TextureFormat type = TextureFormat::RGBA32,
|
||||||
|
|||||||
@@ -42,10 +42,6 @@ class PD_API Drawlist {
|
|||||||
void Copy(Drawlist& other);
|
void Copy(Drawlist& other);
|
||||||
void Optimize();
|
void Optimize();
|
||||||
void Clear();
|
void Clear();
|
||||||
void SetLayer(int layer) { pCurrentLayer = layer; }
|
|
||||||
void LayerUp() { pCurrentLayer++; }
|
|
||||||
void LayerDown() { pCurrentLayer--; }
|
|
||||||
int GetLayer() const { return pCurrentLayer; }
|
|
||||||
|
|
||||||
size_t GetNumVertices() const {
|
size_t GetNumVertices() const {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
@@ -130,7 +126,6 @@ class PD_API Drawlist {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Texture pCurrentTexture;
|
Texture pCurrentTexture;
|
||||||
int pCurrentLayer = 0;
|
|
||||||
Pool<Command> pCommands;
|
Pool<Command> pCommands;
|
||||||
Pool<fvec2> pPath;
|
Pool<fvec2> pPath;
|
||||||
Pool<Vertex> pVertices;
|
Pool<Vertex> pVertices;
|
||||||
|
|||||||
@@ -4,5 +4,4 @@
|
|||||||
#include <pd/lithium/drawlist.hpp>
|
#include <pd/lithium/drawlist.hpp>
|
||||||
#include <pd/lithium/font.hpp>
|
#include <pd/lithium/font.hpp>
|
||||||
#include <pd/lithium/math.hpp>
|
#include <pd/lithium/math.hpp>
|
||||||
#include <pd/lithium/pools.hpp>
|
#include <pd/lithium/vertex.hpp>
|
||||||
#include <pd/lithium/vertex.hpp>
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
|
||||||
#include <pd/lithium/vertex.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
|
||||||
namespace Li {
|
|
||||||
PD_API PD::Pool<Vertex>& GetVertexPool();
|
|
||||||
PD_API PD::Pool<u16>& GetIndexPool();
|
|
||||||
PD_API void ResetPools();
|
|
||||||
} // namespace Li
|
|
||||||
} // namespace PD
|
|
||||||
@@ -1,201 +1,198 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MIT License
|
MIT License
|
||||||
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
Copyright (c) 2024 - 2026 René Amthor (tobid7)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pd/core/core.hpp>
|
#include <pd/core/core.hpp>
|
||||||
#include <pd/pd_p_api.hpp>
|
#include <pd/pd_p_api.hpp>
|
||||||
#include <pd/ui7/io.hpp>
|
#include <pd/ui7/io.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
/**
|
/**
|
||||||
* Container base class all Objects are based on
|
* Container base class all Objects are based on
|
||||||
* @note this class can be used to create custom Objects as well
|
* @note this class can be used to create custom Objects as well
|
||||||
*/
|
*/
|
||||||
class PD_API Container {
|
class PD_API Container {
|
||||||
public:
|
public:
|
||||||
Container() = default;
|
Container() = default;
|
||||||
/**
|
/**
|
||||||
* Constructor with pos and Size
|
* Constructor with pos and Size
|
||||||
* @param pos Container Position
|
* @param pos Container Position
|
||||||
* @param size Container Size
|
* @param size Container Size
|
||||||
*/
|
*/
|
||||||
Container(const fvec2& pos, const fvec2& size) : pos(pos), size(size) {}
|
Container(const fvec2& pos, const fvec2& size) : pos(pos), size(size) {}
|
||||||
/**
|
/**
|
||||||
* Constructor by a vec4 box
|
* Constructor by a vec4 box
|
||||||
* @param box Box containing top left and bottom right coords
|
* @param box Box containing top left and bottom right coords
|
||||||
*/
|
*/
|
||||||
Container(const fvec4& box)
|
Container(const fvec4& box)
|
||||||
: pos(fvec2(box.x, box.y)), size(fvec2(box.z - box.x, box.w - box.y)) {}
|
: pos(fvec2(box.x, box.y)), size(fvec2(box.z - box.x, box.w - box.y)) {}
|
||||||
~Container() = default;
|
~Container() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init Function Required by every Object that uses
|
* Init Function Required by every Object that uses
|
||||||
* Render or Input functions
|
* Render or Input functions
|
||||||
* @param io IO Reference
|
* @param io IO Reference
|
||||||
* @param l Drawlist Reference
|
* @param l Drawlist Reference
|
||||||
*/
|
*/
|
||||||
void Init(UI7::IO* io, Li::Drawlist* l) {
|
void Init(UI7::IO* io, Li::Drawlist* l) {
|
||||||
list = l;
|
list = l;
|
||||||
this->io = io;
|
this->io = io;
|
||||||
pFont = io->Font;
|
// this->screen = io->Ren->CurrentScreen();
|
||||||
// this->screen = io->Ren->CurrentScreen();
|
}
|
||||||
}
|
|
||||||
|
void SetClipRect(fvec4 clip) {
|
||||||
void SetClipRect(fvec4 clip) {
|
pClipRect = clip;
|
||||||
pClipRect = clip;
|
pCLipRectUsed = true;
|
||||||
pCLipRectUsed = true;
|
}
|
||||||
}
|
|
||||||
|
/** Setter for Position */
|
||||||
/** Setter for Position */
|
void SetPos(const fvec2& pos) { this->pos = pos; }
|
||||||
void SetPos(const fvec2& pos) { this->pos = pos; }
|
/** Setter for Size */
|
||||||
/** Setter for Size */
|
void SetSize(const fvec2& size) { this->size = size; }
|
||||||
void SetSize(const fvec2& size) { this->size = size; }
|
/** Getter for Position */
|
||||||
/** Getter for Position */
|
fvec2 GetPos() { return pos; }
|
||||||
fvec2 GetPos() { return pos; }
|
/** Getter for Size */
|
||||||
/** Getter for Size */
|
fvec2 GetSize() { return size; }
|
||||||
fvec2 GetSize() { return size; }
|
/**
|
||||||
Li::Font* GetFont() { return pFont; }
|
* Get the Containers Final Position
|
||||||
/**
|
* for Rendering and Input (if it has a parent Object)
|
||||||
* Get the Containers Final Position
|
*/
|
||||||
* for Rendering and Input (if it has a parent Object)
|
fvec2 FinalPos() {
|
||||||
*/
|
vec2 res = pos;
|
||||||
fvec2 FinalPos() {
|
if (parent) {
|
||||||
vec2 res = pos;
|
/// Probably should use parant->FinalPos here
|
||||||
if (parent) {
|
res += parent->GetPos();
|
||||||
/// Probably should use parant->FinalPos here
|
}
|
||||||
res += parent->GetPos();
|
return res;
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
/** Setter for Parent Container */
|
||||||
|
void SetParent(Container* v) { parent = v; }
|
||||||
/** Setter for Parent Container */
|
/** Getter for Parent Container */
|
||||||
void SetParent(Container* v) { parent = v; }
|
Container* GetParent() { return parent; }
|
||||||
/** Getter for Parent Container */
|
|
||||||
Container* GetParent() { return parent; }
|
/** Check if Rendering can be skipped */
|
||||||
|
bool Skippable() const { return skippable; }
|
||||||
/** Check if Rendering can be skipped */
|
/** Check if the Object got a timeout (ID OBJ Relevant) */
|
||||||
bool Skippable() const { return skippable; }
|
bool Removable() const { return rem; }
|
||||||
/** Check if the Object got a timeout (ID OBJ Relevant) */
|
|
||||||
bool Removable() const { return rem; }
|
/**
|
||||||
|
* Handles Scrolling by scrolling pos as well as
|
||||||
/**
|
* Time for Remove for ID Objects
|
||||||
* Handles Scrolling by scrolling pos as well as
|
* @param scrolling Scrolling Position
|
||||||
* Time for Remove for ID Objects
|
* @param viewport Viewport to check if the Object is skippable
|
||||||
* @param scrolling Scrolling Position
|
*/
|
||||||
* @param viewport Viewport to check if the Object is skippable
|
void HandleScrolling(fvec2 scrolling, fvec4 viewport);
|
||||||
*/
|
/** Template function for Input Handling */
|
||||||
void HandleScrolling(fvec2 scrolling, fvec4 viewport);
|
virtual void HandleInput() {}
|
||||||
/** Template function for Input Handling */
|
/** Tamplate function for Object rendering */
|
||||||
virtual void HandleInput() {}
|
virtual void Draw() {}
|
||||||
/** Tamplate function for Object rendering */
|
/** Template function to update internal data (if needed) */
|
||||||
virtual void Draw() {}
|
virtual void Update() {}
|
||||||
/** Template function to update internal data (if needed) */
|
/** Template as well as base func for Pool based Containers */
|
||||||
virtual void Update() {}
|
virtual void Reset() {
|
||||||
/** Template as well as base func for Pool based Containers */
|
pos = 0;
|
||||||
virtual void Reset() {
|
size = 0;
|
||||||
pos = 0;
|
parent = nullptr;
|
||||||
size = 0;
|
id = 0;
|
||||||
parent = nullptr;
|
pFlags = 0;
|
||||||
id = 0;
|
skippable = false;
|
||||||
pFlags = 0;
|
rem = false;
|
||||||
skippable = false;
|
inp_done = false;
|
||||||
rem = false;
|
pSelected = false;
|
||||||
inp_done = false;
|
pPressed = false;
|
||||||
pSelected = false;
|
pPressedTwice = false;
|
||||||
pPressed = false;
|
pCLipRectUsed = false;
|
||||||
pPressedTwice = false;
|
pClipRect = 0;
|
||||||
pCLipRectUsed = false;
|
io = nullptr;
|
||||||
pClipRect = 0;
|
list = nullptr;
|
||||||
io = nullptr;
|
last_use = 0;
|
||||||
list = nullptr;
|
}
|
||||||
last_use = 0;
|
|
||||||
}
|
/** Internal function */
|
||||||
|
void PreDraw();
|
||||||
/** Internal function */
|
/** Internal function */
|
||||||
void PreDraw();
|
void PostDraw();
|
||||||
/** Internal function */
|
|
||||||
void PostDraw();
|
/** Internal Input Handler */
|
||||||
|
void HandleInternalInput();
|
||||||
/** Internal Input Handler */
|
|
||||||
void HandleInternalInput();
|
/**
|
||||||
|
* Function to unlock Input after Rendering is done in
|
||||||
/**
|
* Menu::Update
|
||||||
* Function to unlock Input after Rendering is done in
|
* @note This is used if the Object got Input Handled directly after creation
|
||||||
* Menu::Update
|
* to not check for Inputs twice
|
||||||
* @note This is used if the Object got Input Handled directly after creation
|
*/
|
||||||
* to not check for Inputs twice
|
void UnlockInput() { inp_done = false; }
|
||||||
*/
|
|
||||||
void UnlockInput() { inp_done = false; }
|
/** Get the Objects ID (if it is an ID object)*/
|
||||||
|
u32 GetID() const { return id; }
|
||||||
/** Get the Objects ID (if it is an ID object)*/
|
/**
|
||||||
u32 GetID() const { return id; }
|
* Set ID for ID Objects
|
||||||
/**
|
* @param id Object ID (hashed prefix+objname+prefixed_counter)
|
||||||
* Set ID for ID Objects
|
*/
|
||||||
* @param id Object ID (hashed prefix+objname+prefixed_counter)
|
void SetID(u32 id) { this->id = id; }
|
||||||
*/
|
|
||||||
void SetID(u32 id) { this->id = id; }
|
/** Get a reference to IO */
|
||||||
|
UI7::IO* GetIO() { return io; }
|
||||||
/** Get a reference to IO */
|
|
||||||
UI7::IO* GetIO() { return io; }
|
protected:
|
||||||
|
/** used to skip Input/Render preocessing ot not*/
|
||||||
protected:
|
bool skippable = false;
|
||||||
/** used to skip Input/Render preocessing ot not*/
|
/** value to check if an ID Object goes out of lifetime*/
|
||||||
bool skippable = false;
|
bool rem = false;
|
||||||
/** value to check if an ID Object goes out of lifetime*/
|
/** Time of the last use (set by HandleScrolling)*/
|
||||||
bool rem = false;
|
u64 last_use = 0;
|
||||||
/** Time of the last use (set by HandleScrolling)*/
|
/** Input done or not for current frame*/
|
||||||
u64 last_use = 0;
|
bool inp_done = false;
|
||||||
/** Input done or not for current frame*/
|
/** Reference to the Screen to draw the Object on*/
|
||||||
bool inp_done = false;
|
// Screen::Ref screen;
|
||||||
/** Reference to the Screen to draw the Object on*/
|
/** Container Position*/
|
||||||
// Screen::Ref screen;
|
fvec2 pos;
|
||||||
/** Container Position*/
|
/** Container Size*/
|
||||||
fvec2 pos;
|
fvec2 size;
|
||||||
/** Container Size*/
|
/** Reference to the Drawlist to Draw to*/
|
||||||
fvec2 size;
|
Li::Drawlist* list = nullptr;
|
||||||
/** Reference to the Drawlist to Draw to*/
|
/** IO Reference for Renderer and Theme */
|
||||||
Li::Drawlist* list = nullptr;
|
UI7::IO* io = nullptr;
|
||||||
/** IO Reference for Renderer and Theme */
|
/** Reference to the parent container*/
|
||||||
UI7::IO* io = nullptr;
|
Container* parent = nullptr;
|
||||||
/** Reference to the parent container*/
|
/** Object ID (0 if unused)*/
|
||||||
Container* parent = nullptr;
|
u32 id = 0;
|
||||||
/** Object ID (0 if unused)*/
|
/** Internal Flags */
|
||||||
u32 id = 0;
|
u32 pFlags = 0;
|
||||||
/** Internal Flags */
|
/** Is Selected? */
|
||||||
u32 pFlags = 0;
|
bool pSelected = false;
|
||||||
/** Is Selected? */
|
/** Was Pressed */
|
||||||
bool pSelected = false;
|
bool pPressed = false;
|
||||||
/** Was Pressed */
|
/** Was Pressed Twice */
|
||||||
bool pPressed = false;
|
bool pPressedTwice = false;
|
||||||
/** Was Pressed Twice */
|
/** ClipRect */
|
||||||
bool pPressedTwice = false;
|
fvec4 pClipRect;
|
||||||
/** ClipRect */
|
/** Clip Rect used */
|
||||||
fvec4 pClipRect;
|
bool pCLipRectUsed = false;
|
||||||
/** Clip Rect used */
|
};
|
||||||
bool pCLipRectUsed = false;
|
} // namespace UI7
|
||||||
Li::Font* pFont = nullptr;
|
} // namespace PD
|
||||||
};
|
|
||||||
} // namespace UI7
|
|
||||||
} // namespace PD
|
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ enum UI7MenuFlags_ {
|
|||||||
enum UI7LayoutFlags_ {
|
enum UI7LayoutFlags_ {
|
||||||
UI7LayoutFlags_None = 0, ///< No Flags used
|
UI7LayoutFlags_None = 0, ///< No Flags used
|
||||||
UI7LayoutFlags_UseClipRect = 1 << 0, ///< Enable ClipRect
|
UI7LayoutFlags_UseClipRect = 1 << 0, ///< Enable ClipRect
|
||||||
UI7LayoutFlags_HzScrolling = 1 << 1, ///< Scrolling Horizontal
|
|
||||||
UI7LayoutFlags_VtScrolling = 1 << 2, ///< Scrolling Vertical
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** UI7 Context Flags */
|
/** UI7 Context Flags */
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ class PD_API IO {
|
|||||||
u32 NumVertices = 0; ///< Debug Vertices Num
|
u32 NumVertices = 0; ///< Debug Vertices Num
|
||||||
u32 NumIndices = 0; ///< Debug Indices Num
|
u32 NumIndices = 0; ///< Debug Indices Num
|
||||||
std::vector<u32> MenuOrder;
|
std::vector<u32> MenuOrder;
|
||||||
std::vector<Li::Font*> FontStack;
|
|
||||||
|
|
||||||
// Pools
|
// Pools
|
||||||
PD::Pool<UI7::Label> LabelPool;
|
PD::Pool<UI7::Label> LabelPool;
|
||||||
@@ -108,18 +107,6 @@ class PD_API IO {
|
|||||||
return ViewPorts[id.RawID()];
|
return ViewPorts[id.RawID()];
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushFont(Li::Font* f) {
|
|
||||||
FontStack.push_back(Font);
|
|
||||||
Font = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopFont() {
|
|
||||||
if (!FontStack.empty()) {
|
|
||||||
Font = FontStack.back();
|
|
||||||
FontStack.pop_back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UI7::InputHandler InputHandler;
|
UI7::InputHandler InputHandler;
|
||||||
};
|
};
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
|
|||||||
@@ -127,8 +127,6 @@ class PD_API Layout {
|
|||||||
void CursorInit();
|
void CursorInit();
|
||||||
void SameLine();
|
void SameLine();
|
||||||
void CursorMove(const fvec2& size);
|
void CursorMove(const fvec2& size);
|
||||||
void PushFont(Li::Font* f) { IO.PushFont(f); }
|
|
||||||
void PopFont() { IO.PopFont(); }
|
|
||||||
|
|
||||||
bool ObjectWorkPos(fvec2& movpos);
|
bool ObjectWorkPos(fvec2& movpos);
|
||||||
|
|
||||||
@@ -165,8 +163,6 @@ class PD_API Layout {
|
|||||||
void SetAlign(UI7Align a) { Alignment = a; }
|
void SetAlign(UI7Align a) { Alignment = a; }
|
||||||
void NextAlign(UI7Align a) { TempAlign = a; }
|
void NextAlign(UI7Align a) { TempAlign = a; }
|
||||||
|
|
||||||
void HandleScrolling();
|
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
fvec2 DbgScrollOffset() { return ScrollOffset; }
|
fvec2 DbgScrollOffset() { return ScrollOffset; }
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ class PD_API Menu {
|
|||||||
void EndTreeNode();
|
void EndTreeNode();
|
||||||
|
|
||||||
void HandleFocus();
|
void HandleFocus();
|
||||||
|
void HandleScrolling();
|
||||||
void HandleTitlebarActions();
|
void HandleTitlebarActions();
|
||||||
void DrawBaseLayout();
|
void DrawBaseLayout();
|
||||||
|
|
||||||
@@ -119,9 +120,6 @@ class PD_API Menu {
|
|||||||
}
|
}
|
||||||
Container* FindObject(u32 id) { return pLayout.FindObject(id); }
|
Container* FindObject(u32 id) { return pLayout.FindObject(id); }
|
||||||
|
|
||||||
void PushFont(Li::Font* f) { pIO.PushFont(f); }
|
|
||||||
void PopFont() { pIO.PopFont(); }
|
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void SetSize(PD::fvec2 size) { pLayout.SetSize(size); }
|
void SetSize(PD::fvec2 size) { pLayout.SetSize(size); }
|
||||||
|
|||||||
+14
-42
@@ -1,48 +1,23 @@
|
|||||||
#include <pd/drivers/gfx.hpp>
|
#include <pd/drivers/gfx.hpp>
|
||||||
#include <pd/lithium/command.hpp>
|
#include <pd/lithium/command.hpp>
|
||||||
#include <pd/lithium/pools.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Li {
|
namespace Li {
|
||||||
|
|
||||||
void Command::Reserve(size_t vtx, size_t idx) {
|
void Command::Reserve(size_t vtx, size_t idx) {
|
||||||
auto& vpool = GetVertexPool();
|
|
||||||
auto& ipool = GetIndexPool();
|
|
||||||
if (VertexCountMax == 0) {
|
if (VertexCountMax == 0) {
|
||||||
FirstVertex = vpool.size();
|
FirstVertex = Gfx::AllocateVertices(vtx, (PD::ptr)this);
|
||||||
vpool.Allocate(vtx);
|
|
||||||
VertexCountMax = vtx;
|
VertexCountMax = vtx;
|
||||||
} else {
|
} else {
|
||||||
if (vpool.size() == FirstVertex + VertexCountMax) {
|
Gfx::ExpandVertices(vtx, (PD::ptr)this);
|
||||||
vpool.Allocate(vtx);
|
VertexCountMax += vtx;
|
||||||
VertexCountMax += vtx;
|
|
||||||
} else {
|
|
||||||
size_t tmp = FirstVertex;
|
|
||||||
FirstVertex = vpool.size();
|
|
||||||
vpool.Allocate(VertexCountMax + vtx);
|
|
||||||
for (size_t i = 0; i < VertexCount; i++) {
|
|
||||||
vpool[FirstVertex + i] = vpool[tmp + i];
|
|
||||||
}
|
|
||||||
VertexCountMax += vtx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (IndexCountMax == 0) {
|
if (IndexCountMax == 0) {
|
||||||
FirstIndex = ipool.size();
|
FirstIndex = Gfx::AllocateIndices(idx, (PD::ptr)this);
|
||||||
ipool.Allocate(idx);
|
|
||||||
IndexCountMax = idx;
|
IndexCountMax = idx;
|
||||||
} else {
|
} else {
|
||||||
if (ipool.size() == FirstIndex + IndexCountMax) {
|
Gfx::ExpandIndices(idx, (PD::ptr)this);
|
||||||
ipool.Allocate(idx);
|
IndexCountMax += idx;
|
||||||
IndexCountMax += idx;
|
|
||||||
} else {
|
|
||||||
size_t tmp = FirstIndex;
|
|
||||||
FirstIndex = ipool.size();
|
|
||||||
ipool.Allocate(IndexCountMax + idx);
|
|
||||||
for (size_t i = 0; i < IndexCount; i++) {
|
|
||||||
ipool[FirstIndex + i] = ipool[tmp + i];
|
|
||||||
}
|
|
||||||
IndexCountMax += idx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,25 +34,22 @@ void Command::Reset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Command& Command::Add(const Vertex& vtx) {
|
Command& Command::Add(const Vertex& vtx) {
|
||||||
if (VertexCount < VertexCountMax) {
|
if (VertexCount <= VertexCountMax)
|
||||||
GetVertexPool()[FirstVertex + VertexCount++] = vtx;
|
Gfx::PutVertex(FirstVertex + VertexCount++, vtx, (PD::ptr)this);
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Command& Command::Add(u16 idx) {
|
Command& Command::Add(u16 idx) {
|
||||||
if (IndexCount < IndexCountMax) {
|
if (IndexCount <= IndexCountMax)
|
||||||
GetIndexPool()[FirstIndex + IndexCount++] =
|
Gfx::PutIndex(FirstIndex + IndexCount++, FirstVertex + VertexCount + idx,
|
||||||
static_cast<u16>(VertexCount + idx);
|
(PD::ptr)this);
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Command& Command::Add(u16 a, u16 b, u16 c) {
|
Command& Command::Add(u16 a, u16 b, u16 c) {
|
||||||
if (IndexCount + 3 <= IndexCountMax) {
|
if (IndexCount + 3 <= IndexCountMax) {
|
||||||
auto& ip = GetIndexPool();
|
|
||||||
size_t idx = FirstIndex + IndexCount;
|
size_t idx = FirstIndex + IndexCount;
|
||||||
ip[idx + 0] = static_cast<u16>(VertexCount + a);
|
Gfx::PutIndex(idx + 0, FirstVertex + VertexCount + a, (PD::ptr)this);
|
||||||
ip[idx + 1] = static_cast<u16>(VertexCount + b);
|
Gfx::PutIndex(idx + 1, FirstVertex + VertexCount + b, (PD::ptr)this);
|
||||||
ip[idx + 2] = static_cast<u16>(VertexCount + c);
|
Gfx::PutIndex(idx + 2, FirstVertex + VertexCount + c, (PD::ptr)this);
|
||||||
IndexCount += 3;
|
IndexCount += 3;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <pd/drivers/gfx.hpp>
|
#include <pd/drivers/gfx.hpp>
|
||||||
#include <pd/lithium/drawlist.hpp>
|
#include <pd/lithium/drawlist.hpp>
|
||||||
@@ -12,44 +11,27 @@ PD_API Drawlist::Drawlist() { Clear(); }
|
|||||||
PD_API Drawlist::~Drawlist() { Clear(); }
|
PD_API Drawlist::~Drawlist() { Clear(); }
|
||||||
|
|
||||||
PD_API void Drawlist::Merge(Drawlist& other) {
|
PD_API void Drawlist::Merge(Drawlist& other) {
|
||||||
size_t start = pCommands.size();
|
|
||||||
pCommands.AppendMove(other.pCommands);
|
pCommands.AppendMove(other.pCommands);
|
||||||
for (size_t i = start; i < pCommands.size(); i++) {
|
|
||||||
pCommands[i].Layer += this->pCurrentLayer;
|
|
||||||
}
|
|
||||||
other.Clear();
|
other.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_API void Drawlist::Copy(Drawlist& other) {
|
PD_API void Drawlist::Copy(Drawlist& other) {
|
||||||
int start = pCommands.size();
|
|
||||||
pCommands.AppendCopy(other.pCommands);
|
pCommands.AppendCopy(other.pCommands);
|
||||||
for (size_t i = start; i < pCommands.size(); i++) {
|
|
||||||
pCommands[i].Layer += this->pCurrentLayer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_API void Drawlist::Optimize() {
|
PD_API void Drawlist::Optimize() {}
|
||||||
if (pCommands.size() <= 1) return;
|
|
||||||
std::stable_sort(pCommands.begin(), pCommands.end(),
|
|
||||||
[](const Command& a, const Command& b) {
|
|
||||||
if (a.Layer != b.Layer) return a.Layer < b.Layer;
|
|
||||||
if (a.SDF != b.SDF) return a.SDF < b.SDF;
|
|
||||||
return a.Tex < b.Tex;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
PD_API void Drawlist::Clear() {
|
PD_API void Drawlist::Clear() {
|
||||||
UnbindTexture();
|
UnbindTexture();
|
||||||
pPath.ResetFast();
|
pPath.ResetFast();
|
||||||
pCommands.NoReset();
|
pVertices.ResetFast();
|
||||||
pCurrentLayer = 0;
|
pIndices.ResetFast();
|
||||||
|
pCommands.ResetFast();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Command Allocation */
|
/** Command Allocation */
|
||||||
PD_API Command& Drawlist::NewCommand() {
|
PD_API Command& Drawlist::NewCommand() {
|
||||||
auto cmd = pCommands.Allocate(1);
|
auto cmd = pCommands.Allocate(1);
|
||||||
cmd->Reset();
|
|
||||||
cmd->Layer = pCurrentLayer;
|
|
||||||
cmd->Tex = pCurrentTexture.GetID();
|
cmd->Tex = pCurrentTexture.GetID();
|
||||||
return *cmd;
|
return *cmd;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,8 +288,7 @@ PD_API void Font::CmdTextEx(Drawlist& dl, const fvec2& pos, u32 color,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cp.Size.x > 0 && cp.Size.y > 0) {
|
if (cp.Size.x > 0 && cp.Size.y > 0) {
|
||||||
if (cmd == nullptr || cmd->Tex != Textures[cp.Tex] ||
|
if (cmd == nullptr || cmd->Tex != Textures[cp.Tex]) {
|
||||||
cmd->Layer != dl.GetLayer()) {
|
|
||||||
if (cp.Tex >= Textures.size()) continue;
|
if (cp.Tex >= Textures.size()) continue;
|
||||||
cmd = &dl.NewCommand();
|
cmd = &dl.NewCommand();
|
||||||
cmd->Tex = Textures[cp.Tex];
|
cmd->Tex = Textures[cp.Tex];
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
#include <pd/lithium/pools.hpp>
|
|
||||||
|
|
||||||
namespace PD {
|
|
||||||
namespace Li {
|
|
||||||
static PD::Pool<Vertex> gVertexPool;
|
|
||||||
static PD::Pool<u16> gIndexPool;
|
|
||||||
|
|
||||||
PD_API PD::Pool<Vertex>& GetVertexPool() { return gVertexPool; }
|
|
||||||
PD_API PD::Pool<u16>& GetIndexPool() { return gIndexPool; }
|
|
||||||
|
|
||||||
PD_API void ResetPools() {
|
|
||||||
gVertexPool.NoReset();
|
|
||||||
gIndexPool.NoReset();
|
|
||||||
}
|
|
||||||
} // namespace Li
|
|
||||||
} // namespace PD
|
|
||||||
@@ -49,13 +49,12 @@ PD_API void Button::HandleInput() {
|
|||||||
PD_API void Button::Draw() {
|
PD_API void Button::Draw() {
|
||||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->SetFont(GetFont());
|
|
||||||
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
|
list->PathRect(FinalPos(), FinalPos() + size, io->FrameRounding);
|
||||||
list->PathFill(io->Theme.Get(color));
|
list->PathFill(io->Theme.Get(color));
|
||||||
list->LayerUp();
|
// list->LayerUp();
|
||||||
list->DrawText(FinalPos() + size * 0.5 - tdim * 0.5, label.c_str(),
|
list->DrawText(FinalPos() + size * 0.5 - tdim * 0.5, label.c_str(),
|
||||||
io->Theme.Get(UI7Color_Text));
|
io->Theme.Get(UI7Color_Text));
|
||||||
list->LayerDown();
|
// list->LayerDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_API void Button::Update() {
|
PD_API void Button::Update() {
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ PD_API void Checkbox::HandleInput() {
|
|||||||
PD_API void Checkbox::Draw() {
|
PD_API void Checkbox::Draw() {
|
||||||
// Assert(list.get() && io.get(), "Did you run Container::Init correctly?");
|
// Assert(list.get() && io.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->SetFont(GetFont());
|
|
||||||
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
|
list->PathRect(FinalPos(), FinalPos() + cbs, io->FrameRounding);
|
||||||
list->PathFill(io->Theme.Get(color));
|
list->PathFill(io->Theme.Get(color));
|
||||||
if (usr_ref) {
|
if (usr_ref) {
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ PD_API void ColorEdit::HandleInput() {
|
|||||||
PD_API void ColorEdit::Draw() {
|
PD_API void ColorEdit::Draw() {
|
||||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->SetFont(GetFont());
|
|
||||||
list->PathRect(FinalPos(), FinalPos() + io->ItemRowHeight, io->FrameRounding);
|
list->PathRect(FinalPos(), FinalPos() + io->ItemRowHeight, io->FrameRounding);
|
||||||
list->PathFill(*color_ref);
|
list->PathFill(*color_ref);
|
||||||
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + io->ItemRowHeight, 0),
|
list->DrawText(FinalPos() + fvec2(io->ItemSpace.x + io->ItemRowHeight, 0),
|
||||||
@@ -56,19 +55,16 @@ PD_API void ColorEdit::Draw() {
|
|||||||
layout->SetPosition(FinalPos());
|
layout->SetPosition(FinalPos());
|
||||||
DynObj* r = io->DynObjPool.Allocate();
|
DynObj* r = io->DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l, Container* thiz) {
|
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l, Container* thiz) {
|
||||||
list->SetFont(thiz->GetFont());
|
|
||||||
thiz->SetSize(layout->GetSize());
|
thiz->SetSize(layout->GetSize());
|
||||||
// l->Layer(30);
|
// l->Layer(30);
|
||||||
l->PathRect(thiz->GetPos(), thiz->GetPos() + thiz->GetSize(),
|
l->PathRect(thiz->GetPos(), thiz->GetPos() + thiz->GetSize(),
|
||||||
io->FrameRounding);
|
io->FrameRounding);
|
||||||
l->PathFill(io->Theme.Get(UI7Color_FrameBackground));
|
l->PathFill(io->Theme.Get(UI7Color_FrameBackground));
|
||||||
l->SetLayer(0);
|
|
||||||
});
|
});
|
||||||
layout->AddObjectEx(r, UI7LytAdd_Front | UI7LytAdd_NoCursorUpdate |
|
layout->AddObjectEx(r, UI7LytAdd_Front | UI7LytAdd_NoCursorUpdate |
|
||||||
UI7LytAdd_NoScrollHandle);
|
UI7LytAdd_NoScrollHandle);
|
||||||
r = io->DynObjPool.Allocate();
|
r = io->DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l, Container* thiz) {
|
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l, Container* thiz) {
|
||||||
list->SetFont(thiz->GetFont());
|
|
||||||
l->PathRect(thiz->FinalPos(), thiz->FinalPos() + io->ItemRowHeight,
|
l->PathRect(thiz->FinalPos(), thiz->FinalPos() + io->ItemRowHeight,
|
||||||
io->FrameRounding);
|
io->FrameRounding);
|
||||||
l->PathFill(*color_ref);
|
l->PathFill(*color_ref);
|
||||||
@@ -88,9 +84,7 @@ PD_API void ColorEdit::Draw() {
|
|||||||
layout->Slider<u8>("B", ((u8*)color_ref) + 2);
|
layout->Slider<u8>("B", ((u8*)color_ref) + 2);
|
||||||
layout->Slider<u8>("A", ((u8*)color_ref) + 3);
|
layout->Slider<u8>("A", ((u8*)color_ref) + 3);
|
||||||
layout->Update();
|
layout->Update();
|
||||||
list->SetLayer(50);
|
|
||||||
list->Merge(layout->GetDrawList());
|
list->Merge(layout->GetDrawList());
|
||||||
list->SetLayer(0);
|
|
||||||
// io->RegisterDrawList(GetID(), layout->GetDrawList());
|
// io->RegisterDrawList(GetID(), layout->GetDrawList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,11 +86,11 @@ PD_API void DragData<T>::Draw() {
|
|||||||
FinalPos() + fvec2(off_x, 0) + td + io->FramePadding,
|
FinalPos() + fvec2(off_x, 0) + td + io->FramePadding,
|
||||||
io->FrameRounding);
|
io->FrameRounding);
|
||||||
list->PathFill(io->Theme.Get(UI7Color_Button));
|
list->PathFill(io->Theme.Get(UI7Color_Button));
|
||||||
list->LayerUp();
|
// list->LayerUp();
|
||||||
list->DrawTextEx(FinalPos() + fvec2(off_x, 0), p.c_str(),
|
list->DrawTextEx(FinalPos() + fvec2(off_x, 0), p.c_str(),
|
||||||
io->Theme.Get(UI7Color_Text), LiTextFlags_AlignMid,
|
io->Theme.Get(UI7Color_Text), LiTextFlags_AlignMid,
|
||||||
td + io->FramePadding);
|
td + io->FramePadding);
|
||||||
list->LayerDown();
|
// list->LayerDown();
|
||||||
off_x += td.x + io->ItemSpace.x + io->FramePadding.x;
|
off_x += td.x + io->ItemSpace.x + io->FramePadding.x;
|
||||||
}
|
}
|
||||||
list->DrawText(FinalPos() + fvec2(off_x, io->FramePadding.y * 0.5),
|
list->DrawText(FinalPos() + fvec2(off_x, io->FramePadding.y * 0.5),
|
||||||
@@ -101,7 +101,6 @@ template <typename T>
|
|||||||
PD_API void DragData<T>::Update() {
|
PD_API void DragData<T>::Update() {
|
||||||
// Assert(io.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get(), "Did you run Container::Init correctly?");
|
||||||
// Probably need to find a faster solution (caching sizes calculated here)
|
// Probably need to find a faster solution (caching sizes calculated here)
|
||||||
list->SetFont(GetFont());
|
|
||||||
float off_x = 0;
|
float off_x = 0;
|
||||||
for (size_t i = 0; i < elm_count; i++) {
|
for (size_t i = 0; i < elm_count; i++) {
|
||||||
std::string p;
|
std::string p;
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ PD_API void Image::Draw() {
|
|||||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// Assert(img.get(), "Image is nullptr!");
|
// Assert(img.get(), "Image is nullptr!");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->LayerUp();
|
// list->LayerUp();
|
||||||
list->BindTexture(img);
|
list->BindTexture(img);
|
||||||
list->DrawRectFilled(FinalPos(), newsize, 0xffffffff);
|
list->DrawRectFilled(FinalPos(), newsize, 0xffffffff);
|
||||||
list->UnbindTexture();
|
list->UnbindTexture();
|
||||||
list->LayerDown();
|
// list->LayerDown();
|
||||||
}
|
}
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -28,7 +28,6 @@ namespace UI7 {
|
|||||||
PD_API void Label::Draw() {
|
PD_API void Label::Draw() {
|
||||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->SetFont(GetFont());
|
|
||||||
list->DrawTextEx(FinalPos(), label.c_str(), io->Theme.Get(UI7Color_Text),
|
list->DrawTextEx(FinalPos(), label.c_str(), io->Theme.Get(UI7Color_Text),
|
||||||
LiTextFlags_NoOOS,
|
LiTextFlags_NoOOS,
|
||||||
PD::fvec2(0, io->CurrentViewPort.pSize.w));
|
PD::fvec2(0, io->CurrentViewPort.pSize.w));
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ template <typename T>
|
|||||||
PD_API void Slider<T>::Draw() {
|
PD_API void Slider<T>::Draw() {
|
||||||
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
// Assert(io.get() && list.get(), "Did you run Container::Init correctly?");
|
||||||
// io->Ren->OnScreen(screen);
|
// io->Ren->OnScreen(screen);
|
||||||
list->SetFont(GetFont());
|
|
||||||
std::string p;
|
std::string p;
|
||||||
if constexpr (std::is_floating_point_v<T>) {
|
if constexpr (std::is_floating_point_v<T>) {
|
||||||
p = std::format("{:.{}f}", *data, precision);
|
p = std::format("{:.{}f}", *data, precision);
|
||||||
@@ -85,10 +84,10 @@ PD_API void Slider<T>::Draw() {
|
|||||||
FinalPos() + fvec2(slp + slw - 2, td.y - 2) + io->FramePadding,
|
FinalPos() + fvec2(slp + slw - 2, td.y - 2) + io->FramePadding,
|
||||||
io->FrameRounding);
|
io->FrameRounding);
|
||||||
list->PathFill(io->Theme.Get(UI7Color_ButtonActive));
|
list->PathFill(io->Theme.Get(UI7Color_ButtonActive));
|
||||||
list->LayerUp();
|
// list->LayerUp();
|
||||||
list->DrawTextEx(FinalPos(), p.c_str(), io->Theme.Get(UI7Color_Text),
|
list->DrawTextEx(FinalPos(), p.c_str(), io->Theme.Get(UI7Color_Text),
|
||||||
LiTextFlags_AlignMid, fvec2(width, td.y) + io->FramePadding);
|
LiTextFlags_AlignMid, fvec2(width, td.y) + io->FramePadding);
|
||||||
list->LayerDown();
|
// list->LayerDown();
|
||||||
list->DrawText(FinalPos() + fvec2(width + io->FramePadding.x * 2.f,
|
list->DrawText(FinalPos() + fvec2(width + io->FramePadding.x * 2.f,
|
||||||
io->FramePadding.y * 0.5),
|
io->FramePadding.y * 0.5),
|
||||||
label.c_str(), io->Theme.Get(UI7Color_Text));
|
label.c_str(), io->Theme.Get(UI7Color_Text));
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <pd/ui7/containers.hpp>
|
#include <pd/ui7/containers.hpp>
|
||||||
#include <pd/ui7/layout.hpp>
|
#include <pd/ui7/layout.hpp>
|
||||||
|
|
||||||
@@ -123,42 +122,6 @@ PD_API fvec2 Layout::AlignPosition(fvec2 pos, fvec2 size, fvec4 area,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_API void Layout::HandleScrolling() {
|
|
||||||
if (Flags & UI7LayoutFlags_VtScrolling) {
|
|
||||||
bool allowed = MaxPosition.y > WorkRect.w;
|
|
||||||
if (allowed) {
|
|
||||||
if (PD::Hid::IsEvent(Hid::Event::Down, PD::Hid::Gamepad::Touch) ||
|
|
||||||
PD::Hid::IsEvent(Hid::Event::Down, PD::Hid::Keyboard::MouseLeft)) {
|
|
||||||
ScrollStart = ScrollOffset;
|
|
||||||
}
|
|
||||||
if (IO.InputHandler.DragObject(UI7::ID("sbg" + ID.GetName()),
|
|
||||||
fvec4(Pos, fvec2(0.f)) + WorkRect)) {
|
|
||||||
if (!IO.InputHandler.DragReleasedAW) {
|
|
||||||
ScrollOffset.y =
|
|
||||||
std::clamp(ScrollStart.y + IO.InputHandler.DragSourcePos.y -
|
|
||||||
IO.InputHandler.DragPosition.y,
|
|
||||||
-20.f, MaxPosition.y - WorkRect.w + 20.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ScrollOffset.y = 0.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ScrollOffset.y > MaxPosition.y - WorkRect.w) {
|
|
||||||
ScrollOffset.y -= 1.5f;
|
|
||||||
if (ScrollOffset.y < MaxPosition.y - WorkRect.w) {
|
|
||||||
ScrollOffset.y = MaxPosition.y - WorkRect.w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ScrollOffset.y < 0) {
|
|
||||||
ScrollOffset.y += 1.5f;
|
|
||||||
if (ScrollOffset.y > 0) {
|
|
||||||
ScrollOffset.y = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PD_API void Layout::Update() {
|
PD_API void Layout::Update() {
|
||||||
if (Size == fvec2(0.f)) {
|
if (Size == fvec2(0.f)) {
|
||||||
Size = fvec2(MaxPosition) + IO.MenuPadding * 2;
|
Size = fvec2(MaxPosition) + IO.MenuPadding * 2;
|
||||||
@@ -192,7 +155,6 @@ PD_API void Layout::Update() {
|
|||||||
Objects.clear();
|
Objects.clear();
|
||||||
WorkRect = fvec4(fvec2(WorkRect.x, WorkRect.y), Size - IO.MenuPadding);
|
WorkRect = fvec4(fvec2(WorkRect.x, WorkRect.y), Size - IO.MenuPadding);
|
||||||
CursorInit();
|
CursorInit();
|
||||||
HandleScrolling();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** SECTION CONTAINERS (STOLEN FROM FORMER MENU) */
|
/** SECTION CONTAINERS (STOLEN FROM FORMER MENU) */
|
||||||
|
|||||||
+47
-15
@@ -104,7 +104,6 @@ PD_API void Menu::SeparatorText(const std::string& label) {
|
|||||||
DynObj* r = pIO.DynObjPool.Allocate();
|
DynObj* r = pIO.DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l,
|
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l,
|
||||||
UI7::Container* self) {
|
UI7::Container* self) {
|
||||||
l->SetFont(self->GetFont());
|
|
||||||
fvec2 size = self->GetSize();
|
fvec2 size = self->GetSize();
|
||||||
fvec2 tdim = io->Font->GetTextBounds(label.c_str(), io->FontScale);
|
fvec2 tdim = io->Font->GetTextBounds(label.c_str(), io->FontScale);
|
||||||
fvec2 pos = self->FinalPos();
|
fvec2 pos = self->FinalPos();
|
||||||
@@ -148,6 +147,45 @@ PD_API void Menu::HandleFocus() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Todo: (func name is self describing) */
|
||||||
|
PD_API void Menu::HandleScrolling() {
|
||||||
|
if (Flags & UI7MenuFlags_VtScrolling) {
|
||||||
|
bool allowed =
|
||||||
|
pLayout.MaxPosition.y > (pLayout.WorkRect.w - pLayout.WorkRect.y);
|
||||||
|
if (allowed) {
|
||||||
|
if (PD::Hid::IsEvent(Hid::Event::Down, PD::Hid::Gamepad::Touch)) {
|
||||||
|
pLayout.ScrollStart = pLayout.ScrollOffset;
|
||||||
|
}
|
||||||
|
if (pIO.InputHandler.DragObject(
|
||||||
|
"sbg" + pID.GetName(),
|
||||||
|
fvec4(pLayout.Pos, fvec2(0.f)) + pLayout.WorkRect)) {
|
||||||
|
if (pIO.InputHandler.DragReleasedAW) {
|
||||||
|
} else {
|
||||||
|
pLayout.ScrollOffset.y = std::clamp(
|
||||||
|
pLayout.ScrollStart.y + pIO.InputHandler.DragSourcePos.y -
|
||||||
|
pIO.InputHandler.DragPosition.y,
|
||||||
|
-20.f, pLayout.MaxPosition.y - 220);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pLayout.ScrollOffset.y = 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pLayout.ScrollOffset.y > pLayout.MaxPosition.y - 240) {
|
||||||
|
pLayout.ScrollOffset.y -= 1.5;
|
||||||
|
if (pLayout.ScrollOffset.y < pLayout.MaxPosition.y - 240) {
|
||||||
|
pLayout.ScrollOffset.y = pLayout.MaxPosition.y - 240;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pLayout.ScrollOffset.y < 0) {
|
||||||
|
pLayout.ScrollOffset.y += 1.5;
|
||||||
|
if (pLayout.ScrollOffset.y > 0) {
|
||||||
|
pLayout.ScrollOffset.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PD_API void Menu::HandleTitlebarActions() {
|
PD_API void Menu::HandleTitlebarActions() {
|
||||||
// Collapse
|
// Collapse
|
||||||
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
||||||
@@ -219,12 +257,11 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
if (!(Flags & UI7MenuFlags_NoResize)) {
|
if (!(Flags & UI7MenuFlags_NoResize)) {
|
||||||
DynObj* r = pIO.DynObjPool.Allocate();
|
DynObj* r = pIO.DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||||
l->SetLayer(1);
|
// //l->Layer(1);
|
||||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(0, 20));
|
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(0, 20));
|
||||||
l->PathAdd(self->FinalPos() + self->GetSize());
|
l->PathAdd(self->FinalPos() + self->GetSize());
|
||||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(20, 0));
|
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(20, 0));
|
||||||
l->PathFill(io->Theme.Get(UI7Color_Button));
|
l->PathFill(io->Theme.Get(UI7Color_Button));
|
||||||
l->SetLayer(0);
|
|
||||||
});
|
});
|
||||||
r->SetSize(
|
r->SetSize(
|
||||||
fvec2(pLayout.GetSize().x, pLayout.GetSize().y - TitleBarHeight));
|
fvec2(pLayout.GetSize().x, pLayout.GetSize().y - TitleBarHeight));
|
||||||
@@ -236,7 +273,7 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
/** Background */
|
/** Background */
|
||||||
DynObj* r = pIO.DynObjPool.Allocate();
|
DynObj* r = pIO.DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||||
l->SetLayer(0);
|
// l->Layer(0);
|
||||||
l->PathRectEx(self->FinalPos(), self->FinalPos() + self->GetSize(), 10.f,
|
l->PathRectEx(self->FinalPos(), self->FinalPos() + self->GetSize(), 10.f,
|
||||||
LiPathRectFlags_KeepTop | LiPathRectFlags_KeepBot);
|
LiPathRectFlags_KeepTop | LiPathRectFlags_KeepBot);
|
||||||
l->PathFill(io->Theme.Get(UI7Color_Background));
|
l->PathFill(io->Theme.Get(UI7Color_Background));
|
||||||
@@ -254,12 +291,11 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
DynObj* r = pIO.DynObjPool.Allocate();
|
DynObj* r = pIO.DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj(
|
*r = UI7::DynObj(
|
||||||
[=, this](UI7::IO* io, Li::Drawlist* l, UI7::Container* self) {
|
[=, this](UI7::IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||||
l->SetFont(self->GetFont());
|
// l->Layer(20);
|
||||||
l->SetLayer(20);
|
|
||||||
/** Header Bar */
|
/** Header Bar */
|
||||||
l->DrawRectFilled(self->FinalPos(), self->GetSize(),
|
l->DrawRectFilled(self->FinalPos(), self->GetSize(),
|
||||||
io->Theme.Get(UI7Color_Header));
|
io->Theme.Get(UI7Color_Header));
|
||||||
l->SetLayer(21);
|
// l->Layer(21);
|
||||||
/** Inline if statement to shift the Text if collapse sym is shown */
|
/** Inline if statement to shift the Text if collapse sym is shown */
|
||||||
/** What the hell is this code btw (didn't found a better way) */
|
/** What the hell is this code btw (didn't found a better way) */
|
||||||
l->DrawText(self->FinalPos() +
|
l->DrawText(self->FinalPos() +
|
||||||
@@ -269,7 +305,6 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
(io->FramePadding.x * 2)),
|
(io->FramePadding.x * 2)),
|
||||||
2),
|
2),
|
||||||
pID.GetName().c_str(), io->Theme.Get(UI7Color_Text));
|
pID.GetName().c_str(), io->Theme.Get(UI7Color_Text));
|
||||||
l->SetLayer(0);
|
|
||||||
});
|
});
|
||||||
r->SetSize(fvec2(pLayout.GetSize().x, TitleBarHeight));
|
r->SetSize(fvec2(pLayout.GetSize().x, TitleBarHeight));
|
||||||
r->SetPos(0);
|
r->SetPos(0);
|
||||||
@@ -281,7 +316,7 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l,
|
*r = UI7::DynObj([=, this](UI7::IO* io, Li::Drawlist* l,
|
||||||
UI7::Container* self) {
|
UI7::Container* self) {
|
||||||
/** This sym actually requires layer 21 (i dont know why) */
|
/** This sym actually requires layer 21 (i dont know why) */
|
||||||
l->SetLayer(21);
|
// l->Layer(21);
|
||||||
/**
|
/**
|
||||||
* Symbol (Position Swapping set by pIsOpen ? openpos : closepos;)
|
* Symbol (Position Swapping set by pIsOpen ? openpos : closepos;)
|
||||||
*/
|
*/
|
||||||
@@ -292,7 +327,6 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
self->FinalPos() +
|
self->FinalPos() +
|
||||||
fvec2(pIsOpen ? self->GetSize().x * 0.5 : 0, self->GetSize().y),
|
fvec2(pIsOpen ? self->GetSize().x * 0.5 : 0, self->GetSize().y),
|
||||||
io->Theme.Get(UI7Color_FrameBackground));
|
io->Theme.Get(UI7Color_FrameBackground));
|
||||||
l->SetLayer(0);
|
|
||||||
});
|
});
|
||||||
r->SetSize(TitleBarHeight - pIO.FramePadding.y * 2);
|
r->SetSize(TitleBarHeight - pIO.FramePadding.y * 2);
|
||||||
r->SetPos(pIO.FramePadding);
|
r->SetPos(pIO.FramePadding);
|
||||||
@@ -324,10 +358,6 @@ PD_API void Menu::Update() {
|
|||||||
if (pLayout.Size == fvec2(0.f) || Flags & UI7MenuFlags_AlwaysAutoSize) {
|
if (pLayout.Size == fvec2(0.f) || Flags & UI7MenuFlags_AlwaysAutoSize) {
|
||||||
pLayout.Size = fvec2(pLayout.MaxPosition) + pIO.MenuPadding * 2;
|
pLayout.Size = fvec2(pLayout.MaxPosition) + pIO.MenuPadding * 2;
|
||||||
}
|
}
|
||||||
if (Flags & UI7MenuFlags_VtScrolling)
|
|
||||||
pLayout.Flags |= UI7LayoutFlags_VtScrolling;
|
|
||||||
if (Flags & UI7MenuFlags_HzScrolling)
|
|
||||||
pLayout.Flags |= UI7LayoutFlags_HzScrolling;
|
|
||||||
if (!(Flags & UI7MenuFlags_NoTitlebar)) {
|
if (!(Flags & UI7MenuFlags_NoTitlebar)) {
|
||||||
TitleBarHeight = pIO.FontScale * pIO.Font->PixelHeight + pIO.MenuPadding.y;
|
TitleBarHeight = pIO.FontScale * pIO.Font->PixelHeight + pIO.MenuPadding.y;
|
||||||
pLayout.WorkRect.y = 5.f + TitleBarHeight;
|
pLayout.WorkRect.y = 5.f + TitleBarHeight;
|
||||||
@@ -338,6 +368,9 @@ PD_API void Menu::Update() {
|
|||||||
}
|
}
|
||||||
DrawBaseLayout();
|
DrawBaseLayout();
|
||||||
pLayout.Update();
|
pLayout.Update();
|
||||||
|
if (Flags & UI7MenuFlags_VtScrolling || Flags & UI7MenuFlags_HzScrolling) {
|
||||||
|
HandleScrolling();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PD_API bool Menu::BeginTreeNode(const ID& id) {
|
PD_API bool Menu::BeginTreeNode(const ID& id) {
|
||||||
@@ -358,7 +391,6 @@ PD_API bool Menu::BeginTreeNode(const ID& id) {
|
|||||||
// Object
|
// Object
|
||||||
DynObj* r = pIO.DynObjPool.Allocate();
|
DynObj* r = pIO.DynObjPool.Allocate();
|
||||||
*r = UI7::DynObj([=, this](IO* io, Li::Drawlist* l, Container* self) {
|
*r = UI7::DynObj([=, this](IO* io, Li::Drawlist* l, Container* self) {
|
||||||
l->SetFont(self->GetFont());
|
|
||||||
fvec2 ts = self->FinalPos() + fvec2(0, 7);
|
fvec2 ts = self->FinalPos() + fvec2(0, 7);
|
||||||
fvec2 pl[2] = {fvec2(10, 5), fvec2(0, 10)};
|
fvec2 pl[2] = {fvec2(10, 5), fvec2(0, 10)};
|
||||||
if (n->second) {
|
if (n->second) {
|
||||||
|
|||||||
@@ -143,11 +143,8 @@ PD_API void Context::Update() {
|
|||||||
pMenus[it]->Update(); /** Render */
|
pMenus[it]->Update(); /** Render */
|
||||||
this->pIO.InputHandler.CurrentMenu = 0;
|
this->pIO.InputHandler.CurrentMenu = 0;
|
||||||
}
|
}
|
||||||
int base_layer = 0;
|
|
||||||
for (int i = (int)FinalList.size() - 1; i >= 0; i--) {
|
for (int i = (int)FinalList.size() - 1; i >= 0; i--) {
|
||||||
pIO.FDL.SetLayer(base_layer);
|
|
||||||
pIO.FDL.Merge(pMenus[FinalList[i]]->pLayout.GetDrawList());
|
pIO.FDL.Merge(pMenus[FinalList[i]]->pLayout.GetDrawList());
|
||||||
base_layer += 100;
|
|
||||||
}
|
}
|
||||||
pCurrentMenus.clear();
|
pCurrentMenus.clear();
|
||||||
pIO.Update();
|
pIO.Update();
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ int main(int argc, char** argv) {
|
|||||||
PD::TT::Beg("MainRaw");
|
PD::TT::Beg("MainRaw");
|
||||||
PD::Hid::Update();
|
PD::Hid::Update();
|
||||||
PD::Gfx::NewFrame();
|
PD::Gfx::NewFrame();
|
||||||
PD::Li::ResetPools();
|
|
||||||
// app.Update(pOs->GetViewport(), pList);
|
// app.Update(pOs->GetViewport(), pList);
|
||||||
pList.SetFontscale(0.7);
|
pList.SetFontscale(0.7);
|
||||||
if (PD::Hid::IsEvent(PD::Hid::Event::Down, PD::Hid::Gamepad::CPLeft |
|
if (PD::Hid::IsEvent(PD::Hid::Event::Down, PD::Hid::Gamepad::CPLeft |
|
||||||
@@ -298,13 +297,13 @@ int main(int argc, char** argv) {
|
|||||||
"#ff00ff");
|
"#ff00ff");
|
||||||
}
|
}
|
||||||
pList.SetFont(&font);
|
pList.SetFont(&font);
|
||||||
|
#ifndef __3DS__
|
||||||
PD::TT::Beg("BuildUI7Menus");
|
PD::TT::Beg("BuildUI7Menus");
|
||||||
if (auto m = ui7.BeginMenu("Test")) {
|
if (auto m = ui7.BeginMenu("Test")) {
|
||||||
m->Label("Hello World!");
|
m->Label("Hello World!");
|
||||||
ui7.EndMenu();
|
ui7.EndMenu();
|
||||||
}
|
}
|
||||||
if (auto m = ui7.BeginMenu("LI DBG INFO")) {
|
if (auto m = ui7.BeginMenu("LI DBG INFO")) {
|
||||||
m->PushFont(&debug_font);
|
|
||||||
m->Label("Gfx Driver: {}", PD::Gfx::GetDriverName());
|
m->Label("Gfx Driver: {}", PD::Gfx::GetDriverName());
|
||||||
m->Separator();
|
m->Separator();
|
||||||
m->Label("LI Draw Comamnds: {}", PD::Gfx::GetNumCommands());
|
m->Label("LI Draw Comamnds: {}", PD::Gfx::GetNumCommands());
|
||||||
@@ -312,7 +311,6 @@ int main(int argc, char** argv) {
|
|||||||
m->Label("GFX Vertices: {}", PD::Gfx::GetNumVertices());
|
m->Label("GFX Vertices: {}", PD::Gfx::GetNumVertices());
|
||||||
m->Label("GFX Triangles: {}", PD::Gfx::GetNumVertices() / 3);
|
m->Label("GFX Triangles: {}", PD::Gfx::GetNumVertices() / 3);
|
||||||
m->Label("GFX Indices: {}", PD::Gfx::GetNumIndices());
|
m->Label("GFX Indices: {}", PD::Gfx::GetNumIndices());
|
||||||
m->PopFont();
|
|
||||||
ui7.EndMenu();
|
ui7.EndMenu();
|
||||||
}
|
}
|
||||||
ui7.MetricsMenu();
|
ui7.MetricsMenu();
|
||||||
@@ -320,10 +318,11 @@ int main(int argc, char** argv) {
|
|||||||
PD::TT::Beg("UI7::Context::Update");
|
PD::TT::Beg("UI7::Context::Update");
|
||||||
ui7.Update();
|
ui7.Update();
|
||||||
PD::TT::End("UI7::Context::Update");
|
PD::TT::End("UI7::Context::Update");
|
||||||
|
#endif
|
||||||
PD::Gfx::Reset();
|
PD::Gfx::Reset();
|
||||||
PD::TT::Beg("PD::Gfx::Draw");
|
PD::TT::Beg("PD::Gfx::Draw");
|
||||||
PD::Gfx::Draw(ui7.GetDrawData());
|
|
||||||
PD::Gfx::Draw(pList);
|
PD::Gfx::Draw(pList);
|
||||||
|
PD::Gfx::Draw(ui7.GetDrawData());
|
||||||
PD::TT::End("PD::Gfx::Draw");
|
PD::TT::End("PD::Gfx::Draw");
|
||||||
pList.Clear();
|
pList.Clear();
|
||||||
PD::TT::End("MainRaw");
|
PD::TT::End("MainRaw");
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void HorizonCtr::Init() {
|
|||||||
romfsInit();
|
romfsInit();
|
||||||
osSetSpeedupEnable(true);
|
osSetSpeedupEnable(true);
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
// consoleInit(GFX_BOTTOM, nullptr);
|
consoleInit(GFX_BOTTOM, nullptr);
|
||||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||||
impl->Top =
|
impl->Top =
|
||||||
C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||||
@@ -43,7 +43,7 @@ void HorizonCtr::Init() {
|
|||||||
C3D_RenderTargetSetOutput(impl->Bottom, GFX_BOTTOM, GFX_LEFT,
|
C3D_RenderTargetSetOutput(impl->Bottom, GFX_BOTTOM, GFX_LEFT,
|
||||||
DisplayTransferFlags);
|
DisplayTransferFlags);
|
||||||
PD::Gfx::UseDriver<PD::GfxCitro3D>();
|
PD::Gfx::UseDriver<PD::GfxCitro3D>();
|
||||||
PD::Hid::UseDriver<PD::Hid3DS>();
|
PD::Hid::UseDriver<PD::HidDriver>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HorizonCtr::Deinit() {
|
void HorizonCtr::Deinit() {
|
||||||
@@ -61,13 +61,14 @@ void HorizonCtr::Deinit() {
|
|||||||
|
|
||||||
bool HorizonCtr::Mainloop() {
|
bool HorizonCtr::Mainloop() {
|
||||||
pViewPort = ivec2(400, 240);
|
pViewPort = ivec2(400, 240);
|
||||||
|
hidScanInput();
|
||||||
bool _kill = hidKeysUp() & KEY_START;
|
bool _kill = hidKeysUp() & KEY_START;
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
|
||||||
return aptMainLoop() && !_kill;
|
return aptMainLoop() && !_kill;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HorizonCtr::ClearViewPort() {
|
void HorizonCtr::ClearViewPort() {
|
||||||
PD::Gfx::SetViewPort(pViewPort);
|
PD::Gfx::SetViewPort(pViewPort);
|
||||||
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
C3D_FrameDrawOn(impl->Top);
|
C3D_FrameDrawOn(impl->Top);
|
||||||
C3D_RenderTargetClear(impl->Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
|
C3D_RenderTargetClear(impl->Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user