Giter VIP home page Giter VIP logo

libaroma's Introduction

Libaroma

an embedded UI toolkit

What is this?

It's a C library which provides graphics output, input management, utilities for drawing and a window system with controls that allows to create an entire user interface with few code lines.

Features

  • input management
  • graphics output
  • basic window manager (one window rendered at a time)
  • hardware acceleration whenever possible (ARM NEON, x86 SSE)
  • simple to use and understand
  • most parts have automatic allocation/free (you only need to release the library)

Compatibility

For now it was tested on the following platforms:

  • Linux (either direct framebuffer/input or SDL window)
  • Windows (using SDL window)

How to use it?

First build and install the library, refer to the BUILDING.md file. There are some examples already written, but the following code should be enough to initialize the library, create an empty window and handle the input:

#include <aroma.h>
int main(int argc, char **argv){
  if (!libaroma_start()){
      printf("libaroma start failed\n");
      return 0;
  }
  LIBAROMA_WINDOWP win = libaroma_window(NULL, 0, 0, 
			LIBAROMA_SIZE_FULL, LIBAROMA_SIZE_FULL);
  if (win==NULL){
      printf("libaroma window failed\n");
      libaroma_end();
      return 0;
  }
  libaroma_window_show(win);
  LIBAROMA_MSG msg;
  do {
      libaroma_window_pool(win, &msg);
      if (msg.msg==LIBAROMA_MSG_EXIT){
          win->onpool=0;
      }
      else if (msg.msg==LIBAROMA_MSG_TOUCH &&
		msg.state==LIBAROMA_HID_EV_STATE_UP){
          libaroma_msg_post(LIBAROMA_MSG_EXIT, 0, 0, 0, 0, NULL);
      }
      else printf("msg=% state=%d, key=%d, x=%d, y=%d, data=%p\n", 
                  msg.msg, msg.state, msg.key, msg.x, msg.y, msg.d);
  } while(win->onpool);
  libaroma_window_free(win);
  libaroma_end();
}

After this, just compile the program as you would with any project, for example:
gcc main.c -o test -laroma
Run it and should show an empty screen/window that closes after releasing the mouse left click.

TODO

  • fix scroll control relying on screen size for fling velocity
  • pager inside a fragment may give black control at creation
  • re-implement DRM on Linux
  • multiple windows & z order
  • LUA scripting engine?

Disclaimer

This library is under heavy work in progress, while there are no planned API changes that break compatibility it may happen if needed (e.g. in case of redundant features removed or safety issues found). The following libraries were embedded to easily implement features:

License

Libaroma is licensed under the Apache 2.0 license (see LICENSE.MD file) The embedded libraries listed above have their own licenses:

  • cJSON and ezXML are covered by the MIT license
  • nanoSVG is covered by the zlib license
  • MinZIP isn't a library per se, but it's code is covered by the Apache 2.0 license

libaroma's People

Contributors

amarullz avatar m1cha avatar mlxprojects avatar nift4 avatar ro0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

libaroma's Issues

[SDL/Win32] drawing text may throw Illegal Instruction on release builds

Platform:
SDL, Windows 8.1 x86
Compiler:
mingw32 gcc 8.1 (dwarf, posix threads variant)
Additional info:
Freetype 2.10.4
Description:
Drawing text may throw Illegal Instruction, crashing the entire program.
Weird enough it doesn't happen if freetype is built with debug symbols, even if not ran using a debugger.
Will upload a backtrace soon.

touch/keypad issues

On some devices, the capacitive keys may not work correctly (or misbehave, for example the back key sending a touch at weird coords).
Also, it seems that some Melfas touchscreens aren't working properly.
The input drivers need to be checked, fixed and, if needed, re-written.

[Win32?] Random text rendering crash

If a window is shown just after creating it and adding any controls with text, the drawing procedure may crash randomly. Need to check if it's platform specific.

Toolchain: Mingw-w64 gcc 8.1.0
Host OS: Windows 11 x64

Demo source: main.txt, run passing res.zip path as 2nd argument (it contains roboto font).
GDB backtrace:

I/LIBAROMA(): libaroma Version 1.0.1 (210609;SDL;Kinanthi)
I/LIBAROMA():   Copyright (c) 2011-2015 Ahmad Amarullah
I/LIBAROMA():
I/LIBAROMA(): ===================================================
D/LIBAROMA(): Starting LIBAROMA_INIT_HELPER thread
[New Thread 4256.0x1de0]
D/LIBAROMA(): waiting for start finished #0, init_status=0, runstate=0
D/LIBAROMA(): libaroma_fb_init allocating framebuffer instance
D/LIBAROMA(): Init framebuffer driver - default
D/LIBAROMA(): SDLFBDR initialized internal data
[New Thread 4256.0x1958]
I/LIBAROMA(): SDL BUFFER INFORMATIONS:
I/LIBAROMA():  width               : 360
I/LIBAROMA():  height              : 600
I/LIBAROMA():  bits_per_pixel      : 16
D/LIBAROMA():  pixsz               : 2
D/LIBAROMA():  line                : 720
D/LIBAROMA():  fb_size             : 432000
W/LIBAROMA(): libaroma_fb_init driver doesn't set dpi. set as : 160 dpi ==> on D:\libaroma\src\aroma\graph\fb.c line 130

