aseprite / laf Goto Github PK
View Code? Open in Web Editor NEWA C++ library to create desktop applications
Home Page: https://aseprite.github.io/laf/
License: MIT License
A C++ library to create desktop applications
Home Page: https://aseprite.github.io/laf/
License: MIT License
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:
I can't compile laf for some reason. The error-message is just
"collect2: error: ld returned 1 exit status". I am trying to compile laf with skia. I downloaded skia-m102 from here: Skia-m102 and chose the libstdc++-version, since I think g++ is the compiler used in my system. I compiled and installed cmake 3.27 by hand, before.
as you can see in the compiler-output, I extracted skia-m102 to ~/deps/skia and set-up all path correctly. Nevertheless compiling just stops without usefull error-message.
Please see full compiler-output on pastebin
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.
Some changes that must be done for a probable first release of the library (some of these items are implemented in an internal beta version that will be published in the near future):
os::draw_text()
function (#12) and remove freetype usage if possible, use Skia directly to draw text, SkShaper
module uses harfbuzz+icuos::Display::setTitleBar()
-> setTitle()
os::Surface::bounds()
-> Rect(0, 0, width, height)
os::Display::invalidate()
= os::Display->invalidateRegion(display->surface->bounds)
os::ScopedHandle
? add os::DisplayHandle
and os::SurfaceHandle
aliases? or use move semantic and pimpl idiom?os::Display
-> os::Window
?os::Display
that is bounds + monitor/screengetEvent()
-> replace bool arg with an enum { WaitForEvents, DontWait }
os::Surface::drawSurface()
/blitTo()
in one member function with a os::Paint
argumentk
prefix (e.g. os::Event::ResizeDisplay
vs os::kArrowCursor
; or os::Key::Esc
instead of os::kKeyEsc
) / Check web KeyboardEvent codes as a reference / #50Match these functions with the standards:
I'll try to implement the native menus for the Windows port in these days.
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).
I've found that when a laf client calls os::queue_event(ev) on macOS there is a chance that the event is not processed until some other OS event "wakes up" the queue. This can be seen when the getEvent() method is called from the main thread without a timeout, because when using a timeout, the timeout wakes up the queue and the issue is not perceived.
The issue can happen when the os::queue_event(ev) call takes place after line 77 and before line 82 in the following fragment of code:
Lines 77 to 86 in 695bb59
Because the m_sleeping flag is still false in that moment, the queueEvent() method won't call the wakeUpQueue() method. Then the event got queued (in m_events queue) but then the queue will go to sleep (call to nextEventMatchingMask with untilDate=distantFuture because we are not using a timeout), waiting for any OS event to wake it up.
I think I've a fix for this which is basically a different approach, I'll try it with Aseprite and then create a PR.
EDIT: I've been trying this for a bit with Aseprite and it seems to work fine. Also I want to clarify why I need this fix:
While developing our laf based UI library I wanted to let the main thread just read all the OS events and if there is no OS events then just wait for the next one, no timeout, just sit and wait. When an OS event is available I just translate it to an app event and then push it to the app event queue. This is because in a background thread I keep reading the app queue to then send app events to the appropriate widgets. Still lots of work to do, but I just wanted to let you know which was the use case made the current implementation fail.
To avoid always depending/linking with harfbuzz/icu libraries, we would prefer os::draw_text()
as a global function instead of a os::Surface
member function. Also we're going to use two alternatives:
os::draw_text()
, andos::draw_text_with_shaper()
To reduce binary size of apps that don't require the text shaping engine.
Help me
Just yesterday I was investigating about the possibility to enable UTF-8 support on the console (using SetConsoleOutputCP(CP_UTF8)
): ad8cf49
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).
As we are going to use zenity for the native file dialog, it would be nice to implement some issues for zenity like:
I've been building Aseprite/laf successfully on my Ubuntu-based Linux distros, but I just tried building the latest version and it fails during the CMake stage in laf/os/CMakeLists.txt on this line:
find_package(X11 REQUIRED)
with the error:
CMake Error at ~/dev/tools/cmake-v3.18.4/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
~/dev/tools/cmake-v3.18.4/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
~/dev/tools/cmake-v3.18.4/share/cmake-3.18/Modules/FindX11.cmake:414 (find_package_handle_standard_args)
laf/os/CMakeLists.txt:126 (find_package)
this is happening on all of the Ubuntu-based linux distros that I've tried:
Any idea how to fix it? Note that I have all of the Linux packages installed that are recommended in the Aseprite INSTALL.md
file, as well as the recommended CMake command. I have been building Aseprite for a number of years now, have not seen this error before, and have all of the relevant x11 packages installed on my system almost surely.
/disk-samsung/freebsd-ports/graphics/aseprite/work/aseprite-1.2.28/laf/os/x11/system.cpp:44:51: error: implicit instantiation of undefined template 'std::__1::array<base::Ref<os::Cursor>, 19>'
std::array<CursorRef, int(NativeCursor::Cursors)> g_nativeCursors;
^
/usr/include/c++/v1/__tuple:219:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
^
/disk-samsung/freebsd-ports/graphics/aseprite/work/aseprite-1.2.28/laf/os/x11/system.cpp:63:11: warning: enumeration value 'Cursors' not handled in switch [-Wswitch]
switch (cursor) {
^
Did you forget to include <array>
?
My plans for the UI part of the laf library are:
laf::os
namespace.laf::ui
namespace.Hi there, currently I am having a problem compiling laf at the cmake command
cmake -G Ninja
-DLAF_BACKEND=skia
-DSKIA_DIR=/skiadir
-DSKIA_LIBRARY_DIR=/skiadir/out/Release-x64 \
when I put that on the terminal it throws me a cmake error:
~/laf/build$ cmake -G Ninja -DLAF_BACKEND=skia -DSKIA_DIR=/skiadir -DSKIA_LIBRARY_DIR=skiadir/out/Release-x64 ..
CMake Error at third_party/CMakeLists.txt:10 (add_subdirectory):
The source directory
/home/m/laf/third_party/googletest
does not contain a CMakeLists.txt file.
-- laf backend: skia
-- laf zlib: zlib
-- laf pixman:
-- laf freetype: FREETYPE_LIBRARY-NOTFOUND
-- laf harfbuzz: HARFBUZZ_LIBRARY-NOTFOUND
-- skia dir: /skiadir
-- skia library: SKIA_LIBRARY-NOTFOUND
-- skia library dir: /home/m/laf/build/skiadir/out/Release-x64
CMake Error at CMakeLists.txt:89 (message):
set SKIA_DIR/SKIA_LIBRARY/SKIA_LIBRARY_DIR to compile w/skia backend
So I dont know exactly what to do after this. I have the skia library m102 and everything else but this is giving me problems and I dont know if it is important to not have problems later when I use the ninja aseprite command.
Im on Linux Mint Vera 21.1.(newbie in linux btw)
Id be very glad If someone could help me to compile it :)
I tried following the compile section but I got a error when running ninja
:
FAILED: gfx/packing_rects_tests
: && /usr/bin/c++ gfx/CMakeFiles/packing_rects_tests.dir/packing_rects_tests.cpp.o -o gfx/packing_rects_tests lib/libgtest.a gfx/liblaf-gfx.a -lpthread base/liblaf-base.a -lpthread /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libGL.so third_party/zlib/lib/libz.a /usr/lib/x86_64-linux-gnu/libfontconfig.so && :
gfx/liblaf-gfx.a(packing_rects.cpp.o): In function `gfx::Region::createSubtraction(gfx::Region const&, gfx::Region const&)':
packing_rects.cpp:(.text._ZN3gfx6Region17createSubtractionERKS0_S2_[_ZN3gfx6Region17createSubtractionERKS0_S2_]+0x29): undefined reference to `SkRegion::op(SkRegion const&, SkRegion const&, SkRegion::Op)'
gfx/liblaf-gfx.a(packing_rects.cpp.o): In function `gfx::Region::~Region()':
packing_rects.cpp:(.text._ZN3gfx6RegionD2Ev[_ZN3gfx6RegionD5Ev]+0x14): undefined reference to `SkRegion::~SkRegion()'
gfx/liblaf-gfx.a(region_skia.cpp.o): In function `gfx::Region::Region()':
region_skia.cpp:(.text+0x80): undefined reference to `SkRegion::SkRegion()'
gfx/liblaf-gfx.a(region_skia.cpp.o): In function `gfx::Region::Region(gfx::Region const&)':
...
There are more undefined reference error, but I omitted them.
Previously when running cmake
I get some warnings:
CMake Warning at cmake/FindSkia.cmake:150 (target_link_libraries):
Target <TARGET> requests linking to directory
"/home/yudi/deps/skia/out/Release-x64". Targets may link only to
libraries. CMake is dropping the item.
Call Stack (most recent call first):
CMakeLists.txt:47 (include)
This warning is printed several times with different values for<TARGET>
.
Am I missing something?
Versions:
cmake: 3.25.2
g++: 11.0
From aseprite actions we can see that thread_pool_tests has an infinite loop/thread-safety issues (action cancelled 1 hour ago in 6h 0m 15s) so there might be a bug in our thread_pool impl:
Run if [[ "macOS" == "Linux" ]] ; then
Test project /Users/runner/work/aseprite/aseprite/build
...
12/52 Test #12: split_string_tests ............... Passed 0.10 sec
Start 13: string_tests
13/52 Test #13: string_tests ..................... Passed 0.11 sec
Start 14: task_tests
14/52 Test #14: task_tests ....................... Passed 0.11 sec
Start 15: thread_pool_tests
Error: The operation was canceled.
It looks like since Windows 10, version 1607, paths can be longer, check the documentation (and the app manifest can enable the long path usage):
Hi,
I think do you want Skia to have GPU support, right?? See line:
https://github.com/aseprite/laf/blob/master/cmake/FindSkia.cmake#L91
Why not change to SK_SUPPORT_GPU=1
?
Regards,
Melroy van den Berg
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.