Spastic Edits
This commit is contained in:
@@ -27,6 +27,10 @@ namespace JUI
|
||||
Inset /// As BorderWidth increases, the border grows inward only. The dimensions of the widget's contents are reduced at a 1:2 ratio.
|
||||
};
|
||||
|
||||
enum class CornerRoundingMode {
|
||||
None, Circular, Chamfer,
|
||||
};
|
||||
|
||||
/// Base implementation for rendering rectangles with decorations.
|
||||
class RectBase {
|
||||
public:
|
||||
@@ -40,6 +44,7 @@ namespace JUI
|
||||
virtual void CornerRounding(float radius);
|
||||
|
||||
[[nodiscard]] float CornerRounding() const;
|
||||
enum CornerRoundingMode CornerRoundingMode() const;
|
||||
|
||||
// TODO: Implement per-corner rounding in JGL::Outline/FillRect
|
||||
//void CornerRounding(float tlRadius, float trRadius, float blRadius, float brRadius);
|
||||
|
31
include/JUI/Style/RectStyler.hpp
Normal file
31
include/JUI/Style/RectStyler.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <Color4.hpp>
|
||||
#include <Colors.hpp>
|
||||
|
||||
namespace JUI {
|
||||
|
||||
class RectStyler {
|
||||
public:
|
||||
#pragma region Getters
|
||||
virtual Color4 BGColor() const = 0;
|
||||
virtual Color4 BorderColor() const = 0;
|
||||
virtual enum BorderMode BorderMode() const = 0;
|
||||
virtual float BorderWidth() const = 0;
|
||||
virtual float CornerRounding() const = 0;
|
||||
#pragma endregion
|
||||
#pragma region Setters
|
||||
virtual void BGColor(const Color4& color) = 0;
|
||||
virtual void BorderColor(const Color4& color) = 0;
|
||||
virtual void BorderMode(const enum BorderMode& borderMode) = 0;
|
||||
virtual void BorderWidth(float width) = 0;
|
||||
#pragma endregion
|
||||
|
||||
protected:
|
||||
float border_width = 1.f;
|
||||
Color4 border_color {192, 192, 192};
|
||||
enum BorderMode border_mode;
|
||||
float corner_rounding = 0.f;
|
||||
private:
|
||||
};
|
||||
}
|
@@ -32,19 +32,7 @@ namespace JUI {
|
||||
virtual Separator* AddSeparator(const UDim& size = 5_px) = 0;
|
||||
};
|
||||
|
||||
class RectStyleInterface {
|
||||
public:
|
||||
virtual Color4 BGColor() const = 0;
|
||||
virtual Color4 BorderColor() const = 0;
|
||||
virtual enum BorderMode BorderMode() const = 0;
|
||||
virtual float BorderWidth() const = 0;
|
||||
virtual float CornerRounding() const = 0;
|
||||
|
||||
virtual void BGColor(const Color4& color) = 0;
|
||||
virtual void BorderColor(const Color4& color) = 0;
|
||||
virtual void BorderMode(const enum BorderMode& borderMode) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@@ -7,11 +7,14 @@
|
||||
|
||||
|
||||
namespace JUI {
|
||||
|
||||
///
|
||||
struct DataPoint {
|
||||
Vector2 pos;
|
||||
Color4 color;
|
||||
};
|
||||
|
||||
///
|
||||
class FpsGraph : public JUI::ImageRect
|
||||
{
|
||||
public:
|
||||
|
@@ -2,8 +2,35 @@
|
||||
#include "Rect.hpp"
|
||||
#include "ImageRect.hpp"
|
||||
|
||||
class Graph : public JUI::ImageRect {
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
namespace JUI {
|
||||
|
||||
/// A widget that plots and displays a data set in the form of various graphs.
|
||||
class Graph : public ImageRect {
|
||||
public:
|
||||
/// The default constructor sets sensible defaults for style properties and zero-initializes other members.
|
||||
Graph()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// Constructs a Graph by explicitly specifying its parent element.
|
||||
explicit Graph(Widget* parent) : Graph() {
|
||||
this->Parent(parent);
|
||||
}
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
class PieChart : public Graph {
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
class LineGraph : public Graph {
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
@@ -27,6 +27,17 @@ namespace JUI
|
||||
|
||||
|
||||
|
||||
struct Scrubber {
|
||||
public:
|
||||
Color4 color;
|
||||
UDim2 size;
|
||||
|
||||
protected:
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// A slider is a widget with a handle which can be pulled back and forth to change the value.
|
||||
class Slider : public Rect, public Clickable, public Hoverable
|
||||
{
|
||||
@@ -42,6 +53,7 @@ namespace JUI
|
||||
[[nodiscard]] float CurrentValue() const;
|
||||
[[nodiscard]] Color4 ScrubberColor() const;
|
||||
[[nodiscard]] float ScrubberWidth() const;
|
||||
[[nodiscard]] UDim2 ScrubberSize() const;
|
||||
[[nodiscard]] bool Dragging() const;
|
||||
[[nodiscard]] float Range() const;
|
||||
|
||||
@@ -64,6 +76,7 @@ namespace JUI
|
||||
void OnExit(const J3ML::LinearAlgebra::Vector2 &MousePos) override;
|
||||
void Update(float delta) override;
|
||||
void Draw() override;
|
||||
void InnerDraw() override;
|
||||
|
||||
protected:
|
||||
float minimum = 0;
|
||||
@@ -76,4 +89,12 @@ namespace JUI
|
||||
Color4 scrubber_color = Colors::White;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class VerticalSlider {
|
||||
public:
|
||||
protected:
|
||||
private:
|
||||
|
||||
};
|
||||
}
|
||||
|
9
main.cpp
9
main.cpp
@@ -345,8 +345,8 @@ JUI::Rect* CreateWidgetList(JUI::Widget* root) {
|
||||
}
|
||||
|
||||
auto* slider = new LabeledSlider(collapsible->ContentBox());
|
||||
slider->Size({100_percent, 30_px});
|
||||
slider->Position({0_px, 30_px});
|
||||
slider->Size({90_percent, 20_px});
|
||||
slider->Position({10_px, 50_px});
|
||||
slider->Content("Value: 0");
|
||||
slider->Minimum(-1.f);
|
||||
slider->Maximum(1.f);
|
||||
@@ -355,6 +355,11 @@ JUI::Rect* CreateWidgetList(JUI::Widget* root) {
|
||||
slider->ValueChanged += [slider](float value) mutable {
|
||||
slider->Content(std::format("Value: {}", value));
|
||||
};
|
||||
slider->CornerRounding(10);
|
||||
slider->ScrubberColor(Colors::Black);
|
||||
slider->ScrubberWidth(20);
|
||||
slider->SetClipsDescendants(true);
|
||||
slider->BGColor(Colors::Blues::DarkSlateBlue);
|
||||
|
||||
|
||||
|
||||
|
@@ -70,6 +70,7 @@ namespace JUI {
|
||||
corner_rounding_radius = radius;
|
||||
}
|
||||
|
||||
|
||||
float RectBase::CornerRounding() const { return corner_rounding_radius; }
|
||||
|
||||
|
||||
|
@@ -93,6 +93,34 @@ namespace JUI
|
||||
Rect::Update(delta);
|
||||
}
|
||||
|
||||
void Slider::InnerDraw() {
|
||||
Rect::InnerDraw();
|
||||
|
||||
Vector2 pos = {
|
||||
percentage * (GetAbsoluteSize().x - scrubber_width) + GetAbsolutePosition().x
|
||||
,GetAbsolutePosition().y
|
||||
};
|
||||
|
||||
/*
|
||||
Vector2 child_size_scale = this->Size().GetScale();
|
||||
Vector2 child_size_px = this->Size().GetPixels();
|
||||
|
||||
Vector2 parent_abs_size = this->GetParent()->GetAbsoluteSize();
|
||||
|
||||
Vector2 pad_size_reduction = GetAbsolutePaddingBottomRight();
|
||||
|
||||
Vector2 abs_size = child_size_px + (parent_abs_size * child_size_scale) - pad_size_reduction;
|
||||
*/
|
||||
|
||||
UDim scrub_width = UDim(scrubber_width, 0.f);
|
||||
float padding = 2;
|
||||
|
||||
float scrubber_abs_width = scrub_width.Pixels + (GetAbsoluteSize().x * scrub_width.Scale) - padding;
|
||||
|
||||
J2D::FillRoundedRect(scrubber_color, pos, {scrubber_abs_width, GetAbsoluteSize().y});
|
||||
|
||||
}
|
||||
|
||||
void Slider::Draw() {
|
||||
//scrubber->Draw();
|
||||
Rect::Draw();
|
||||
@@ -100,10 +128,17 @@ namespace JUI
|
||||
percentage * (GetAbsoluteSize().x - scrubber_width) + GetAbsolutePosition().x
|
||||
,GetAbsolutePosition().y
|
||||
};
|
||||
|
||||
float abs_vertical_center_of_rect = GetAbsolutePosition().y + (GetAbsoluteSize().y / 2.f);
|
||||
|
||||
enum RectType { NORMAL, ROUNDED, CHAMFERED };
|
||||
|
||||
|
||||
/// TODO: Implement internal padding on scrubber element?
|
||||
//J2D::Begin();
|
||||
JGL::J2D::FillRect(scrubber_color, pos, {scrubber_width, GetAbsoluteSize().y});
|
||||
//JGL::J2D::FillRect(scrubber_color, pos, {scrubber_width, GetAbsoluteSize().y});
|
||||
//J2D::End();
|
||||
|
||||
}
|
||||
|
||||
float Slider::Minimum() const { return minimum; }
|
||||
|
Reference in New Issue
Block a user