Building ColorPicker Widget, got stuck on mcolor error.

This commit is contained in:
2025-04-22 02:46:32 -05:00
parent e71ab30c23
commit e8491e9007
2 changed files with 58 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ CPMAddPackage(NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-17.zip)
CPMAddPackage(NAME mcolor
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-6.2.zip)
URL https://git.redacted.cc/maxine/mcolor/archive/Prerelease-7.zip)
CPMAddPackage(NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-12.zip)

View File

@@ -2,12 +2,12 @@
#include <JGL/logger/logger.h>
#include <ReWindow/types/Window.h>
#include <JUI/Widgets/Scene.hpp>
#include <JUI/Widgets/Slider.hpp>
#include <JUI/Widgets/Window.hpp>
#include "JUI/Widgets/CommandLine.hpp"
#include "JGL/types/Shader.h"
#include <ReWindow/Logger.h>
std::vector<std::string> string_expand(const std::string& input, char delimiter = ' ');
@@ -35,6 +35,59 @@ std::vector<std::string> string_expand(const std::string& input, char delimiter)
}
using namespace JUI::UDimLiterals;
/// A JUI Widget that displays a HSV color input dialog.
class ColorPicker : public JUI::Rect {
public:
JUI::Slider* hue_slider;
JUI::Slider* sat_slider;
JUI::Slider* bri_slider;
JUI::Text* hue_label;
JUI::TextRect* sat_label;
JUI::TextRect* bri_label;
JUI::TextRect* hex_label;
ColorPicker() : Rect() {
Size({100_percent, 100_percent});
auto* row_layout = new JUI::VerticalListLayout(this);
row_layout->Padding(5_px);
hue_slider = new JUI::Slider(row_layout);
hue_slider->Size({100_percent, 28_px});
hue_slider->Minimum(0.f); hue_slider->Maximum(1.f);
hue_slider->Interval(1e-3f);
hue_slider->ValueChanged += [this] (float val) mutable {
hue_label->SetContent(std::format("Hue: {}", Math::FloorInt(val*255)));
hue_slider->ScrubberColor(Color4(HSV{val*255, 255, 255}));
};
hue_label = new JUI::Text(hue_slider);
hue_label->AlignCenterHorizontally();
hue_label->AlignTop();
hue_label->SetTextColor(Colors::Black);
hue_label->SetContent("Hue: 255");
sat_slider = new JUI::Slider(row_layout);
sat_slider->Size({100_percent, 28_px});
sat_slider->Minimum(0); sat_slider->Maximum(1);
bri_slider = new JUI::Slider(row_layout);
bri_slider->Size({100_percent, 28_px});
auto* hue_box = new JUI::Rect();
}
explicit ColorPicker(Widget* parent) : ColorPicker() {
Parent(parent);
}
protected:
private:
};
class ReShaderProgram : public ReWindow::OpenGLWindow {
public:
JUI::Scene *scene;
@@ -100,7 +153,9 @@ public:
wind->SetTitle("ReShader");
wind->MinSize({100, 100});
wind->Size({200_px, 100_px});
wind->Close();
//wind->Close();
ColorPicker* pp = new ColorPicker(wind->ViewportInstance());
console = new JUI::CommandLine(scene);
console->MinSize(Vector2(200, 200));