Getting started

Yue is a bundle of libraries that can be used to create cross platform GUI programs, currently it includes:

Please note that there is no documentation on the base library, you have to read the header files on how to use it.

Documentation of nativeui library is part of this site.

The base library

Though the base library is undocumented, there are few guides to help you learn it:

It is strongly recommended to read all of the guides before using nativeui.

A minimal GUI program using nativeui library

#include "base/command_line.h"
#include "nativeui/nativeui.h"

#if defined(OS_WIN)
int WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
  base::CommandLine::Init(0, nullptr);
#else
int main(int argc, const char *argv[]) {
  base::CommandLine::Init(argc, argv);
#endif

  // Initialize the global instance of nativeui.
  nu::State state;

  // Create GUI message loop.
  nu::Lifetime lifetime;

  // Create window with default options, and then show it.
  scoped_refptr<nu::Window> window(new nu::Window(nu::Window::Options()));
  window->SetContentView(new nu::Label("Hello world"));
  window->SetContentSize(nu::SizeF(400, 400));
  window->Center();
  window->Activate();

  // Quit when window is closed.
  window->on_close.Connect([](nu::Window*) {
    nu::Lifetime::GetCurrent()->Quit();
  });

  // Enter message loop.
  lifetime.Run();

  return 0;
}

Building the program with prebuilt static library

There is no assumption on which build system you should use, to use Yue, you can download the libyue_VERSION_PLATFORM_ARCH.zip archive from the Releases page, which includes header files and prebuilt static libraries of Yue.

The libyue zip archive includes following files:

If you are interested in integrating Yue into a build system, you can look into the CMakeLists.txt on which compilation options should be used.

Quick start with CMake

CMake can generate projects according to your preferences, this is a quick start tutorial if you are too lazy to learn CMake.

  1. Download CMake.

  2. Enter the directory of libyue and create a build sub-directory for building.

     cd libyue_VERSION_PLATFORM_ARCH
     mkdir build
     cd build
    
  3. Generate project and then build.

    macOS

    cmake .. -G Xcode
    open YueSampleApp.xcodeproj
    

    Linux

    cmake -D CMAKE_BUILD_TYPE=Release ..
    make
    ./sample_app
    

    Windows

    Note that on Windows you need to manually speicfy the version of Visual Studio and the architecture to build for.

    cmake .. -G "Visual Studio 14 Win64"
    start YueSampleApp.sln
    

    For certain versions of Visual Studio you also need to manually set the "sample_app" as startup project.