Giter VIP home page Giter VIP logo

moonfltk's People

Contributors

computernerd avatar osch avatar stetre avatar tomet avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

moonfltk's Issues

Lua 5.1

Hello there!

Lua 5.1 seems to work fine, is there a reason it isn't supported? I'm using it with LuaJIT if that makes any difference.

Can't compile on SparkyLinux.

I have tried many different combinations of the install procedure e.g. getting fltk-dev, lua and moon-fltk from deb repository and/or compiling from source but whatever I do I consistently get this message when I try to 'make' moonfltk:

....many lines deleted.... /usr/bin/ld: /usr/local/lib/libfltk.a(Fl_File_Chooser2.o): relocation R_X86_64_PC32 against symbol _ZN15Fl_File_Chooser19add_fas_labelE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/lib/libfltk.a(fl_arci.o): relocation R_X86_64_PC32 against symbol `fl_gc' can not be used when making a object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[1]: [Makefile:162: moonfltk] Error 1 (ignored)

make[1]: Leaving directory '/home/jon/moonfltk/src'`

Any clues very much appreciated since I am really stuck. It worked out-of-the box on Lubuntu a few weeks, but the OS kept crashing, so I switched to Sparky which is faster and crashes less, but has its own issues ;-0

I have been through the command history I used for the Lubuntu install, without success so far.

callbacks, lua states & coroutines

Hi Stefano,

while playing around with multithreading I discovered a problem that can occur even if "real" multithreading is not involved: this problem may affect all lua callbacks that are registered in FLTK within a lua coroutine. (one could of course say, that this is in principle not a good idea...)

Take for example the idle callback that can be registered with fl.set_idle. The invoking lua_State is registered as void* with Fl::add_idle. However if the invoking lua_State is a coroutine, the registered state can become invalid if it is garbage collected.

Another example is the Widgetcallback, but this is more complicated: the struct moonfltk_ud_t contains the lua state that was valid when the widget was created.

I'm now trying to think about a solution for this problem.... I hope, this could also lead to a deeper understanding for possible multithreading problems.

What do you think?

Best regards,
Oliver

FreeBSD build error

I have lua54 installed, ie

/usr/local/bin/lua54
/usr/local/bin/luac54
/usr/local/include/lua54/lauxlib.h
/usr/local/include/lua54/lua.h
/usr/local/include/lua54/lua.hpp
/usr/local/include/lua54/luaconf.h
/usr/local/include/lua54/lualib.h
/usr/local/lib/liblua-5.4.a
/usr/local/lib/liblua-5.4.so

gmake returns,

gmake[1]: Entering directory '/usr/home/x/test/moonfltk/src'
gmake[1]: lua: No such file or directory
c++ -O2 -Wall -Wextra -DCOMPAT53_PREFIX=moonfltk_compat_ -DLUAVER=5.3 -DUSE_GL=1 -DUSE_IMAGES=1 -DBEGIN_FLTK_INCLUDE='_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")' -DEND_FLTK_INCLUDE='_Pragma("GCC diagnostic pop")' -DLINUX -fpic -I/usr/include -I/usr/include/lua5.3 -I/usr/local/include -I/usr/local/include -D_THREAD_SAFE -pthread -I/usr/local/include/freetype2 -I/usr/local/include/libpng16 -O2 -pipe -fno-lto -O2 -pipe -march=ivybridge -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -fno-lto -O2 -pipe -isystem /usr/local/include -fvisibility-inlines-hidden -I/usr/local/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT   -c -o additional.o additional.cc
In file included from additional.cc:26:
In file included from ./internal.h:37:
./moonfltk.h:33:10: fatal error: 'lua.hpp' file not found
#include <lua.hpp>
         ^~~~~~~~~
1 error generated.
gmake[1]: *** [<builtin>: additional.o] Error 1
gmake[1]: Leaving directory '/usr/home/x/test/moonfltk/src'
gmake: *** [Makefile:5: build] Error 2

Cannot build in G++ (aarch64) with this errors.

I am trying use your moonfltk on my embedded system board ( Rock960B, aarch64 ) but it failures withi this message when make.

g++ -O2 -Wall -Wextra -DCOMPAT53_PREFIX=moonfltk_compat_ -DLUAVER=5.3 -DUSE_GL=1 -DUSE_IMAGES=1 -DBEGIN_FLTK_INCLUDE='_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")' -DEND_FLTK_INCLUDE='_Pragma("GCC diagnostic pop")' -DLINUX -fpic -I/usr/include -I/usr/include/lua5.3 -I/usr/local/include -I/usr/local/include/FL/images -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT   -c -o bitfields.o bitfields.cc
bitfields.cc: In function ‘int push_Tree_Item_Draw_Mode(lua_State*, Fl_Tree_Item_Draw_Mode, int)’:
bitfields.cc:489:30: error: ‘flags’ was not declared in this scope
         { lua_pushinteger(L, flags); return 1; }
                              ^~~~~
