# Rewrite 5
- Move Libraries Source into pd directory and give them all their own CMakeLists.txt - Partial rewrite core (color, autogenerated vec), lithium (now uses UNIQUE PTR for Commands), UI7 - Use MenuV2 as new standart in UI7 - Implementz ViewPort Pre alpha to UI7 - Add Line Drawing to DrawList (not Working) - Implement a Complete new drievrs API (static Drivers) - NO SUPPORT FOR SHARED LIBRARY BUILDS IN VERSION 5 YET - Add Tools to Autogenerate Headers and Stuff
This commit is contained in:
135
include/pd/ui7/ui7.hpp
Normal file → Executable file
135
include/pd/ui7/ui7.hpp
Normal file → Executable file
@ -2,7 +2,8 @@
|
||||
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
Copyright (c) 2024 - 2025 tobid7
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@ -23,130 +24,56 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "pd/ui7/flags.hpp"
|
||||
#include <pd/core/core.hpp>
|
||||
#include <pd/ui7/drawlist.hpp>
|
||||
#include <pd/ui7/flags.hpp>
|
||||
#include <pd/ui7/id.hpp>
|
||||
#include <pd/ui7/io.hpp>
|
||||
#include <pd/ui7/menu.hpp>
|
||||
#include <pd/ui7/remenu.hpp>
|
||||
#include <pd/ui7/theme.hpp>
|
||||
#include <pd/ui7/pd_p_api.hpp>
|
||||
|
||||
/**
|
||||
* Declare UI7 Version
|
||||
* Format: 00 00 00 00
|
||||
* Major Minor Patch Build
|
||||
* 0x01010000 -> 1.1.0-0
|
||||
*/
|
||||
#define UI7_VERSION 0x00040000
|
||||
#define UI7_VERSION 0x00050000
|
||||
|
||||
namespace PD {
|
||||
namespace UI7 {
|
||||
/**
|
||||
* Get UI7 Version String
|
||||
* @param show_build Ahow build num (mostly unused)
|
||||
* @param show_build Show build num (mostly unused)
|
||||
* @return Version String (1.0.0-1 for example)
|
||||
*/
|
||||
PD_UI7_API std::string GetVersion(bool show_build = false);
|
||||
/** Base Context for UI7 */
|
||||
class PD_UI7_API Context : public SmartCtor<Context> {
|
||||
public:
|
||||
/**
|
||||
* Constructor for UI7 Context
|
||||
* @param ren Renderer Reference
|
||||
* @param hid Input Driver Reference
|
||||
*/
|
||||
Context(LI::Renderer::Ref ren, Hid::Ref hid) {
|
||||
/// Set the Internal References
|
||||
io = IO::New(hid, ren);
|
||||
}
|
||||
class PD_UI7_API Context {
|
||||
public:
|
||||
Context() { pIO = IO::New(); }
|
||||
~Context() = default;
|
||||
|
||||
/**
|
||||
* Begin a New Menu
|
||||
* @param id Menu ID / Name shown in Titlebar
|
||||
* @param flags Optional flags to change stuff
|
||||
* @return If the Menu was Created
|
||||
* (useless as false results in an error screen)
|
||||
*/
|
||||
bool BeginMenu(const ID& id, UI7MenuFlags flags = 0, bool* show = nullptr);
|
||||
bool DoMenuEx(const ID& id, UI7MenuFlags flags,
|
||||
std::function<void(ReMenu::Ref m)> f);
|
||||
/**
|
||||
* Get the Current Menu
|
||||
* for example for auto m = ctx->GetCurrentMenu
|
||||
*/
|
||||
Menu::Ref GetCurrentMenu();
|
||||
/**
|
||||
* Find a Menu by its ID to edit things outside of
|
||||
* the place between Begin and EndMenu
|
||||
* @param id ID (Menu Name) to search for
|
||||
*/
|
||||
Menu::Ref FindMenu(const ID& id);
|
||||
/**
|
||||
* Ends the Current Menu
|
||||
* (to be able to create another one)
|
||||
*/
|
||||
PD_SHARED(Context);
|
||||
|
||||
void AddViewPort(const ID &id, const ivec4 &vp);
|
||||
void UseViewPort(const ID &id);
|
||||
void Update();
|
||||
bool BeginMenu(const ID &id, UI7MenuFlags flags, bool *pShow = nullptr);
|
||||
void EndMenu();
|
||||
|
||||
/**
|
||||
* Get Theme reference
|
||||
* @return Reference to the base Theme of the context
|
||||
*/
|
||||
Theme::Ref GetTheme() { return io->Theme; }
|
||||
/**
|
||||
*Directly return a Color by using the
|
||||
* ctx->ThemeColor(UI7Color_Text) for example
|
||||
* @param clr The Input UI7 Color
|
||||
* @return The 32bit color value
|
||||
*/
|
||||
u32 ThemeColor(UI7Color clr) const { return io->Theme->Get(clr); }
|
||||
Menu::Ref pGetOrCreateMenu(const ID &id) {
|
||||
auto menu = pMenus.find(id);
|
||||
if (menu == pMenus.end()) {
|
||||
pMenus[id] = Menu::New(id, pIO);
|
||||
menu = pMenus.find(id);
|
||||
}
|
||||
return menu->second;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Context (Render menus)
|
||||
* @param delta deltatime
|
||||
*/
|
||||
void Update(float delta);
|
||||
|
||||
// Expose DrawLists
|
||||
|
||||
/** Background DrawList Reference */
|
||||
DrawList::Ref BackList() { return io->Back; }
|
||||
/** Foreground DrawList Reference */
|
||||
DrawList::Ref FrontList() { return io->Front; }
|
||||
|
||||
/**
|
||||
* Set the Root Layer of the Menu
|
||||
* @param l Layer
|
||||
*/
|
||||
void RootLayer(int l) { root_layer = l; }
|
||||
/** Get the Root Layer of the Menu */
|
||||
int RootLayer() const { return root_layer; }
|
||||
|
||||
/** Get IO Reference */
|
||||
IO::Ref GetIO() { return io; }
|
||||
|
||||
// Debugging / Demo / About
|
||||
|
||||
/** About Menu */
|
||||
void AboutMenu(bool* show = nullptr);
|
||||
|
||||
/** Metrics */
|
||||
void MetricsMenu(bool* show = nullptr);
|
||||
|
||||
/** Style Editor Menu (Includes Theme Editor) */
|
||||
void StyleEditor(bool* show = nullptr);
|
||||
|
||||
private:
|
||||
// Used in Overlays
|
||||
int root_layer = 0;
|
||||
// Map of The Menus by ID
|
||||
std::unordered_map<u32, Menu::Ref> menus;
|
||||
std::vector<u32> amenus; ///< Active ones
|
||||
std::vector<u32> aml; ///< Copy of Active Menus
|
||||
Menu::Ref current; ///< Current Menu
|
||||
ReMenu::Ref Current;
|
||||
// IO
|
||||
IO::Ref io;
|
||||
IO::Ref pIO;
|
||||
/** Current Menu */
|
||||
Menu::Ref pCurrent = nullptr;
|
||||
std::vector<u32> pCurrentMenus;
|
||||
std::unordered_map<u32, Menu::Ref> pMenus;
|
||||
};
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
} // namespace UI7
|
||||
} // namespace PD
|
||||
|
Reference in New Issue
Block a user