Skip to content

knobin/ptk

Repository files navigation

pTK

C++ library for building user interfaces.

Very early work in progress project.

Usage

Small sample application:

#include "ptk/ptk.hpp"

int main(int argc, char *argv[]) {
    pTK::Application app{"Sample Application", argc, argv};
    pTK::Window window{"Sample Window", {960, 540}};

    std::shared_ptr<pTK::Label> label = std::make_shared<pTK::Label>();
    label->setText("Sample Label");
    window.add(label);
    
    return app.exec(&window);
}

For more sample applications see:

Build

Start by cloning the repository:

$ git clone --recursive https://github.com/knobin/ptk.git

Next follow the instructions to build Skia in the Building Skia section.

After building skia go to the main ptk directory and create a build directory.

$ mkdir build

Then use cmake to build the project.

Example below is a Release build with unix makefiles.

$ cd build
$ cmake -G "Unix Makefiles" ..
$ make

Building Skia

First go to the third party directory in ptk.

$ cd third_party

Be sure to have Clang as the default compiler and then follow the instructions depending on your platform: Linux, macOS and Windows.

Skia on Linux

$ git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'
$ export PATH="${PWD}/depot_tools:${PATH}"
$ cd skia
$ python3 tools/git-sync-deps
$ gn gen out/Release --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false"
$ ninja -C out/Release skia

Skia on macOS

$ git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'
$ export PATH="${PWD}/depot_tools:${PATH}"
$ cd skia
$ python3 tools/git-sync-deps
$ gn gen out/Release --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_sfntly=false skia_use_freetype=true skia_use_harfbuzz=true skia_pdf_subset_harfbuzz=true skia_use_system_freetype2=false skia_use_system_harfbuzz=false skia_use_metal=true target_cpu=\"x64\" extra_cflags=[\"-stdlib=libc++\", \"-mmacosx-version-min=10.14\"] extra_cflags_cc=[\"-frtti\"]"
$ ninja -C out/Release skia

Skia on Windows

It is recommended to use Clang to build skia due to it being optimized for it and compiling it with another compiler will result in a performance penalty.

However, it is more complicated to do and this project is not really need the added performance for now.

Below are instructions on compiling Skia with MSVC using the Command Prompt. Be sure to install Visual Studio 2022 Community Edition as it is needed. If it is installed with a custom path, be sure to update win_vc with the custom path.

$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ cd skia
$ python3 tools/git-sync-deps
$ ..\depot_tools\gn gen out/Release --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_sfntly=false skia_use_freetype=true skia_use_harfbuzz=true skia_pdf_subset_harfbuzz=true skia_use_system_freetype2=false skia_use_system_harfbuzz=false target_cpu=""x64"" win_vc=""C:\Program Files\Microsoft Visual Studio\2022\Community\VC"" extra_cflags=[""-MD""]"
$ ..\depot_tools\ninja -C out/Release skia

License

See MIT License.

This project uses third-party dependencies:

About

C++ library for building user interfaces.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published