bitfields.cc:492:27: error: ‘flags’ was not declared in this scope
 #define CASE(CODE,str) if(flags & CODE) do { lua_pushstring(L, str); n++; } while(0)
                           ^
bitfields.cc:493:9: note: in expansion of macro ‘CASE’
         CASE(FL_TREE_ITEM_DRAW_DEFAULT, "default");
         ^~~~
bitfields.cc:492:27: error: ‘flags’ was not declared in this scope
 #define CASE(CODE,str) if(flags & CODE) do { lua_pushstring(L, str); n++; } while(0)
                           ^
bitfields.cc:494:9: note: in expansion of macro ‘CASE’
         CASE(FL_TREE_ITEM_DRAW_LABEL_AND_WIDGET, "label and widget");
         ^~~~
bitfields.cc:492:27: error: ‘flags’ was not declared in this scope
 #define CASE(CODE,str) if(flags & CODE) do { lua_pushstring(L, str); n++; } while(0)
                           ^
bitfields.cc:495:9: note: in expansion of macro ‘CASE’
         CASE(FL_TREE_ITEM_HEIGHT_FROM_WIDGET, "height from widget");
         ^~~~
bitfields.cc:486:67: warning: unused parameter ‘val’ [-Wunused-parameter]
 int push_Tree_Item_Draw_Mode(lua_State *L, Fl_Tree_Item_Draw_Mode val, int pushcode)
                                                                   ^~~
<builtin>: recipe for target 'bitfields.o' failed
make[1]: *** [bitfields.o] Error 1
make[1]: Leaving directory '/home/linaro/Projects/moonfltk/src'
Makefile:5: recipe for target 'build' failed
make: *** [build] Error 2

My G++ runs on on board, and this is little information about environments.

  • G++ 6.3.0( see below )
  • FLTK 1.3.5 ( my little bit customized 1.3.5-2-ts, 100% compatibles with 1.3.5 )
  • LUA 5.2
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/6/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-arm64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-arm64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-arm64 --with-arch-directory=aarch64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-multiarch --enable-fix-cortex-a53-843419 --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)

Adding compatibility to Mac OS X

Error during Make procedure:

c++ -O2 -Wall -Wextra -Wpedantic -DCOMPAT53_PREFIX=moonfltk_compat_ -DLUAVER=5.3 -DUSE_GL=1 -DUSE_IMAGES=1 -DBEGIN_FLTK_INCLUDE='_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")' -DEND_FLTK_INCLUDE='_Pragma("GCC diagnostic pop")' -DLINUX -fpic -I/usr/include -I/usr/local/Cellar/fltk/1.3.4_1/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT   -c -o flcolor.o flcolor.cc
flcolor.cc:114:13: error: use of undeclared identifier 'fl_xpixel'
        n = fl_xpixel(check_ColorIndex(L, 1));
            ^
