A library to create Windows, macOS, and Linux applications.

Related tags

GUI laf
Overview

LAF: The Lost Application Framework

build MIT Licensed

A library to create Windows, macOS, and Linux applications.

This library is under active development so we don't provide API or ABI compatibility at this moment.

Modules

  • base: Base functions for any kind of application.
  • gfx: Generic graphics classes (rectangle, point, region, etc.)
  • ft: FreeType wrapper used by the os module (requires freetype library as dependency)
  • os: Functions to create windows in your Operating System.

Dependencies

laf can be compiled with two back-ends (LAF_BACKEND): skia or none.

When LAF_BACKEND=skia, laf requires a compiled version of the Skia library from branch aseprite-m96. You can check the aseprite/skia fork which includes a release with pre-built versions, or the check the instructions to compile skia from scratch.

When LAF_BACKEND=none, the Pixman library can be used as an alternative implementation of the gfx::Region class (generally if you're using laf-os you will link it with Skia, so there is no need for Pixman at all).

Compile

To compile laf with Skia as backend you have to specify some variables pointing to a valid compiled version of Skia in your disk. In the following example /skiadir is the absolute path to a directory where the Skia source code + compiled version is, or just where you've uncompressed a pre-built package of Skia (note that in this case /skiadir/out/Release-x64 should contain the Skia library files, i.e. skia.lib on Windows or libskia.a on other platforms):

git clone https://github.com/aseprite/laf.git
cd laf
mkdir build
cd build
cmake -G Ninja \
  -DLAF_BACKEND=skia \
  -DSKIA_DIR=/skiadir \
  -DSKIA_LIBRARY_DIR=/skiadir/out/Release-x64 \
  ..
ninja
./examples/helloworld

To compile only the library (without examples and tests) you can disable the LAF_WITH_EXAMPLES/LAF_WITH_TESTS options:

cmake -DLAF_WITH_EXAMPLES=OFF -DLAF_WITH_TESTS=OFF ...

Running Tests

You can use ctest to run all tests:

cd build
ninja
ctest

Defined Macros

  • LAF_WINDOWS: Compiling on Windows platform
  • LAF_MACOS: Compiling on macOS platform
  • LAF_LINUX: Compiling on Linux platform
  • LAF_SKIA: When we compile with LAF_BACKEND=skia (Skia library is available)

License

laf is distributed under the terms of the MIT license.

Some functions in laf depends on third party libraries (you should include these license notices when you distribute your software):

Comments
  • Add Rect floor function

    Add Rect floor function

    This 'floor' function is useful to adjust x, y float coordinates to the left most near integer for x, and top most near integer for y (instead of rounding towards 0). This function was included to solve issue aseprite/aseprite#2891

    Example of use:

    gfx::RectF boundsF(-0.25, -0.75, 1, 2);
    gfx::Rect bounds = boundsF.floor();
    bounds = (-1, -1, 1, 2)
    

    When 'floor' is not used:

    gfx::RectF boundsF(-0.25, -0.75, 1, 2);
    gfx::Rect bounds = boundsF;
    bounds = (0, 0, 1, 2)
    
    opened by Gasparoken 5
  • Compilation fails on aarch64 platforms

    Compilation fails on aarch64 platforms

    When attempting to compile Aseprite, compilation fails due to the following error:

    FAILED: laf/base/CMakeFiles/laf-base.dir/platform.cpp.o 
    /usr/bin/c++ -DCMARK_STATIC_DEFINE -DHAVE_CONFIG_H -DLAF_LINUX -DLAF_SKIA -DNDEBUG -DPNG_NO_MMX_CODE -I/home/lmt/Stuff/aseprite/third_party/zlib -I/home/lmt/Stuff/aseprite/build/third_party/zlib -I/home/lmt/Stuff/aseprite/third_party/libpng -I/home/lmt/Stuff/aseprite/build/third_party/libpng -I/home/lmt/Stuff/aseprite/third_party/libwebp/src -I/home/lmt/Stuff/aseprite/third_party/tinyxml -I/home/lmt/Stuff/aseprite/third_party/pixman/pixman -I/home/lmt/Stuff/aseprite/build -I/home/lmt/Stuff/aseprite/third_party/giflib -I/home/lmt/Stuff/aseprite/third_party/jpeg -I/home/lmt/Stuff/aseprite/third_party/curl/include -I/home/lmt/Stuff/aseprite/third_party/simpleini -I/home/lmt/Stuff/aseprite/laf -I/home/lmt/Stuff/aseprite/build/laf -I/home/lmt/Stuff/aseprite/src -I/home/lmt/Stuff/aseprite/laf/third_party/stringencoders/src -O2 -g -DNDEBUG -std=c++14 -MD -MT laf/base/CMakeFiles/laf-base.dir/platform.cpp.o -MF laf/base/CMakeFiles/laf-base.dir/platform.cpp.o.d -o laf/base/CMakeFiles/laf-base.dir/platform.cpp.o -c /home/lmt/Stuff/aseprite/laf/base/platform.cpp
    In file included from /home/lmt/Stuff/aseprite/laf/base/platform.cpp:11:
    /home/lmt/Stuff/aseprite/laf/base/platform.h:56:59: error: static assertion failed: Invalid identification of CPU architecture
       56 |   static_assert((arch == Arch::x86 && sizeof(void*) == 4) ||
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
       57 |                 ((arch == Arch::x64 ||
          |                 ~~~~~~~~~~~~~~~~~~~~~~                     
       58 |                   arch == Arch::arm64) && sizeof(void*) == 8),
          |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [600/1554] Building CXX object laf/base/CMakeFiles/laf-base.dir/program_options.cpp.o
    ninja: build stopped: subcommand failed.
    

    If I were to guess, this is due to my system reporting aarch64 instead of arm64.

    % uname -m
    aarch64
    

    My OS is Arch Linux ARM running on the Pinebook Pro.

    opened by netthier 5
  • Simplify to_utf8 and from_utf8 functions

    Simplify to_utf8 and from_utf8 functions

    This PR replaces the use of WideCharToMultiByte and MultiByteToWideChar to convert to and from utf8 strings by the use of the C++11 standard conversion functions.

    One thing to note is that the int parameter of to_utf8 was removed, which breaks the compatibility with previous versions of the library. Not sure if we should keep it and adapt the function to work as before.

    WARNING: C++17 deprecates the codecvt header...so...maybe this PR doesn't worth it.

    opened by martincapello 5
  • Force zero init of X11 class.

    Force zero init of X11 class.

    Running Aseprite batch mode (using -b) as part of a headless asset build process was causing it to segfault in XInput::~XInput() because m_xi was uninitialized. Forcing zero initialization fixes it.

    I agree that my contributions are licensed under the Laf license, and agree to future changes to the licensing.

    opened by slembcke 3
  • Fix low performance over time with SetCursor (Fix Aseprite#2713)

    Fix low performance over time with SetCursor (Fix Aseprite#2713)

    Instead of calling SetCursor(), swap the cursor reference on the window class. This aims to address https://github.com/aseprite/aseprite/issues/2713 Where SetCursor() results in decreased responsiveness as usage time progresses and persists even after closing and reopening the program.

    I agree that my contributions are licensed under the Laf license, and agree to future changes to the licensing.

    opened by Enfyve 3
  • Don't use pthread_detach() after pthread_join()

    Don't use pthread_detach() after pthread_join()

    After pthread_join() all allocated to thread resources are freed, so pthread_detach() after pthread_join() will results in undefined behavior with SIGSERV on some libc implementations (like MUSL). According to pthread_detach(3), "Either pthread_join(3) or pthread_detach() should be called for each thread that an application creates".

    I agree that my contributions are licensed under the MIT License. You can find a copy of this license at https://opensource.org/licenses/MIT

    opened by winterheart 2
  • Error messages in fs_unix.h

    Error messages in fs_unix.h

    I agree that my contributions are licensed under the Laf license, and agree to future changes to the licensing.

    I have simply added strerror to each function which throws an error to get a more detailed error message.

    opened by Delta2Force 2
  • [macOS] Fix searching for SKIA_OPENGL_LIBRARY

    [macOS] Fix searching for SKIA_OPENGL_LIBRARY

    In macOS, if the user's filesystem is case-sensitive, then laf CAN'T locate /System/Library/Frameworks/OpenGL.framework/, which results in link failures. (aseprite/aseprite#1776)

    This is because cmake/FindSkia.cmake tries to locate /System/Library/Frameworks/opengl.framework/. (Notice the lowercase "opengl" instead of "OpenGL"), and this commit fixes such error on macOS with a case-sensitive filesystem.

    Tested on Macbook Pro Retina 2014 with Mojave + APFS (case-sensitive): Screen Shot 2020-07-09 at 4 42 53 PM

    I agree that my contributions are licensed under the Laf license, and agree to future changes to the licensing.

    opened by aesophor 2
  • [osx] Use Retina display scale

    [osx] Use Retina display scale

    On Retina displays view/window coordinates are logical points not pixels and window.backingScaleFactor represents how many pixels are covered by single coordinate point.

    This change effectively makes LAF UI 2x smaller on Retina displays, but allows drawing at native Retina resolution.

    A picture is worth a thousand words: (NOTE: Click on the image to see it on full 2x/Retina scale) image

    Picture above depicts Aseprite using 400% scale on Retina and using TTF font instead of bitmap font.

    I understand this change may be completely irrelevant for most of the Aseprite users using default UI settings, but if you want to use TTF font this change actually makes all TTF fonts look crisp on macOS Retina displays. And I prefer to have TTF font on my Retina display rather than default bitmap font, that I find hard to read 🙄

    I agree that my contributions are licensed under the Laf license, and agree to future changes to the licensing.

    opened by nanoant 2
  • Fix Caps Lock has no effect on macOS

    Fix Caps Lock has no effect on macOS

    Hi! Hope this can be of a little help (^ ^;)

    It is a not-so-elegant workaround — I cannot find much information on how UCKeyTranslate() works, and this is the only way I can get the outcome correct so far. For now it seems that UCKeyTranslate() ignores the Caps Lock flag without Shift, and reads it with Shift, hence always disabling its function. I don't know the reason behind it, and I might, might be terribly wrong… I'd appreciate if anyone can provide a deeper insight into it!

    Btw, this can fix aseprite/aseprite#1876.

    opened by ayuusweetfish 2
  • Add support for sorted parsing

    Add support for sorted parsing

    The rationale behind this proposal is a bug that resulted from the use of the parse function in Aseprite. It so happened that the position of arguments is sensitive in some instances. For example, in cases where values without any associated options (e.g file names) come before some options, Aseprite opens the file(s), parse and process the opened file(s) before moving on to processing the other arguments. In some of these cases, the options provided via the CLI may be what is supposed to drive how the file is opened, parsed and processed. However, if the file is eagerly processed before the arguments, it results in some hard-to-debug bugs. This PR allows the user have two options:

    • get access to the CLI values/options as-is
    • move the option-less values to the end of "queue"

    This second option delays the eagerness to open/process option-less values until all driving forces are properly taken care of. If, from Aseprite, we could have direct mutating access to the underlying values and options parsed, there would not have been a need for this PR but (rightly so) the interface exposed is immutable -- thus why I think this PR may be needed.

    PS: I am not so sure the name of this function (sortedParse) is the right name for it, but as at the time of making this amendment, this is the only name I could think of.

    ADDENDUM: According to this comment, this PR may not be necessary as the Aseprite opened issue isn't really a bug but a feature.

    opened by iamOgunyinka 1
  • Review keyboard events

    Review keyboard events

    Review keyboard events and codes. Rename KeyScancode to VKey or something like that our KeyScancode is a virtual keycode in reality.

    Also check what compatibility we can offer with web keycodes:

    • https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values
    • https://w3c.github.io/uievents/tools/key-event-viewer.html
    enhancement 
    opened by dacap 0
  • Fix Windows build

    Fix Windows build

    find_library() is not a proper way for finding OpenGL libraries.
    On Windows, SKIA_OPENGL_LIBRARY got "SKIA_OPENGL_LIBRARY-NOTFOUND"
    without using VS-Dev-CMD.
    
    See discussions here:
        https://gitlab.kitware.com/cmake/cmake/-/issues/19804
        https://gitlab.kitware.com/cmake/cmake/-/issues/20226
    
    Use find_package(OpenGL) and OpenGL::GL instead.
    
    On Windows systems with non-English locales, the wide strings may cause
    "Error C2001: Newline in constant".
    
    2 solutions:
        Save the file with UTF-8 with BOM (byte-order mark).
        Specify UTF-8 charset for compilation. Used by this commit.
    
    See discussions here:
        https://github.com/libusb/libusb/issues/207#issuecomment-288664124
    

    I agree that my contributions are licensed under the MIT License. You can find a copy of this license at https://opensource.org/licenses/MIT

    opened by chaosink 0
  • UTF-8 on Windows

    UTF-8 on Windows

    Just yesterday I was investigating about the possibility to enable UTF-8 support on the console (using SetConsoleOutputCP(CP_UTF8)): https://github.com/aseprite/laf/commit/ad8cf4929f5effab88cc393b7d9534d32a65de8d

    But I'm not sure if this should be done by default. Even more, we could add support to use ANSI version of functions which can support UTF-8 directly (if we embed a special manifest file): https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page#set-a-process-code-page-to-utf-8

    In this way we could avoid the from_utf8/to_utf8 conversions on each Win32 API call (https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page#-a-vs--w-apis).

    enhancement 
    opened by dacap 0
  • base::copy_file implementation

    base::copy_file implementation

    Hi!

    This change, in short, implements base::copy_file function based on the idea of copying and pasting memory blocks. I've also changed the functions (move, copy and delete file) that throw exceptions unnecessarily to return bool type. (It needs clarify that I'm not an expert :sweat_smile:)

    opened by doomed-phobos 1
  • Add events to detect when the app is deactivated/activated

    Add events to detect when the app is deactivated/activated

    Add a couple of events to detect when the user deactivate the app (focus other app). In this way we can stop some timers (e.g. a blinking text cursor).

    enhancement 
    opened by dacap 0
Owner
Aseprite
Aseprite
Create macOS universal binaries of your Qt apps

With Apple transition from Intel to Apple Silicon (arm64) CPUs, developers have to deal with Universal binaries in macOS (again) in order to support t

CrystalIDEA Software 60 Dec 25, 2022
Examples, tutorials and applications for the LVGL embedded GUI library

Examples, tutorials and applications for the LVGL embedded GUI library

LVGL 441 Nov 11, 2022
FlatUI is a immediate mode C++ GUI library for games and graphical applications.

FlatUI is a immediate mode C++ GUI library for games and graphical applications. Go to our landing page to browse our documentation.

Google 610 Dec 23, 2022
The HorusUI library allows you to quickly develop GUIs for your applications by leveraging the ease of use provided by immediate mode GUI concepts.

Immediate Mode Graphical User Interface for Tools OVERVIEW The HorusUI library allows you to quickly develop GUIs for your applications by leveraging

null 133 Dec 12, 2022
NWM is a simple window manager for linux which uses Xlib for managing windows

NWM is a simple window manager for linux which uses Xlib for managing windows.

Kumar Gaurav Pandey 18 Nov 27, 2022
Build performant, native and cross-platform desktop applications with Node.js and CSS like styling. 🚀

NodeGui Build performant, native and cross-platform desktop applications with Node.js and CSS like styling. ?? NodeGUI is powered by Qt5 ?? which make

NodeGui 8.1k Dec 30, 2022
Lets try out a few ways to easily create a modern Win32 UI app

UI-Experiments Lets try out a few ways to easily create a modern Win32 UI app This is a VS2019 solution with a handful of single projects, each one tr

Tammo 'kb' Hinrichs 21 Dec 6, 2021
A minimalist andf platform-agnostic application layer for writing graphical applications, with a strong emphasis on simplicity and ease of use.

SlimApp A minimalist(*) and platform-agnostic application layer for writing graphical applications. Available as either a single header file or a dire

Arnon Marcus 34 Dec 18, 2022
Electron framework lets you write cross-platform desktop applications using JavaScript, HTML and CSS.

?? Available Translations: ???? ???? ???? ???? ???? ???? ???? ???? . View these docs in other languages at electron/i18n. The Electron framework lets

Electron 105.2k Jan 3, 2023
wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls.

About wxWidgets is a free and open source cross-platform C++ framework for writing advanced GUI applications using native controls. wxWidgets allows y

null 4.8k Jan 7, 2023
Change applications UI labels by hook SetDlgItemTextW(...) in user32.dll.

UI-Injection-Text Change applications UI labels by hook SetDlgItemTextW(...) in user32.dll.

null 1 Oct 24, 2021
Tiny cross-platform webview library for C/C++/Golang. Uses WebKit (Gtk/Cocoa) and Edge (Windows)

A tiny cross-platform webview library for C/C++/Golang to build modern cross-platform GUIs. Also, there are Rust bindings, Python bindings, Nim bindings, Haskell, C# bindings and Java bindings available.

webview 10.8k Jan 9, 2023
A lightweight modern C++11 library for Win32 API, using lambdas to handle Windows messages.

WinLamb A lightweight modern C++11 library for Win32 API, using lambdas to handle Windows messages. Overview Setup Example Classes summary License 1.

Rodrigo 239 Dec 28, 2022
win-vind provides a lightweight hybrid UI system of CUI and GUI for Windows

win-vind provides a lightweight hybrid UI system of CUI and GUI for Windows. And everything is inspired by Vim and its plugins. Simply put, it is a Vim-oriented toy box consisting of various useful features.

pit-ray 950 Jan 4, 2023
XClicker - Fast gui autoclicker for x11 linux desktops

What is XClicker? XClicker is an open-source, easy to use, feature-rich, blazing fast Autoclicker for linux desktops using x11. Main features Fairly s

Robiot 291 Dec 24, 2022
FLTK - Fast Light Tool Kit - a cross-platform C++ GUI toolkit for UNIX(r)/Linux(r) (X11)

FLTK - Fast Light Tool Kit - a cross-platform C++ GUI toolkit for UNIX(r)/Linux(r) (X11)

The FLTK Team 1.1k Dec 25, 2022
Proof-of-concept code to reconstruct the GUI of a Xen guest running Windows

vmi-reconstruct-gui A proof-of-concept to reconstruct the GUI of a Xen VM running Windows 7. ❗ Disclaimer This repository is work in progress. It curr

Jan 12 Aug 21, 2022
tabbed window manager that can tile windows inside floating containers

tabbed window manager that can tile windows inside floating containers

Seninha 131 Dec 27, 2022
🍡 Maximize windows in a way easy for minimize

关于我想要快速最小化于是乎就重写了最大化这档子事 看到这个轻小说标题一样的标题就可以知道这个项目必定不是在干什么正事。因为作者是学生,所以需要精通 Alt + tab / Win + Down 之类的技巧。然而,Windows 10 2004 以后 Alt + Tab 就开始抽风(可能会跳到莫名其妙

gyro永不抽风 2 Feb 13, 2022