Compare commits
11 Commits
Prerelease
...
Prerelease
Author | SHA1 | Date | |
---|---|---|---|
cfce294bf2 | |||
48aaff669e | |||
00818e4656 | |||
fb5831caae | |||
2a9d095203 | |||
411f06aad0 | |||
e147c7c881 | |||
0a1d698a9d | |||
7fb63db263 | |||
9a281ca9a5 | |||
ae69bd8c5b |
@@ -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,27 +33,27 @@ 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-12.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.2.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME jlog
|
||||
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-12.zip
|
||||
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-16.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ReWindow
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-8.zip
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-21.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME JGL
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-29.zip
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-35.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
56
README.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Josh User Interface
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
|
||||
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.
|
@@ -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;
|
||||
|
||||
|
@@ -11,8 +11,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <Event.h>
|
||||
|
||||
#include <Color4.hpp>
|
||||
|
||||
namespace JUI
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -11,10 +11,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Event.h"
|
||||
#include <Event.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "J3ML/LinearAlgebra.h"
|
||||
#include "J3ML/LinearAlgebra.hpp"
|
||||
#include "JUI/UDim2.hpp"
|
||||
#include <Color3.hpp>
|
||||
#include <Color4.hpp>
|
||||
|
0
include/JUI/Mixins/Clickable.hpp
Normal file
0
include/JUI/Mixins/Clickable.hpp
Normal file
0
include/JUI/Mixins/Dockable.hpp
Normal file
0
include/JUI/Mixins/Dockable.hpp
Normal file
0
include/JUI/Mixins/Draggable.hpp
Normal file
0
include/JUI/Mixins/Draggable.hpp
Normal file
0
include/JUI/Mixins/Hoverable.hpp
Normal file
0
include/JUI/Mixins/Hoverable.hpp
Normal file
@@ -12,7 +12,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <JUI/UDim.hpp>
|
||||
|
||||
namespace JUI
|
||||
|
@@ -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
|
||||
{
|
||||
|
||||
};
|
||||
}
|
@@ -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;
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <JUI/Base/Widget.hpp>
|
||||
|
||||
#include <JUI/Base/RectBase.hpp>
|
||||
|
24
main.cpp
24
main.cpp
@@ -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 JUI::Image(win_element->GetViewportInstance(), sample_texture);
|
||||
darkie->FitImageToParent(true);
|
||||
darkie->Color({255,255,255,128});
|
||||
|
||||
@@ -228,6 +226,21 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnMouseButtonUp(const ReWindow::WindowEvents::MouseButtonUpEvent &) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnMouseButtonDown(const ReWindow::WindowEvents::MouseButtonDownEvent &) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnMouseMove(const ReWindow::WindowEvents::MouseMoveEvent &) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//bool OnResizeRequest(const ReWindow::WindowResizeRequestEvent &e) override {}
|
||||
JUIDevelopmentTestWindow() : ReWindow::RWindow() {}
|
||||
};
|
||||
@@ -236,7 +249,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 +261,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
BIN
showcase.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "JGL/JGL.h"
|
||||
#include <JUI/Widgets/Button.hpp>
|
||||
#include <jlog/jlog.hpp>
|
||||
#include <jlog/Logger.hpp>
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
7
src/JUI/Widgets/GridLayout.cpp
Normal file
7
src/JUI/Widgets/GridLayout.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <JUI/Widgets/GridLayout.hpp>
|
||||
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
}
|
@@ -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() {}
|
||||
|
7
src/JUI/Widgets/ScrollingRect.cpp
Normal file
7
src/JUI/Widgets/ScrollingRect.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <JUI/Widgets/ScrollingRect.hpp>
|
||||
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
}
|
7
src/JUI/Widgets/Slider.cpp
Normal file
7
src/JUI/Widgets/Slider.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <JUI/Widgets/Slider.hpp>
|
||||
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
}
|
@@ -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});
|
||||
}
|
||||
|
Reference in New Issue
Block a user