- Litium Chenge Static Object to set instead of add layer - Add UI7 Color Selector (Not done) - Add NoClose flag as well as a is_shown address to set to close menus completly - Add u32 input for nameless ui7 ids - Add Debug Vertex/Index counters to DrawLists and IO - Add an Anywhere Released bool to Input API to decide if object should always react or only if curser is inside its box - Add Focused Menu System to Drag API to make sure to not care about the menu input process order - Let Menus only have 1 Drawlist instead of 3 Put Close, Resize, Move, Collapse and Scroll into their own handlers - Add a DeadHeader color to make a visual diffrence between Menus and Focused Menu - Add a GetRef to Theme for Color edit - Fix DrawList Line not rendering if going out of screen - Clear All CLipRects after process DrawList - Fix SeparatorText glitch - Fix Typos - Add IO Input Support to Containers
121 lines
3.7 KiB
C++
121 lines
3.7 KiB
C++
#pragma once
|
|
|
|
/*
|
|
MIT License
|
|
Copyright (c) 2024 - 2025 René Amthor (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/core/common.hpp>
|
|
#include <pd/lithium/renderer.hpp>
|
|
#include <pd/ui7/theme.hpp>
|
|
|
|
namespace PD {
|
|
namespace UI7 {
|
|
/** DrawList class */
|
|
class DrawList : public SmartCtor<DrawList> {
|
|
public:
|
|
/**
|
|
* Constructor for a new Drawlist
|
|
* @param r Renderer reference
|
|
*/
|
|
DrawList(LI::Renderer::Ref r) { ren = r; }
|
|
~DrawList() = default;
|
|
|
|
/**
|
|
* Render a Rectangle
|
|
* @param pos Position
|
|
* @param szs Size
|
|
* @param clr Color
|
|
*/
|
|
void AddRectangle(vec2 pos, vec2 szs, const UI7Color& clr);
|
|
/**
|
|
* Render a Triangle
|
|
* @param pos0 Position a
|
|
* @param pos1 Position b
|
|
* @param pos2 Position c
|
|
* @param clr Color
|
|
*/
|
|
void AddTriangle(vec2 pos0, vec2 pos1, vec2 pos2, const UI7Color& clr);
|
|
/**
|
|
* Render a Text
|
|
* @param pos Position
|
|
* @param text Text
|
|
* @param clr Color
|
|
* @param flags Flags
|
|
* @param box Aditional Text Box limit (for specific flags)
|
|
*/
|
|
void AddText(vec2 pos, const std::string& text, const UI7Color& clr,
|
|
LITextFlags flags = 0, vec2 box = vec2());
|
|
/**
|
|
* Render an Image
|
|
* @param pos Position
|
|
* @param img Image Texture Reference
|
|
* @param size Optional Size of the Image
|
|
*/
|
|
void AddImage(vec2 pos, Texture::Ref img, vec2 size = 0.f);
|
|
/**
|
|
* Render a Line from Position A to Position B
|
|
* @param a Pos a
|
|
* @param b Pos b
|
|
* @param clr Color
|
|
* @param t Thcikness
|
|
*/
|
|
void AddLine(const vec2& a, const vec2& b, const UI7Color& clr, int t = 1);
|
|
|
|
/** Clear the Drawlist */
|
|
void Clear();
|
|
/** Process [Render] the Drawlist */
|
|
void Process();
|
|
|
|
/** Push a Clip Rect */
|
|
void PushClipRect(const vec4& v) { clip_rects.push(v); }
|
|
|
|
/** Revert Last Clip Rect */
|
|
void PopClipRect() { clip_rects.pop(); }
|
|
|
|
/** Getter for the Layer */
|
|
int Layer() const { return layer; }
|
|
/** Setter fot the Layer */
|
|
void Layer(int v) { layer = v; }
|
|
|
|
private:
|
|
/** Base Layer offset (Internal Used) */
|
|
int BaseLayer() const { return base; }
|
|
/** Base Layer offset (Internal Used) */
|
|
void BaseLayer(int v) { base = v; }
|
|
|
|
// Set friendclass here to not expose private functions as public
|
|
friend class Menu;
|
|
friend class Context;
|
|
|
|
int layer; ///< Current Layer
|
|
int base; ///< Base Layer
|
|
LI::Renderer::Ref ren; ///< Renderer Reference
|
|
std::stack<vec4> clip_rects; ///< Stack containing Scissor Areas
|
|
u32 num_vertices; ///< Number of Vertices
|
|
u32 num_indices; ///< Number of Indices
|
|
// Map for Auto Static Text
|
|
std::unordered_map<u32, LI::StaticText::Ref> static_text;
|
|
// List of Drawcommands generated
|
|
std::vector<std::pair<bool, LI::Command::Ref>> commands;
|
|
};
|
|
} // namespace UI7
|
|
} // namespace PD
|