9 Commits

24 changed files with 110 additions and 53 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.18..3.28)
cmake_minimum_required(VERSION 3.18..3.27)
project(JUI
VERSION 1.1
LANGUAGES CXX)
@@ -33,12 +33,12 @@ set_target_properties(JUI PROPERTIES LINKER_LANGUAGE CXX)
CPMAddPackage(
NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-6.zip
URL https://git.redacted.cc/josh/Event/archive/Release-10.zip
)
CPMAddPackage(
NAME J3ML
URL https://git.redacted.cc/josh/j3ml/archive/Release-2.2.zip
URL https://git.redacted.cc/josh/j3ml/archive/Release-3.1.zip
)
CPMAddPackage(
@@ -48,12 +48,12 @@ CPMAddPackage(
CPMAddPackage(
NAME ReWindow
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-8.zip
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-13.zip
)
CPMAddPackage(
NAME JGL
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-29.zip
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-32.zip
)
target_include_directories(JUI PUBLIC ${Event_SOURCE_DIR}/include)
@@ -68,4 +68,4 @@ install(FILES ${JUI_HEADERS} DESTINATION include/${PROJECT_NAME})
target_link_libraries(JUI PUBLIC Event J3ML jlog ReWindowLibrary JGL)
add_executable(RedactedJUIDemo main.cpp)
target_link_libraries(RedactedJUIDemo PUBLIC JUI)
target_link_libraries(RedactedJUIDemo PUBLIC JUI)

56
README.md Normal file
View File

@@ -0,0 +1,56 @@
# Josh User Interface
![Static Badge](https://img.shields.io/badge/Lit-Based-%20)
Fourth Time's The Charm! (tm)
JUI is a C++20 Library for building interactive menus in OpenGL / Redacted3D.
It is expressly built with our Redacted3D engine in mind, but steps have been taken to support OpenGL generally.
## Abstract
JUI provides a set of objects that we term Widgets. Widgets can be styled and laid out on-screen in relation to each other. Each widget has a single parent, and a list of child elements. Your root widget should be a Scene object.
Provided widgets include Scene, Rect, Text, TextRect, Button, TextButton, TextInputForms, Slider, Image, ImageRect, RadioButton
## Features
### Why use this instead of imgui?
## Usage
## Examples
![JUI First Showcase](showcase.png)
Browse the src/Demos directories for examples of building and interacting with things in JUI.
## Documentation
Documentation is automatically generated from latest commit and is hosted at https://doc.redacted.cc/jui .
## Contributing
Contributions to JUI are welcome! Feel free to file bug reports or feature requests by creating an Issue. Pull requests are also very welcome!
## History
JUI started out as my menu toolkit for the LOVE2D framework many years ago. Between then and now I had re-implemented it twice, once for MonoGame Framework, and again in C++ for SDL2. Legacy versions are listed below.
JUI v1 - LOVE2D / Lua
JUI v2 - MonoGame / C#
JUI v3 - SDL2 / C++
## License
JUI is expressly released without a license, under no restrictions. We dedicate all of our works to the public domain for the (hopeful) betterment of humanity.
## Acknowledgements
JUI is developed and maintained by Joshua O'Leary from Redacted Software Group, and all the wonderful contributors.

View File

@@ -12,8 +12,8 @@
#pragma once
#include <Color4.hpp>
#include <J3ML/LinearAlgebra/Vector2.h>
#include "JGL/Texture.h"
#include <J3ML/LinearAlgebra/Vector2.hpp>
#include <JGL/types/Texture.h>
using J3ML::LinearAlgebra::Vector2;

View File

@@ -11,8 +11,9 @@
#pragma once
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra.hpp>
#include <Event.h>
#include <EventConnection.h>
#include <Color4.hpp>
namespace JUI

View File

@@ -1,8 +1,8 @@
#pragma once
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra.hpp>
#include <Color4.hpp>
#include <JGL/Font.h>
#include <JGL/types/Font.h>
using J3ML::LinearAlgebra::Vector2;

View File

@@ -11,10 +11,11 @@
#pragma once
#include "Event.h"
#include <Event.h>
#include <EventConnection.h>
#include <string>
#include <vector>
#include "J3ML/LinearAlgebra.h"
#include "J3ML/LinearAlgebra.hpp"
#include "JUI/UDim2.hpp"
#include <Color3.hpp>
#include <Color4.hpp>

View File

View File

View File

View File

View File

@@ -12,7 +12,7 @@
#pragma once
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra.hpp>
#include <JUI/UDim.hpp>
namespace JUI

View File

@@ -6,9 +6,8 @@
/// This work is dedicated to the public domain.
/// @file GridLayout.hpp
/// @desc Clickable Button widget.
/// @edit 2024-08-02
/// @desc Lays out child elements in a grid-matrix.
/// @edit 2024-08-05
#pragma once
@@ -16,21 +15,9 @@
namespace JUI
{
class ListLayout : public LayoutContainer
class GridLayout : public LayoutContainer
{
public:
};
class VerticalListLayout : public ListLayout
{
public:
};
class HorizontalListLayout : public ListLayout
{
};
}

View File

@@ -1,7 +1,6 @@
#pragma once
#include <JUI/Base/Widget.hpp>
namespace JUI
{
// TODO: SceneSizingBehavior - FillToWindow, CustomSized
@@ -12,12 +11,8 @@ namespace JUI
void Draw() override;
void SetViewportSize(int w, int h);
// TODO: Interface for passing input to JUI in a relatively
// independent way
Event<Vector2> MouseMoved;
void Update(float delta) override;
[[nodiscard]] Vector2 GetAbsolutePosition() const override;

View File

@@ -11,7 +11,7 @@
#pragma once
#include <J3ML/LinearAlgebra.h>
#include <J3ML/LinearAlgebra.hpp>
#include <JUI/Base/Widget.hpp>
#include <JUI/Base/RectBase.hpp>

View File

@@ -20,7 +20,7 @@
#include <JUI/Widgets/TextRect.hpp>
#include <JUI/Widgets/Image.hpp>
#include <rewindow/types/window.h>
#include <jlog/jlog.hpp>
#include <jlog/Logger.hpp>
JGL::Font FreeSans;
JUI::Scene* scene;
@@ -31,7 +31,6 @@ JUI::Scene* CreateScene() {
Scene *root = new Scene();
auto* JUI = new TextRect(root);
JUI->SetFont(FreeSans);
JUI->SetTextSize(48);
@@ -133,7 +132,6 @@ JUI::Scene* CreateScene() {
// End Window //
auto list = new VerticalListLayout(win_element->GetViewportInstance());
list->SetPadding(10_px);
@@ -176,7 +174,7 @@ JUI::Scene* CreateScene() {
text->SetTextSize(48);
text->SetTextColor({255, 0, 0});
auto darkie = new Image(root, sample_texture);
auto darkie = new Image(win_element->GetViewportInstance(), sample_texture);
darkie->FitImageToParent(true);
darkie->Color({255,255,255,128});
@@ -236,7 +234,7 @@ public:
int main()
{
using namespace ReWindow;
//LOGLEVEL(jlog::severity::none)
// TODO: Find out new jlog api for silencing specific loggers.
auto* window = new JUIDevelopmentTestWindow("Test Window", 800, 600);
window->setRenderer(RenderingAPI::OPENGL);
@@ -248,7 +246,6 @@ int main()
JGL::Update({800, 600});
FreeSans = JGL::Font("assets/fonts/FreeSans.ttf");
sample_texture = new JGL::Texture("assets/ld.png");
scene = CreateScene();

BIN
showcase.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@@ -7,7 +7,8 @@ namespace JUI
{
void ImageBase::Draw(const Vector2 &pos, const Vector2 &size) {
J2D::Begin();
J2D::DrawSprite(*texture, pos, origin, scale, image_color);
// TODO: Support image rotation in the widget.
J2D::DrawSprite(*texture, pos, 0, origin, scale, image_color);
J2D::End();
}

View File

@@ -1,5 +1,5 @@
#include "JUI/Base/Widget.hpp"
#include "jlog/jlog.hpp"
#include <jlog/Logger.hpp>
namespace JUI {
@@ -149,7 +149,7 @@ namespace JUI {
void Widget::SetSize(const UDim2& s) { size = s; }
float Widget::GetAbsoluteRotation() const {
// TODO: implement correctly!!
// TODO: implement rotation correctly!!
return rotation;
}
@@ -326,10 +326,8 @@ namespace JUI {
return newChild;
}
void Widget::SetAnchorPoint(const Vector2& point) {
anchor_point = point;
}
}

View File

@@ -1,6 +1,6 @@
#include "JGL/JGL.h"
#include <JUI/Widgets/Button.hpp>
#include <jlog/jlog.hpp>
#include <jlog/Logger.hpp>
namespace JUI
{

View File

@@ -0,0 +1,7 @@
#include <JUI/Widgets/GridLayout.hpp>
namespace JUI
{
}

View File

@@ -1,6 +1,6 @@
#include "JGL/JGL.h"
#include "JUI/Widgets/Rect.hpp"
#include "jlog/jlog.hpp"
#include <jlog/Logger.hpp>
namespace JUI {
Rect::Rect(): Widget(), RectBase() {}

View File

@@ -0,0 +1,7 @@
#include <JUI/Widgets/ScrollingRect.hpp>
namespace JUI
{
}

View File

@@ -0,0 +1,7 @@
#include <JUI/Widgets/Slider.hpp>
namespace JUI
{
}

View File

@@ -1,5 +1,5 @@
#include "JUI/Widgets/Window.hpp"
#include "jlog/jlog.hpp"
#include <jlog/Logger.hpp>
#include <cstdlib>
@@ -89,8 +89,8 @@ namespace JUI
this->SetVisible(false);
};
DEBUG(std::format("{} {} {} {}", Topbar->Size().X.Pixels, Topbar->Size().Y.Pixels, Topbar->Size().X.Scale,
Topbar->Size().Y.Scale))
jlog::Debug(std::format("{} {} {} {}", Topbar->Size().X.Pixels, Topbar->Size().Y.Pixels, Topbar->Size().X.Scale,
Topbar->Size().Y.Scale));
//min_size = exit_btn->GetSize() + Topbar->GetSize() + TitleLabel->Size();
//= Topbar->GetSize();//+ exit_btn->Size();
// TODO: fs_btn
@@ -160,7 +160,7 @@ namespace JUI
void Window::Update(float delta) {
if (dragging) {
DEBUG(std::format("mpos {} {}", last_known_mouse_pos.x, last_known_mouse_pos.y));
jlog::Debug(std::format("mpos {} {}", last_known_mouse_pos.x, last_known_mouse_pos.y));
Vector2 mpos = last_known_mouse_pos - initial_drag_offset;
this->SetPosition(UDim2{(int)mpos.x, (int)mpos.y, 0,0});
}