Hit a wall
This commit is contained in:
@@ -30,6 +30,11 @@ endif()
|
||||
|
||||
set_target_properties(JUI PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Event
|
||||
URL https://git.redacted.cc/josh/Event/archive/Release-6.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME J3ML
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Release-2.2.zip
|
||||
@@ -40,17 +45,26 @@ CPMAddPackage(
|
||||
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-12.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ReWindow
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-3.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME JGL
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-20.zip
|
||||
)
|
||||
|
||||
target_include_directories(JUI PUBLIC ${Event_SOURCE_DIR}/include)
|
||||
target_include_directories(JUI PUBLIC ${J3ML_SOURCE_DIR}/include)
|
||||
target_include_directories(JUI PUBLIC ${jlog_SOURCE_DIR}/include)
|
||||
target_include_directories(JUI PUBLIC ${JGL_SOURCE_DIR}/include)
|
||||
target_include_directories(JUI PUBLIC ${ReWindow_SOURCE_DIR}/include)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})
|
||||
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)
|
@@ -1,8 +1,16 @@
|
||||
#pragma once
|
||||
#include <JUI/Widget.hpp>
|
||||
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
|
||||
// TODO: SceneSizingBehavior - FillToWindow, CustomSized
|
||||
class Scene : public Widget {
|
||||
public:
|
||||
Scene();
|
||||
~Scene() override {}
|
||||
void Draw() override;
|
||||
void Update(float delta) override;
|
||||
};
|
||||
}
|
@@ -1,8 +1,64 @@
|
||||
//
|
||||
// Created by dawsh on 7/10/24.
|
||||
//
|
||||
#pragma once
|
||||
#include <Event.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <JUI/UDim2.hpp>
|
||||
|
||||
#ifndef WIDGET_HPP
|
||||
#define WIDGET_HPP
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
#endif //WIDGET_HPP
|
||||
class Widget
|
||||
{
|
||||
public:
|
||||
Widget();
|
||||
Widget(Widget* parent);
|
||||
virtual ~Widget() {}
|
||||
public:
|
||||
Event<> Focused;
|
||||
Event<> Unfocused;
|
||||
Event<Widget *> DescendantAdded;
|
||||
Event<Widget *> DescendantRemoved;
|
||||
Event<Widget *, Widget*> AncestryChanged;
|
||||
Event<Widget *> ChildAdded;
|
||||
Event<Widget *> ChildRemoved;
|
||||
Event<Widget *> Destroying;
|
||||
public:
|
||||
Widget* Add(Widget* newChild);
|
||||
bool IsAncestorOf(Widget* w) const;
|
||||
bool IsDescendantOf(Widget* w) const;
|
||||
Widget* FindFirstChild(const std::string& name);
|
||||
std::vector<Widget*> GetDescendants();
|
||||
std::vector<Widget*> GetAncestors();
|
||||
std::vector<Widget*> GetChildren();
|
||||
virtual Vector2 GetAbsoluteSize() const;
|
||||
virtual Vector2 GetAbsolutePosition() const;
|
||||
virtual float GetAbsoluteRotation() const;
|
||||
Widget* GetParent() const;
|
||||
|
||||
public:
|
||||
virtual void Draw();
|
||||
virtual void Update(float delta);
|
||||
Widget* GetFamilyTreeRoot() const;
|
||||
protected:
|
||||
UDim2 position;
|
||||
UDim2 size;
|
||||
Widget* parent = nullptr;
|
||||
std::vector<Widget*> children;
|
||||
float rotation = 0;
|
||||
std::string name;
|
||||
bool selected = false;
|
||||
UDim pad_left = 0_px;
|
||||
UDim pad_right = 0_px;
|
||||
UDim pad_top = 0_px;
|
||||
UDim pad_bottom = 0_px;
|
||||
UDim margin_left = 0_px;
|
||||
UDim margin_right = 0_px;
|
||||
UDim margin_top = 0_px;
|
||||
UDim margin_bottom = 0_px;
|
||||
Vector2 anchor_point = {0.f, 0.f};
|
||||
bool visible = true;
|
||||
Widget* next = nullptr;
|
||||
Widget* prev = nullptr;
|
||||
};
|
||||
}
|
||||
|
69
main.cpp
69
main.cpp
@@ -1,7 +1,76 @@
|
||||
/// Josh's User Interface Library
|
||||
/// A C++20 Library for creating, styling, and rendering of a UI/UX widgets.
|
||||
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
|
||||
/// Special Thanks to William Tomasine II and Maxine Hayes.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file main.cpp
|
||||
/// @desc Demo Program Entry Point
|
||||
/// @edit 2024-07-11
|
||||
|
||||
#include <iostream>
|
||||
#include <JGL/JGL.h>
|
||||
#include <JUI/Scene.hpp>
|
||||
#include <rewindow/types/window.h>
|
||||
|
||||
|
||||
class JUIDevelopmentTestWindow : public ReWindow::RWindow {
|
||||
public:
|
||||
JUIDevelopmentTestWindow(const std::string& title, int w, int h) : ReWindow::RWindow(title, w, h) {}
|
||||
void OnRefresh(float elapsed) override {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
JGL::J2D::Begin();
|
||||
JGL::J2D::FillRect(JGL::Color3(255,0,0), {0,0}, {50, 50});
|
||||
JGL::J2D::End();
|
||||
glSwapBuffers();
|
||||
}
|
||||
|
||||
bool OnResizeRequest(const ReWindow::WindowResizeRequestEvent &e) override {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
auto* window = new JUIDevelopmentTestWindow("Test Window", 600, 480);
|
||||
|
||||
|
||||
|
||||
window->setRenderer(RenderingAPI::OPENGL);
|
||||
|
||||
|
||||
|
||||
window->Open();
|
||||
|
||||
gladLoadGL();
|
||||
JGL::InitTextEngine();
|
||||
|
||||
|
||||
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glViewport(0,0,600,480);
|
||||
|
||||
|
||||
|
||||
|
||||
window->setFullscreen(false);
|
||||
window->setVsyncEnabled(false);
|
||||
window->setResizable(true);
|
||||
|
||||
|
||||
|
||||
|
||||
while (window->isAlive()) {
|
||||
window->pollEvents();
|
||||
window->refresh();
|
||||
}
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
1
src/JUI/Scene.cpp
Normal file
1
src/JUI/Scene.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <JUI/Scene.hpp>
|
1
src/JUI/Widget.cpp
Normal file
1
src/JUI/Widget.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <JUI/Widget.hpp>
|
Reference in New Issue
Block a user