Skip to content
forked from graemeg/fpGUI

fpGUI Toolkit is a cross-platform GUI toolkit using Free Pascal (Ultibo port)

License

LGPL-2.1, Unknown licenses found

Licenses found

LGPL-2.1
COPYING.txt
Unknown
COPYING.modifiedLGPL
Notifications You must be signed in to change notification settings

ultibohub/fpGUI

 
 

Repository files navigation

fpGUI Ultibo port

This repository is the port to make the fpGUI toolkit run under Ultibo core.

Please note that this port is not currently complete and does not create a usable GUI interface. See the information below for details about what elements are missing, what work is required to complete the port and how you can help.

Work to date

The initial work to make both fpGUI and AggPas run under Ultibo has now been committed, this includes the following changes:

  • \src\extrafpc.cfg - Extended to include Ultibo definitions

  • \src\fpmake.pas - Extended to include Ultibo definitions (Not tested)

  • \src\corelib\fpg_base.pas - Minor adjustments (default fonts etc)

  • \src\corelib\fpg_main.pas - Minor adjustments

  • \src\corelib\ultibo* - Added to provide the basic platform support for fpGUI

  • \src\corelib\render\software\Agg2D.pas - Addition of raster font support

  • \src\corelib\render\software\agg_mode.inc - Extended to include Ultibo definitions

  • \src\corelib\render\software\agg_platform_ultibo.inc - Addition of Ultibo support for drawing to screen

  • \src\corelib\render\software\platform* - Added to provide the basic platform support for AggPas

  • \examples\corelib\aggcanvas - Ultibo specific version of the example

  • \examples\corelib\canvastest - As above

  • \examples\corelib\helloworld - As above

What is working

Surprisingly a lot is already working, so far only about 5 days has been spent on porting fpGUI to Ultibo and a couple of those days were spent putting the initial work into a form that could be committed to GitHub and become the beginning of a proper port.

