Giter VIP home page Giter VIP logo

cgui's Introduction

CGui(Beta)

Open Source Library for C++ UI based on GTK 3

Requirments

  • Window 7, 8.1, 10 or Linux distribution
  • GTK+ 3.22 or later
  • gcc on Linux or MSVC on Window
  • Git

For further more experience use the C++ standard 17 or later.

Tested on

  • Windows 10 with Visual Studio 2019
  • Ubuntu 18.02 LTS, and Ubuntu 20.04 LTS

Installation

Windows with visual studio

Install gtk on windows with vcpkg

Clone this repository

git clone https://github.com/Developmentprogramming/CGui.git
  1. Open the visual studio and create a new cpp empty console project(CGui).
  2. Copy the cloned repository to the cpp empty console project(CGui) except Makefile, Main.cc, Examples/, Image/ Readme.md.
  3. Right click cpp empty console project(CGui)->Properties->Configuration Properties->General->Configuration Type and select Static library.
  4. Create a new cpp empty console project2(your_project_name).
  5. Add a reference of cpp empty console project(CGui) to cpp empty console project2(your_project_name).
  6. Right click cpp empty console project2(your_project_name)->Properties->Configuration Properties->C/C++->General->Additional include directories and add the path of cpp empty console project(CGui).

Linux

Install dependencies for CGui

sudo apt-get install g++-8 libgtk-3-dev git make

Clone this repository

git clone https://github.com/Developmentprogramming/CGui.git

Start the installtion process

cd CGui/Installer/bin
chmod +x ./Installer
./Installer

Installer
Now choose the path where you want to install, and check the Universal Access to get access of this library from any where on your system.
And at last click on install and wait until it finsihes.
Note: This installer itself is made using this library(CGui).

If you want to install in Preferred Path location then you must run this installer with root access, and if you want to install it in the Current Path location or any other user's location then no need for root access.

Precompiling headers(Only for development purpose)

git clone https://github.com/Developmentprogramming/CGui.git
cd CGui
make -i PrecompiledHeaders

Compilation

For compile any file, use the following command line:

g++-8 -std=c++17 file.cc `pkg-config gtk+-3.0 --cflags --libs`
  1. Change the file.cc with your cpp file.
  2. g++-8 for g++ 8th generation compiler
  3. -std=c++17 for c++ standard version 17
  4. `pkg-config gtk+-3.0 --cflags --libs` for invoking all the GTK+ files

Compile the test file and run it(Only for testing the CGui is working):

g++-8 -std=c++17 Main.cc -o Main `pkg-config gtk+-3.0 --cflags --libs`
./Main

Result:
MainResult

If you see this message Welcome to CGui.
Congratulations!!!, it's working... .

Code Structure

// Label example
#include <CGUI.hh>

using namespace CGui;

int main(int argc, char *argv[])
{
  Init init(argc, argv); // Initialize CGui
  
  // Some code
  Window window(WindowType::TOPLEVEL, "CGUI WINDOW", WindowPos::CENTER); // Create a new Window
  
  Label label("Text");
  label.Align(Alignments::CENTER, Alignments::CENTER); // align the label to center horizontally and vertically
  
  window.Add(label); // add label to window
  window.DefaultSize(640, 480); // window default size
  window.InternalWidth(10); // Internal window width
  window.ShowAll(); // Show all widgets
  
  init.Render(); // Start the main loop

  return 0;
}

Result:-
ExampleOne

//Image Example
#include <CGUI.hh>

using namespace CGui;

int main(int argc, char *argv[])
{
  Init init(argc, argv); // Initialize CGui
  
  // Some Code
  Window window(WindowType::TOPLEVEL, "CGUI WINDOW", WindowPos::CEN); // Create a new Window
  
  Pixbuf pixbuf("./Image/yaktocat.png", 400, 400);
  Image image(pixbuf); // create a new image of size of 400X400
  image.Align(Alignments::CENTER, Alignments::CENTER); // align the image to center horizontally and vertically
  
  window.Add(image); // add image to window
  window.DefaultSize(640, 480); // window default size
  window.InternalWidth(10); // Internal window width
  window.ShowAll(); // Show all widgets 
  
  init.Render(); // Start the main loop
  
  return 0;
}

Result:-
ExampleTwo

// Button example
#include <CGUI.hh>
#include <iostream>

using namespace CGui;

static void Button_Clicked()
{
  std::cout << "Hello World" << std::endl;
}

int main(int argc, char *argv[])
{
  Init init(argc, argv); // Initialize CGui
  
  // Some Code
  Window window(WindowType::TOPLEVEL, "CGUI WINDOW", WindowPos::CENTER); // Create a new Window
  
  Button button("Button"); // Create a new button
  button.Align(Alignments::CENTER, Alignments::CENTER); // align button to center horizontally and vertically
  button.Clicked(Button_Clicked);
  
  window.Add(button); // add button to window
  window.DefaultSize(640, 480); // window default size
  window.InternalWidth(10); // Internal window width
  window.ShowAll(); // Show all widgets
  
  init.Render(); // Start the main loop
  
  return 0;
}

Result:-
ExampleThree
On Button clicked:-
ExampleThreeButtonClicked

Contribution

Email: [email protected]

Developer Info

Name: Parth Lodhia
Age: 17
Email: [email protected]

cgui's People

Contributors

htrap19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

linecode madankal

cgui's Issues

Failed to build on MSYS2 MINGW64

I edited makefile to change g++-8 to g++. There are too many errors so I can't posted here. Btw, when it comes to GTK3 then MSYS2 is a more native environment than MSVC. It seems your project only supports MSVC.

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.