FLTK Rust: Using FLTK on Android

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Disclaimer: Android support is being worked on by the FLTK core developers, it's still in pre-alpha.

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/mo_al_ πŸ“…οΈŽ︎ Sep 23 2020 πŸ—«︎ replies

Nice! Slightly off topic: is there any fltk widget that combines tree view and table? Like qtreeview in Qt?

πŸ‘οΈŽ︎ 1 πŸ‘€οΈŽ︎ u/csarnow πŸ“…οΈŽ︎ Sep 23 2020 πŸ—«︎ replies
Captions
hello welcome to a new video on the uh fltk rust series so this is a tutorial on creating a uh nfl tk application on android so uh i have android studio i run the android emulator and here we'll be creating a new android studio project and let's go all the way down to native c plus next we can call this for example uh fltk app so this will be in the tutorial uh uh location and language it doesn't matter you can use java or kotlin either way we'll be deleting the java code so this emulator is an x86 emulator and uh the first thing we want is to uh open the terminal here and get more stuff target add there is a i-686 linux android so i already have it installed so you can see that this is uh the emulator here and we can just run this code just to see that it's working or our tool chain is working then the basic idea is that we need a uh what's called the android android native activity that means that there won't be a main activity a java main activity so once this finishes we can basically just delete the java file okay so we'll delete this okay delete anyway then we'll go to the manifest we can actually delete this since this basically calls the main activity so we can remove all of this and here this is from a uh c plus plus tutorial uh i'll add the link uh down below and basically need something like this we'll just be changing the name of the library here so we can go back here add this code here and the library name will be the library name that is generated by cmake so native lib so if you check our cmak file here so basically it creates a library called native lib uses a c plus plus file uh natively dot cpp we won't need this code so we can remove all the code here we can keep the file uh basically empty basically uh this creates a shared library and this just finds some basic libraries for logging etc and here we'll be creating a uh linking the uh native lib to the log lib which is found here so we'll be creating a uh a rust application now so let's go to the folder here so let us go to app source main cpp you check the directory here so it's uh the same directory as the cpp file you can go or go new and you're actually although we're creating a fltk application we want to create a lib and export the main function from the library so let's call this app for example and let's open visual studio code so this is our rest project here and dependencies will add decay and this is actually available in the master branch for the moment so and we'll be using ninja as a build system since we're using uh windows here and the uh cmake which is uh used to build fltk would uh by default generate uh visual studio product files which don't work well with the with android basically so features for uh other posix system you don't need to use ninja so we'll just uh save this and uh actually like to run this from the native tools command prompt once you get all the environment variables and okay up not use the project structure of the android applications so okay app will build and here we can pass the target so it's i686 linux android just leave this build so once this builds we can actually link the generated library to the native lib here yes so you can see that if we don't give the uh if the build script for fltk detects that the target is android and you don't set the ndk home variable environment variable that will panic so here we can actually uh so the uh variable if we create something like uh helps temp i have the ndk home so set ndk um something right so this one's basically uh forward slashes so local android sdk mdk and just check here so we'll be using this one okay so we'll just pass this here first so once this is set we can resume the build so once this finishes it should create something like a uh lib app.a so this will be in our uh make current list there app target 5686 nx android debug and the vat dot a and we need to also link android and here we can create our code so use fltk and then then the main function will be a an exported main so use no mango and uh extern c and main this returns an i32 and then our boilerplate code so that's app and the window we'll be using an android window default android no default so we built this again okay yes so we need to tell this that we're creating a static lib so here i can say live click type all right so this built and we can basically try this now here and build this [Music] so there is a problem yes so there is actually something with the native tool chain you need to press something to see make this flag so this is in the same c plus plus tutorial here so we can go back to level tk app so uh here and just push it put it here for example let's see make sure to link up flags and this undefines the a native activity on create save and build so this is actually our fltk window we try to for example uh so let's close this and just do our programming here so let's add for example a button and uh so the x we can get for example the screen size um so let's try first 100 so this is about 800 600 in width and each hundred and length so if we take for example uh 20 and here for example let's say 400 and the width 160 and 80 let us say click me so with every change we need to build first here and then basically check the uh so we get the uh the button here we can basically modify the color of the button for example so let's say that color uh um e32 and we'll be using a uh color from the material design so material x color okay and we can change the label color and font so let's set label size let's say 36 and another white and build this first and then here reload okay you can also change the frame type so let us say for example flat box and uh let's push it a bit down so here for example 500 or 600 60 so this is a rounded flat box you can push it a bit further down example 700 and let's add a callback for example and so let us say that color color black apple drop oops we didn't want this okay all right so here uh so let's just create a uh so this is just a point or copy since uh fltk widgets implement uh internal uh mutability oops okay i'll run this again so for the moment it's not really streamlined i'd like to streamline it more make it easier okay so this is too well and 600. and you click here okay and get uh some margin problems here you can basically fix this by removing the visible focus so uh let's go back here and say build this and run this so you can see the world process is quite fast so we got rid of the little dotted lines there so uh this basically works that was basically it for this video i hope you enjoyed and hopefully i'll be creating more videos soon thanks for watching bye
Info
Channel: Mo_Al_
Views: 2,701
Rating: 5 out of 5
Keywords: rust, rustlang, programming, fltk, android, tutorial, gui
Id: 3jW_vxGmxt0
Channel Id: undefined
Length: 19min 30sec (1170 seconds)
Published: Wed Sep 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.