flcolor.cc:116:13: error: use of undeclared identifier 'fl_xpixel'
        n = fl_xpixel(luaL_checkinteger(L, 1), luaL_checkinteger(L, 2), ...
            ^
2 errors generated.

On Mac OS X

Why search for userdata in a separate data structure?

I noticed that the code does the following:

ud_t *ud = userdata(p);

That function searches a mapping between the pointer created by new Fl_Widget and the userdata.

Was there a particular problem you were trying to solve that could only be done in this way?

As an alternative for userdata you can create a struct with all the data you need in it and return it and pass it around. This means no need for searching and simpler code.

RFC: Fluid exporter for Lua

Hi devs.

I really like the project that you have created here. I am a big fan of Lua, but keep falling back into C++ development for all the wrong reasons.

My name is Matthias, and I am one of the original developers of FLTK together with Bill Spitzak. We are currently preparing to release version 1.4 which is a huge improvement on all platform. My job - besides bug fixes - is maintaining Fluid, our visual user interface design tool.

My question (and offer) is: would it make sense to write an exporter that creates moonfltk Lua source code out of Fluid designs? If you think that this is a useful feature for your user base, I would be willing to implement that, but I have to rely on your input of implementations specifics because I am not yet good enough at Lua.

To me, this would also be a great starting point to implement more languages like Rust. FLTK seems to become the goto GUI for not-so mainstream languages, which I find really great!

Cheers,

  • Matthias

Can't persuade lua to release memory using moonfltk and oocairo - probably my incompetence rather than a bug.

I have some code here which uses oocairo to draw a probability tree and then draw some paths through it which are displayed in 'real time' in an FLTK box. The problem is that when I run it, the memory used by lua goes up and up and never gets released till I kill the gui or the computer crashes. I assume that the problem lies in this bit:

surface:write_to_png("simple-example.png") --some cairo stuff
png=fl.png_image("simple-example.png") --read the image into a box widget
box:image(png)
box:redraw()
fl:check()
png:uncache()

but I am not sure. The png:uncache() helps a lot to keep the memory used by Xorg down a lot. I tried using local variables rather than globals and followed the advice in the documentation and in the progress bar example file, which suggest doing something like this:

w:remove(progress) -- remove progress bar from window
-- unreference the progress bar, so that it will be GC'ed
fl.unreference(progress)
-- let's force GC:
progress = nil
collectgarbage()

but without success. As per title, this is almost certainly my incompetence rather than a bug, but you kindly requested on the /r/lua forum that I should post something here. If its not my numpty code, I fear that the problem might be in oocairo??

crash at program termination after using gtk native file chooser

In the example editor.lua the program is terminated with os.exit(true, true). This leads to a crash after the gtk native file chooser was invoked (at least under current Manjaro Linux, latest release MoonFLTK 0.5 und also current git master), stacktrace:

#0  0x00007f510e851bc5 in getenv () at /usr/lib/libc.so.6
#1  0x00007f5105a0b4b0 in  () at /usr/lib/libcanberra.so.0
#2  0x00007f510f587af3 in _dl_fini () at /lib64/ld-linux-x86-64.so.2
#3  0x00007f510e852448 in __run_exit_handlers () at /usr/lib/libc.so.6
#4  0x00007f510e85249a in  () at /usr/lib/libc.so.6
#5  0x0000562b55393741 in os_exit (L=0x562b56989268) at loslib.c:379

The program does not crash if terminating with os.exit(true, false) or if the FLTK file chooser is used instead of the GTK one.

The problem is, that the second true argument in os.exit leads to closing the lua_State before the exit handlers are called. In lua source loadlib.c one can see that closing the lua state unloads all native shared objects, e.g. moonfltk.so. Unloading moonfltk.so seems to unload some other shared objects that are needed by another exit handler: if the call to dlclose in lua/loadlib.c is commented out, than no crash does occur.

I did not find a better solution than just quitting the application with os.exit(true, false).

MSYS2 (MinGW-W64) Error occurs on while compile "tree.cc"

Here an error,

g++ -O2 -Wall -Wextra -Wpedantic -DCOMPAT53_PREFIX=moonfltk_compat_ -DLUAVER=5.3 -DUSE_GL=1 -DUSE_IMAGES=1  -DMINGW -Wno-unused-parameter -Wno-long-long  -I/mingw64/include -I/mingw64/include/FL/images -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64   -c -o tree.o tree.cc
tree.cc:1019:30: error: 'Treecalc_dimensions' was not declared in this scope
         { "calc_dimensions", Treecalc_dimensions },
                              ^~~~~~~~~~~~~~~~~~~
tree.cc:1019:30: note: suggested alternative: 'Treecalc_tree'
         { "calc_dimensions", Treecalc_dimensions },
                              ^~~~~~~~~~~~~~~~~~~
                              Treecalc_tree

Where "Treecalc_dimensions" defined ?
Shouldn't find with grep.

Regards, Raph.

$ make LUAVER=5.4

g++ -O2 -Wall -Wextra -DCOMPAT53_PREFIX=moonfltk_compat_ -DLUAVER=5.4 -DUSE_GL=1 -DUSE_IMAGES=1 -DMINGW -Wno-unused-parameter -Wno-long-long -I/mingw64/include -march=x86-64 -mtune=generic -O2 -pipe -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -c -o handlers.o handlers.cc
handlers.cc: In function 'int Add_fd(lua_State*)':
handlers.cc:242:26: error: invalid conversion from 'void ()(int, void)' to 'Fl_FD_Handler' {aka 'void ()(long long unsigned int, void)'} [-fpermissive]
242 | Fl::add_fd(fd, when, FdHandler, (void*)0);
| ^~~~~~~~~
| |
| void ()(int, void)
In file included from internal.h:47,
from handlers.cc:26:
C:/msys64/mingw64/include/FL/Fl.H:463:54: note: initializing argument 3 of 'static void Fl::add_fd(int, int, Fl_FD_Handler, void*)'
463 | static void add_fd(int fd, int when, Fl_FD_Handler cb, void* = 0); // platform dependent
| ~~~~~~~~~~~~~~^~
make[1]: *** [: handlers.o] Error 1
make[1]: Leaving directory '/home/61401/moonfltk/src'
make: *** [Makefile:5: build] Error 2

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.