From the examples that have been built the rendering of dots, lines, rectangles, triangles and arcs works fine (filled arc doesn't work but that is noted in the source as an fpGUI/AggPas issue).

The canvastest example loads bitmaps from disk and renders them at both original size and stretched.

The aggcanvas example also shows more complex rendering like circles, arrows and stars and includes shading and transparent fill.

All of the examples show text rendering (aggcanvas evens shows text flip) but currently this is done with built in raster fonts only and not true type fonts (see below for more info).

No attempt has been made to connect any form of mouse or keyboard input but both of these should be possible as they are available in Ultibo and there are places to connect them in fpGUI.

Building fpGUI and AggPas

Included in the changes is a build_ultibo.bat batch file under \src which will build both libraries for the Ultibo target. By default it looks for the Ultibo version of FPC in the folder:

C:\Ultibo\Core\fpc\3.1.1

If you installed Ultibo core to a different location you can set the environment variable ULTIBO_DIR to the appropriate folder (eg D:\Tools\Ultibo\fpc\3.1.1) and the batch files will adjust the paths based on that.

You can also pass a parameter to the batch file to specify which type of Raspberry Pi to build for, the default is RPI2B (which also works for 3B) but you can specify any of the following instead (eg build_ultibo.bat RPIB):

  • RPIA
  • RPIB
  • RPIZERO
  • RPI2B
  • RPI3B

If the build is successful then all of the compiled units end up in the \lib\arm-ultibo folder.

Compiling the examples

Under \examples\corelib the aggcanvas, canvastest and helloworld examples have each been modified to include an Ultibo specific version. As with the library itself there is a build_ultibo.bat batch file in each directory which builds the example for the Ultibo target. These batch files also look for the ULTIBO_DIR environment variable and also allow a command line parameter to specify the type of Raspberry Pi to build for.

An attempt has been made to compile the lion example from \src\corelib\render\software\agg-demos and there is a build-ultibo.bat file in that folder which shows how (same options as above). This demo doesn't work yet because some more platform support is needed for the AggPas demos to run.

Known issues

Building the above examples has revealed a few items that don't seem to work so far, there are probably others but these are the ones that didn't work in the examples:

  • fpgCanvas.GradientFill() - Nothing seems to appear in the final output
  • fpgCanvas.TextWidth() - Returns an extremely large number which is not correct
  • fpgCanvas.Font.TextWidth() - Same as fpgCanvas.TextWidth (probably the same function internally)

What next and how to help

There are several items that need attention in order to move the port forward, primary focus is needed on:

FreeType 1 support

fpGUI and AggPas currently use either FreeType 2 or the WinFont engine for handling true type fonts. The WinFont engine is only available on Windows but FreeType is cross platform. Unfortunately FreeType 2 is provided as a DLL or shared library or as C source code which can't be used by Ultibo at this stage.

FreeType 1 is available in pascal source form and while older and with less features should be usable for true type font support if it can be connected into the AggPas font engine.

Update: As of Ultibo core 1.3.077 the FreeType 2 library is included and available for use, this means that the fpGUI port can also make use of FreeType 2 instead of trying to retrofit the much older FreeType 1 code into fpGUI. Some work has been started on connecting the FreeType 2 support into the Ultibo port of fpGUI but this has not yet been completed.

Basic Window management

fpGUI relies on an underlying window manager (GDI in Windows or X11 in Linux/Mac etc) so in order to get a working graphical interface Ultibo will need some form of window manager to do the same task.

Current thinking is that a new fpg_ultibo_window_manager.pas unit could be added to \src\corelib\ultibo to form the basis of a window manager which allocates and destroys window handles and keeps track of state, size, position, ownership and z-order for each window (Remembering that many visual elements have a window handle, not just the forms themselves). This could also be the logical point to interface with Ultibo for screen rendering and also for mouse and keyboard events which would then be queued to fpGUI for processing.

Mouse and Keyboard support

Ultibo already has the basics of both mouse and keyboard input, some enhancements may be needed to make it all fit together but in general fpGUI expects to receive events via a message queue to say when a key was pressed or the mouse was clicked. A thread that takes the mouse and keyboard data from Ultibo and translates them into fpGUI events is likely to be a good starting point.

Update: As of Ultibo core 2.0.235 support for mouse cursor and text caret is now included in Ultibo, while the implementations provided may not be directly usable in fpGUI they will show how such support can be added to a basic window manager in order to implement the necessary functionality for fpGUI.

The FreeVision port also provides a good reference point for translating the mouse and keyboard devices in Ultibo core to events that can be delivered to a interface framework.

How to help?

Looking at the above might be overwhelming for some or you might be up for a challenge, either way there are things you can do if you want to see a graphical interface available in Ultibo core.

If you have knowledge of fpGUI, AggPas or FreeType and want to delve into the internals of getting something like FreeType 1 support working feel free to jump in and see what you can do. Keep us updated on your progress and anything we can do to help.

If you're not inclined to dig in to the inner workings of fpGUI and AggPas, there is a need for testing of the functions to determine what is and is not working both now and as work progresses. Creating test programs to try out the vast number of functions in both fpGUI and AggPas and providing that information will help to pinpoint what still needs to be fixed. Of course debugging of any existing or new issues would also be extremely helpful.

You might have other ideas you want to try out or other ways to contribute, feel free to get involved in any way that suits you.

Documentation and other info

About

fpGUI Toolkit is a cross-platform GUI toolkit using Free Pascal (Ultibo port)

Resources

License

LGPL-2.1, Unknown licenses found

Licenses found

LGPL-2.1
COPYING.txt
Unknown
COPYING.modifiedLGPL

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Pascal 84.2%
  • Java 7.6%
  • C++ 4.5%
  • SourcePawn 1.3%
  • CSS 0.9%
  • IGOR Pro 0.4%
  • Other 1.1%