Giter Site home page Giter Site logo

mfkiwl / octanegui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdavisprog/octanegui

0.0 1.0 0.0 1.52 MB

OctaneGUI is a renderer agnostic multi-window multi-platform UI library for C++.

License: MIT License

Shell 0.52% C++ 95.33% C 0.46% Objective-C++ 1.93% CMake 1.11% Batchfile 0.64%

octanegui's Introduction

OctaneGUI

Latest update: August 2022

Inspector

Designer

Overview

OctaneGUI is a renderer agnostic multi-window multi-platform UI library for C++. The main goal of this library is to easily create applications that is performant on all devices. It is architected in a way to allow for easy integration to other frameworks that may have its own rendering pipeline. This project will provide multiple integrations to widely used windowing and rendering libraries such as SDL, SFML, OpenGL, and Metal among others.

OctaneGUI uses an event-driven paradigm for the UI system. The application and all of its controls and layouts can be defined through a JSON string. The C++ code can then register events for controls defined in the JSON string through IDs. Below is an example of a Hello World application with a button for user interaction.

#include "Interface.h"
#include "OctaneGUI/OctaneGUI.h"

int main(int argc, char** argv)
{
	const char* Stream = R"({
	"Theme": "./Themes/Dark.json",
	"Windows": {
		"Main": {"Title": "Hello", "Width": 300, "Height": 200, "Body": {"Controls": [
			{"ID": "Container", "Type": "VerticalContainer", "Controls": [
				{"ID": "Button", "Type": "TextButton", "Text": {"Text": "Hello Friends"}}
			]}
		]}}
	}
})";

	OctaneGUI::Application Application;
	Interface::Initialize(Application);

	std::unordered_map<std::string, OctaneGUI::ControlList> WindowControls;
	Application.Initialize(Stream, WindowControls);

	const OctaneGUI::ControlList& List = WindowControls["Main"];
	List.To<OctaneGUI::Button>("Container.Button")->SetOnClicked([&](const OctaneGUI::Button&) -> void
	{
		static bool DidClick = false;
		if (!DidClick)
		{
			List.To<OctaneGUI::Container>("Container")->AddControl<OctaneGUI::Text>()->SetText("Welcome to the program :^)!");
			DidClick = true;
		}
	});

	return Application.Run();
}

Hello Sample

Support

The following tables displays what platforms are supported and which windowing and rendering libraries can be used for each platform. This information is for users who wish to build the applications in this repository.

Windowing

Platform SDL2 SFML
Windows X X
MacOS X
Linux X X

Rendering

Platform Metal OpenGL SFML
Windows X X
MacOS X
Linux X X

Build

Below are instructions for how to build this project out of the repository itself or integrate it into other projects.

Prerequisites

Before beginning the process of building the project, some tools will be needed. Below is a list of the tools that will need to be installed:

  • CMake - This is a tool that helps with generating projects. It is a common tool used for many open source projects.
  • Compiler - A C++ compiler is needed to compile the library and its apps. This is platform specific and the compiler for each platform is listed below.
    • Visual Studio - This is the compiler used on Windows. A Community version is offered for free which provides the compiler along with the IDE. The IDE is not required as the build scripts will find the proper tools needed to compile.
      • Visual Studio Build Tools - This is a download offered that will only install the compiler and other tools needed to compile the project without the IDE.
    • GCC - This is the compiler used on Linux. Please refer to your Linux distribution for proper instructions on how to install these tools.
    • XCode - This project has used 'Command Line Tools for Xcode' to build on Macs.
  • (Optional) Ninja - This is a light-weight build system that is supported on all platforms. If this is not used, then 'msbuild'/Visual Studio is used on Windows and 'Make' is used on other platforms.
  • An installation of either the SDL2 or SFML development libraries.

Scripts

The repository provides shell scripts and batch files to make building the project and its applications easier. These files can be found in the 'Scripts' folder. The 'Build' script is the main script to run when building this project. This can be run from any directory and accpets a number of arguments. Below is the list of arguments and a desription for each:

  • release - Sets the configuration to Release. The default is Debug.
  • tools - Compiles with tools enabled. This can be compiled in any configuration.
  • ninja - Use the ninja build system instead of the default (make or msbuild). The path to the ninja build system must be added to the PATH environment variable.
  • clean - Cleans the intermediate files before generating and building. This forces a full rebuild of the project.
  • noapps - Only compiles the library.
  • sfml - Builds the apps using the SFML library. The SFML_DIR variable must be set for the generator to locate the library.
  • sdl2 - Builds the app using the SDL library. The SDL2 cmake and library paths must be locatable by the generator through either the environment variables or the SDL2_DIR and SDL2_MODULE_PATH variables.
  • help - Displays this help message.

On Windows, a VCVars.bat file is called which will load Visual Studio tools into the current environment. This will attempt to load Visual Studio 2019 first, then 2017. More versions of Visual Studio will be added in the future.

The path to CMake/Ninja will need to be set in the PATH environment variable on your system. This may be set during the installation of these tools. The PATH can also be set in your own script before calling the 'Build' script. Below are example scripts that can be used to build the project.

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

SET PATH=%PATH%;"PATH\TO\CMake\bin\"
SET PATH=%PATH%;"PATH\TO\Ninja\"
SET SFML_DIR=PATH\TO\SFML\lib\cmake\SFML
SET SDL2_MODULE_PATH="PATH\TO\SDL2\cmake"
SET SDL2_DIR="PATH\TO\SDL2"

CALL Scripts\Build.bat %*

ENDLOCAL
#!/bin/bash
PATH="$PATH:/PATH/TO/CMake/bin:/PATH/TO/Ninja"
source Scripts/Build.sh

Integration

TODO

octanegui's People

Contributors

mdavisprog avatar thnom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.