- 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
114 lines
3.6 KiB
C++
Executable File
114 lines
3.6 KiB
C++
Executable File
#pragma once
|
|
|
|
/*
|
|
MIT License
|
|
|
|
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
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
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
|
|
SOFTWARE.
|
|
*/
|
|
|
|
#include "pd/ui7/container/dragdata.hpp"
|
|
#include <pd/core/core.hpp>
|
|
#include <pd/ui7/io.hpp>
|
|
#include <pd/ui7/layout.hpp>
|
|
#include <pd/ui7/pd_p_api.hpp>
|
|
|
|
namespace PD {
|
|
namespace UI7 {
|
|
class PD_UI7_API Menu {
|
|
public:
|
|
Menu(const UI7::ID &id, UI7::IO::Ref pIO);
|
|
~Menu() {}
|
|
|
|
PD_SHARED(Menu);
|
|
|
|
/**
|
|
* Render a Simple Label
|
|
* @param label The text to draw
|
|
*/
|
|
void Label(const std::string &label);
|
|
/**
|
|
* Render a Button
|
|
* @param label The buttons text
|
|
* @return if the button was pressed
|
|
*/
|
|
bool Button(const std::string &label);
|
|
/**
|
|
* Render a Checkbox
|
|
* @param label Label of the Checkbox
|
|
* @param v A value to update
|
|
*/
|
|
void Checkbox(const std::string &label, bool &v);
|
|
/**
|
|
* Render an Image
|
|
* @param img Texture reference of the image
|
|
* @param size a Custom Size if needed
|
|
*/
|
|
void Image(Li::Texture::Ref img, fvec2 size = 0.f, Li::Rect uv = fvec4(0));
|
|
/**
|
|
* Render a Drag Object witth any supported type:
|
|
* [`int`, `float`, `double`, `u8`, `u16`, `u32`]
|
|
* @param label Name of the Drag
|
|
* @param data Reference to Data Object (can be multiple as well)
|
|
* @param num_elements Defien the number of Elements in the Data addr
|
|
* @param precission Difine the Format string len for float/double
|
|
*/
|
|
template <typename T>
|
|
void DragData(const std::string &label, T *data, size_t num_elms = 1,
|
|
T min = std::numeric_limits<T>::min(),
|
|
T max = std::numeric_limits<T>::max(), T step = 1,
|
|
int precision = 1) {
|
|
u32 id = Strings::FastHash("drd" + label + std::to_string((uintptr_t)data));
|
|
Container::Ref r = pLayout->FindObject(id);
|
|
if (!r) {
|
|
r = UI7::DragData<T>::New(label, data, num_elms, pIO, min, max, step,
|
|
precision);
|
|
// Isnt This exactly the same line???
|
|
// r = UI7::DragData<T>::New(label, data, num_elms, pIO, min, max, step,
|
|
// precision);
|
|
r->SetID(id);
|
|
}
|
|
pLayout->AddObject(r);
|
|
}
|
|
void Sameline() { pLayout->SameLine(); }
|
|
void Separator();
|
|
void SeparatorText(const std::string &label);
|
|
|
|
void HandleFocus();
|
|
void HandleScrolling();
|
|
void HandleTitlebarActions();
|
|
void DrawBaseLayout();
|
|
|
|
void Update();
|
|
|
|
/** Data Section */
|
|
|
|
UI7MenuFlags Flags = 0;
|
|
Layout::Ref pLayout;
|
|
IO::Ref pIO;
|
|
ID pID;
|
|
bool *pIsShown = nullptr;
|
|
bool pIsOpen = true;
|
|
|
|
float TitleBarHeight = 0.f;
|
|
};
|
|
} // namespace UI7
|
|
} // namespace PD
|