I/LIBAROMA(): Framebuffer Initialized (360x600px - 160 dpi - Single Buffer)
D/LIBAROMA(): allocating hid instance
D/LIBAROMA(): init hid driver
D/LIBAROMA(): Init hid driver - default
D/LIBAROMA(): hid driver initialized
D/LIBAROMA(): libaroma_lang initialized
D/LIBAROMA(): libaroma_wm_init init window manager
[New Thread 4256.0x1dec]
[New Thread 4256.0x524]
[New Thread 4256.0x1d50]
I/LIBAROMA(): ___________________________________________________
I/LIBAROMA():
D/LIBAROMA(): previous font with same id exists, freeing
D/LIBAROMA(): font loaded 241008bytes (memzip://[zip_resource]#roboto.ttf)
W/LIBAROMA(): framebuffer driver do not support snapshoot ==> on D:\libaroma\src\aroma\graph\fb.c line 506

[New Thread 4256.0x1f98]
[New Thread 4256.0x13f4]
D/LIBAROMA(): starting wm messaging
D/LIBAROMA(): starting wm ui thread

Thread 7 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 4256.0x1dec]
0x0045d69b in af_glyph_hints_reload (hints=0x40cbfb8, outline=0x458b7cc)
    at D:/libaroma/libs/freetype/src/autofit/afhints.c:953
953               idx        = (short)( end[0] + 1 );
(gdb) bt
#0  0x0045d69b in af_glyph_hints_reload (hints=0x40cbfb8, outline=0x458b7cc)
    at D:/libaroma/libs/freetype/src/autofit/afhints.c:953
#1  0x00462111 in af_latin_metrics_init_widths (metrics=0x46cecb8, face=0x458aef8)
    at D:/libaroma/libs/freetype/src/autofit/aflatin.c:179
#2  0x00460ea3 in af_latin_metrics_init (metrics=0x46cecb8, face=0x458aef8)
    at D:/libaroma/libs/freetype/src/autofit/aflatin.c:1154
#3  0x0045c6f2 in af_face_globals_get_metrics (globals=0x3ec8f38, gindex=71, options=66, ametrics=0x40cda98)
    at D:/libaroma/libs/freetype/src/autofit/afglobal.c:466
#4  0x00463235 in af_loader_load_glyph (loader=0x40cdb44, module=0x149be78, face=0x458aef8, glyph_index=71,
    load_flags=196608) at D:/libaroma/libs/freetype/src/autofit/afloader.c:312
#5  0x00459213 in af_autofitter_load_glyph (module=0x149be78, slot=0x458b760, size=0x458b8d8, glyph_index=71,
    load_flags=196608) at D:/libaroma/libs/freetype/src/autofit/afmodule.c:535
#6  0x00417aca in FT_Load_Glyph (face=0x458aef8, glyph_index=71, load_flags=196608)
    at D:/libaroma/libs/freetype/src/base/ftobjs.c:966
#7  0x004c0000 in libaroma_font_glyph (c=71, fontid=0 '\000', size=4 '\004')
    at D:/libaroma/src/aroma/graph/text/font_freetype.c:246
#8  0x004cf8d2 in libaroma_text_shaper (span=0x40cf728, chunk=0x46c9880)
    at D:/libaroma/src/aroma/graph/text/text_shaper.c:88
#9  0x004ced97 in libaroma_text_group (chunk=0x46c9880) at D:/libaroma/src/aroma/graph/text/text_shaper.c:579
#10 0x004cff94 in libaroma_textline (chunk=0x46c9880) at D:/libaroma/src/aroma/graph/text/text_line.c:537
#11 0x004cda89 in libaroma_text (text=0x458bf98 "center", color=0, maxwidth=104, txtflags=28377152,
    linespacing=100 'd') at D:/libaroma/src/aroma/graph/text/text_public.c:144
#12 0x0043fe1c in _libaroma_ctl_button_internal_draw (ctl=0x149c748)
    at D:\libaroma\src\aroma\controls\ctl_button.c:216
#13 0x0043ee16 in _libaroma_ctl_button_draw (ctl=0x149c748, c=0x45f59a0)
    at D:\libaroma\src\aroma\controls\ctl_button.c:321
#14 0x004adf1d in libaroma_control_draw (ctl=0x149c748, sync=0 '\000') at D:\libaroma\src\aroma\ui\control.c:275
#15 0x004d49de in libaroma_window_invalidate._omp_fn () at D:\libaroma\src\aroma\ui\window.c:848
#16 0x6380d992 in omp_in_final () from D:\libaroma\out\bin\libgomp-1.dll
---Type <return> to continue, or q <return> to quit---
#17 0x64b44d01 in pthread_create_wrapper () from D:\libaroma\out\bin\libwinpthread-1.dll
#18 0x76757ee5 in msvcrt!_beginthreadex () from C:\Windows\System32\msvcrt.dll
#19 0x76757fb1 in msvcrt!_endthreadex () from C:\Windows\System32\msvcrt.dll
#20 0x76cd6739 in KERNEL32!BaseThreadInitThunk () from C:\Windows\System32\kernel32.dll
#21 0x77ce8e7f in ntdll!RtlGetFullPathName_UEx () from C:\Windows\SYSTEM32\ntdll.dll
#22 0x77ce8e4d in ntdll!RtlGetFullPathName_UEx () from C:\Windows\SYSTEM32\ntdll.dll
#

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.