Implement static draw routines to RectBase to unify JUI's rectangle motifs.

This commit is contained in:
2025-06-24 01:57:38 -05:00
parent d5d6703ee9
commit 9d901c6300
2 changed files with 62 additions and 18 deletions

View File

@@ -18,6 +18,8 @@
#include "JGL/types/RenderTarget.h"
#include <JUI/DefaultStyle.hpp>
#include "JGL/JGL.h"
namespace JUI
{
enum class BorderMode
@@ -28,7 +30,7 @@ namespace JUI
};
enum class CornerRoundingMode {
None, Circular, Chamfer,
None, Rounded, Chamfer,
};
/// Base implementation for rendering rectangles with decorations.
@@ -72,9 +74,29 @@ namespace JUI
void Draw(const Vector2& pos, const Vector2& size);
void Draw(const Color4& bgColor, const Color4& fgColor, const Vector2& pos, const Vector2& size);
/// Core routine for drawing outline rects.
static void DrawOutline(const Color4& color,
const Vector2& pos, const Vector2& size,
float rounding, float borderWidth,
enum BorderMode borderMode, enum CornerRoundingMode cornerRoundingMode);
/// Core routine for drawing background rects.
static void DrawBG(const Color4& color,
const Vector2& pos, const Vector2& size,
float rounding,
enum CornerRoundingMode rounding_mode);
/// Core routine for drawing rect boxes, with background and outline.
static void Draw(const Color4& bgColor, const Color4& fgColor,
const Vector2& pos, const Vector2& size,
float rounding, float borderWidth,
enum BorderMode borderMode, enum CornerRoundingMode rounding_mode);
protected:
enum BorderMode border_mode = BorderMode::Middle;
enum CornerRoundingMode corner_mode = CornerRoundingMode::Rounded;
bool mouse_press_debounce{};
bool mouse_inside_debounce{};
float border_width = Style::BorderLineWidth;