Commit Graph

96 Commits

Author SHA1 Message Date
Albrecht Schlosser 7f24a0d6d8 Update docs and screenshot for fl_line_style() (#1016)
As a follow-up to the discussion I used the posted screenshot demo
(thanks to Greg), redesigned it using Fl_Grid, and added it as a
new test program, including Makefiles and CMakeLists.txt.

New file: test/line_style_docs.cxx to create screenshot. Note that the
old test/line_style.cxx is not obsolete, it can be used to test the
line styles interactively.

Docs have been updated in both chapter "Drawing Things" and the
function description.

Also added the new demo to test/demo.menu under "Images for Manual...".
2024-07-21 22:34:02 +02:00
Albrecht Schlosser 175931bccd CMake: simplify compiler detection for '-Wshadow' test 2024-05-01 16:07:58 +02:00
Albrecht Schlosser 576f7bb9cc Enable 'shadow_variables' test on macOS using AppleClang
The CMake compiler ID on macOS is AppleClang rather than Clang.
This commit checks for this compiler ID as well.
2024-04-22 16:54:25 +02:00
Albrecht Schlosser 3fc8875756 Add missing 'x11.H' to exclusion list (STR 2728) 2024-04-18 17:33:57 +02:00
Albrecht Schlosser bb45198413 Test public headers for shadowed variables (STR 2728)
This program is built only when using CMake and a GNU or Clang
compiler to detect shadowed variables in header files.

Developers should fix such warnings whenever they see them during the
build to avoid user reports.
2024-04-18 17:13:09 +02:00
Albrecht Schlosser 193c5285cd Improve linking of test/cairo_test.cxx demo program
With modern CMake libcairo doesn't need to linked explicitly in the
test/cairo_test.cxx demo program. Either '-lcairo' is implied by
linking with fltk::fltk or it is not used at all.

This fixes a linker warning on macOS:
  "ld: warning: ignoring duplicate libraries ..."
2024-03-16 23:24:01 +01:00
Albrecht Schlosser 7bbe75c84e Add another keyboard event test program test/handle_keys.cxx
This program logs all keyboard events to a built-in Fl_Terminal widget.

WIP: version 0.80
2024-03-09 15:17:34 +01:00
Albrecht Schlosser 809ceea075 Fix Cairo related build issues (missing Cairo lib)
... particularly for shared libs
2024-02-09 19:41:45 +01:00
Albrecht Schlosser ede53b8a50 Fix cairo_test-shared build as well (#902) 2024-02-09 17:35:26 +01:00
Albrecht Schlosser 3895068aa1 Fix "cairo_test fails to link due to undefined's" (#902)
Restore "too much optimized" CMake code.

The issue would only be visible if neither FLTK_GRAPHICS_CAIRO nor
FLTK_BACKEND_WAYLAND was active.
2024-02-09 12:38:14 +01:00
Albrecht Schlosser fd5cd80935 Introduce "Modern CMake" in FLTK
This is a big commit and there are too many changes to list them all.
The main changes are:

- rename all CMake build options to 'FLTK_*'
- export library targets with namespace (prefix) 'fltk::'
- standardize shared library target names with suffix '-shared'
- set public build properties on libraries for consumers
- document library names and aliases in README.CMake.txt
- document changes in "Migrating Code from FLTK 1.3 to 1.4"
- partial backwards compatibility for old user projects

Included but not directly related changes:

- fix Windows (Visual Studio) DLL build
- add CMake function fl_debug_target() to show target properties
- don't build test programs if FLTK is a subproject
- internal: reformat CMake code: remove space before '('

Thanks to Matthias and Manolo for their help, testing, and feeback.
2024-02-07 18:37:34 +01:00
Albrecht Schlosser 5df5daf78e Make the 'Forms' compatibility library 'fltk_forms' optional
This library is no longer needed in FLTK itself. There is only one
demo program (test/forms.cxx) that uses it if it is built. The demo
program displays a message if fltk_forms is not available.

The default is 'enabled' for backwards compatibility but this may
be changed to 'disabled' in a future version.
2023-12-20 17:33:37 +01:00
Albrecht Schlosser efe3ea7115 Add Fl_Grid based dialog demo program
This is a new test program for Fl_Grid based layout and a proof of
concept for a future dialog class based on Fl_Grid.
2023-11-18 18:37:55 +01:00
erco77 6842a43a31
Fl_Terminal widget (#800)
Pull Fl_Terminal widget from Greg's fork
2023-11-14 07:01:52 -08:00
Albrecht Schlosser d9798d2840 CMake: Refactor building OpenGL and "shared" demo programs
Define GLDEMO_LIBS and GLDEMO_SHARED: these definitions can be used
  to build OpenGL demo programs that can also be built w/o OpenGL

Examples: fullscreen, handle_events, unittests
2023-11-03 15:40:58 +01:00
Albrecht Schlosser 38871c5b31 Add Fl_Grid widget and test and demo programs
- FL/Fl_Grid.H: header file
- src/Fl_Grid.cxx: implementation

- examples/grid-simple.cxx: simple example program
- test/cube.cxx:            use Fl_Grid for layout
- test/grid_alignment.cxx:  test cell alignment and other functions
- test/grid_buttons.cxx:    demo program as discussed in fltk.general
- test/grid_login.cxx:      like test/flex_login.cxx but with Fl_Grid
- test/flex_login.cxx:      modified to match test/grid_login.cxx
2023-10-16 22:18:24 +02:00
Albrecht Schlosser 1fd6f0dd3a Fix STR 3458: "GLUT compatibility mode segfaults"
... "when there's no current window".

Silently ignore GLUT function calls that need a current window if the
current window is NULL, return 0 from functions that return an 'int'.

Check if window is shown in Fl_X11_Gl_Window_Driver::swap_buffers().
This would issue "XRequest.nnn: GLXBadDrawable 0x0" on X11 otherwise.

Note: the chosen implementation to ignore GLUT calls silently appears
to be compatible with GLUT (3.7) whereas FreeGLUT 3.0 would issue error
messages and exit. The latter could be implemented as well but would
be much more work.
2023-10-07 17:14:11 +02:00
Albrecht Schlosser ede381c005 Fix Visual Studio shared library build
Todo: fluid-shared can't (yet) be built agains the shared fltk lib
  because of some linker errors. Needs investigation.

Note: fluid-shared is basically a test program to demonstrate linking
  against the shared FLTK libs but doesn't work yet using VS (MSVC).
  This is no problem for the functionality.
2023-09-12 23:18:46 +02:00
Matthias Melcher e8b378302c Undoing previous changes 2023-08-15 22:59:07 +02:00
Matthias Melcher 3b093e895b Lot's of changes, must rethink UI. 2023-08-15 17:09:51 +02:00
Matthias Melcher 0de186e614 Sudoku into smaller pieces. 2023-08-15 17:09:51 +02:00
Matthias Melcher 0c8083a06d Adding generator 2023-08-15 17:09:51 +02:00
Albrecht Schlosser 5175192755 CMake: build shared libs with OPTION_CAIROEXT (issue #250)
- remove separate libfltk_cairo to avoid cyclic dependencies, but
- keep a dummy libfltk_cairo in 1.4.0 for backwards compatibility
- move cairo/Fl_Cairo.cxx to src/Fl_Cairo.cxx
- add preliminary Cairo support for Visual Studio (MSVC)

Static linking is not affected by this change, but users building
with hand-made Makefiles will have to remove libfltk_cairo starting
with FLTK 1.4.0. The dummy library can be linked for backwards
compatibility but it will be removed later (in 1.4.x or 1.5.0).

The shared FLTK library libfltk.{so|dylib|dll|..} depends on libcairo
if and only if FLTK is built with one of the Cairo options. This has
always been the case for OPTION_CAIROEXT but is now also true if only
OPTION_CAIRO is selected, i.e. FLTK programs linked with a Cairo
enabled shared FLTK library will also be linked with libcairo. The same
is true for configure options --enable-cairo and --enable-cairoext,
respectively.

Preliminary Cairo support for MSVC now detects a Cairo installation
using the CMake variable FLTK_CAIRO_DIR which must be set by the user.
Note that this feature is temporary and may be changed in the future
for a better and more comfortable version.
2023-03-09 17:34:05 +01:00
Matthias Melcher 9f87af8ad9
Fl_String refactoring and extension (#683)
- add true unittest and Fl_String testing
- interface and printout are similar to gtest
  without requiring external linkage.
  just run `unittest --core`.
- new Fl_String API
- extended API to fl_input_str and fl_password_str
- co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
2023-02-23 15:42:05 +01:00
wcout 2ddfd9d949
Animated GIF support (Fl_Anim_GIF_Image class) (#375) 2023-01-21 17:27:58 +01:00
Albrecht Schlosser 78cf29ba29 Improve and extend fl_contrast() (#370)
- Add internal fl_contrast_cielab() as the new default.
- Keep old function as internal fl_contrast_legacy().
- Add fl_contrast_mode() to switch between fl_contrast() functions.
- Add fl_contrast_level() to fine tune fl_contrast() per mode.
- Add option to register and use a custom contrast function.
- Add test/contrast.cxx test program.
- Move all fl_contrast() related code to a new file src/fl_contrast.cxx.
- Add fl_lightness() convenience function for perceived lightness.
- Add fl_luminance() convenience function for physical luminance.
2022-12-28 18:16:23 +01:00
Matthias Melcher 08f6741d7b
Make unittest conform to CMP (#597)
Update unittest README
2022-12-17 13:16:57 +01:00
Greg Ercolano 821d2fdf82 Added Unicode Boxes unittest and README-unittests.txt
This test helps check for issues with multiline widgets
drawing text properly.

The README-unittests.txt was added to help developers
add new unit tests easily.
2022-12-11 10:18:06 -08:00
Albrecht Schlosser f37aca15e9 Add Fl_Flex widget from Karsten Pedersen (issue #255)
This work is based on the repository and latest commit:
  https://github.com/osen/FL_Flex.git

  commit 36e4ed75a00daac825b87e81295818b4650991f5
  Author: Karsten Pedersen <...>
  Date:   Fri Apr 23 12:06:16 2021 +0000

    Added Fltk (LGPL) license.

This widget is similar to Fl_Pack and supports either one row or one
column of widgets but has some more features. Test and demo programs
are included:

  test/flex_login.cxx: simple "login window" demo program
  test/flex_demo.cxx:  slightly more complex demo program

The original demo programs can still be compiled and built with
the new widget provided you '#include <FL/Fl_Flex.H>'.
Backwards compatible methods are included (except debug()).

The original widget has been modified to match FLTK standards and
enhanced in several ways, including:

- support box frames
- add HORIZONTAL and VERTICAL enum values (as in Fl_Pack)
- add horizontal() method (as in Fl_Pack)
- use type() rather than internal 'direction' variable
- add standard widget constructor (x, y, w, h, label)
- add margin and gap accessors rather than hard coding constants
- improve test and demo programs
- add documentation
- replace <vector> with array as required by FLTK CMP
- rename camelCase method names, keeping old names for compatibility:
  - change 'setSize(Fl_Widget*, int)'   to 'set_size(Fl_Widget*, int)'
  - change 'bool isSetSize(Fl_Widget*)' to 'int set_size(Fl_Widget*)'
- remove debug() method
- add a way to "unset" fixed size: set_size(Fl_Widget *, 0)
- add layout() method to force recalculation of children
- unify resizeRow() and resizeCol() methods to avoid code duplication
- improve widget size calculation.
2022-08-01 15:33:20 +02:00
Albrecht Schlosser 9e147fe8c0 Fix build of test/unittests with shared libraries
- set variables UNITTEST_LIBS and UNITTEST_LIBS_SHARED appropriately
- use these variables in build instructions

This includes normal and shared builds with and w/o OpenGL.
2022-04-09 17:19:20 +02:00
Matthias Melcher db0a1f4bae
OpenGL implementation of all `fl_` "Drawing Fast Shapes" graphics calls (#385)
* Fix build system for unites,

* Updated unittest to check OpenGL drawing.

Making sure that OpenGL drawing is exactly the same
as native drawing to make FLTK widget rendering
look the same in GL windows.

* Make OpenGL optional.

* Implemented clipping in OpenGL

* unites drawing fast shapes

* Fixed CMake

* Updating unittest.

Added tests for fl_pi and fl_arc (int)
Renamed tab to render complex shapes.

* Improved OpenGL FLTK drawing emulation.

* Fixed GTK ROUND DOWN BOX

* Fixing Makefile for unittest

* Correctly aligning OpenGL text.

* Fixed text alignment in GL windows.

Explained the "FLTK over GL " example in Cube.

* Overlapping test.

* Better GL graphics alignment.

* Drawing the focus rect.

* Adding Alpha Channel support for GL.

* Added FLTK-on-GL documentation.
2022-02-06 15:22:24 +01:00
Albrecht Schlosser 04ccc8cc46 Remove experimental platforms Android, Pico, SDL (PR #376)
... as discussed in fltk.coredev: "FLTK 1.4.0 release schedule"
https://groups.google.com/g/fltkcoredev/c/PDbHTRpXVh0/m/JqboexZ_AwAJ
2022-01-23 18:12:47 +01:00
engelsman 2d18c6f650
Documentation on widget coordinates and layout, plus new test programs (#304)
Add coordinates and layout section to user manual

add section to user manual to clarify the use of window-relative
coordinates in both Fl_Group and Fl_Window containers, and include
brief descriptions of current layout manager widgets in one place.

add test/coordinates.cxx, test/wizard.cxx and related screenshots
under documentation/src.

update CMakeLists.txt, Makefile and .gitignore for new files.

Co-authored-by: Albrecht Schlosser <albrechts.fltk@online.de>
2021-12-08 15:00:33 +01:00
Albrecht Schlosser 0bc06e8f1a Reformat and move clipboard demo from examples to test folder
The clipboard demo is more a test program than an example and very
useful even if the examples are not built.

Also update dependencies.
2021-11-18 13:44:41 +01:00
Duncan Gibson 7407d9c8d0 Add new resize example to test and dox (PR #165)
add example(s) showing Albrecht's innovative overlap resizable
technique to the "How does resizing work?" documentation and tests

See "resizable question" original discussion thread under:
https://www.fltk.org/newsgroups.php?gfltk.general+v:39635
2021-11-08 16:18:58 +01:00
Albrecht Schlosser cf20474d7c CMake: Simplify adding test programs for developers
The intention is to make it more convenient for developers to add
one or more test programs for their tests by editing only one
variable (extra_tests).
2021-10-06 18:17:55 +02:00
Albrecht Schlosser 787c67afea macOS: fix fltk_cairo shared library (issue #250)
- add missing dependencies to build the shared libfltk_cairo(.dylib)
- remove incorrect dependency on cairo from libfltk
- add cairo_test-shared demo (linked with shared libs)
2021-07-12 20:05:07 +02:00
Albrecht Schlosser 773467dee4 Refactor macOS bundle generation to avoid "quarantine"
macOS Big Sur 11.3 introduced a new "security feature" such that
app bundles created from existing bundle templates in downloaded
files (tar distibutions, expanded) could no longer be executed
without unsetting the "quarantine" attribute. This commit fixes
this by creating all bundles from scratch.

Known *workaround* for older tarballs and snapshots:

  $ xattr -d -r com.apple.quarantine xxx.app
2021-05-13 16:18:13 +02:00
Albrecht Schlosser 7b70d2c90d Fix handle_events demo build w/o OpenGL
test/handle_events.cxx can optionally be built with an Fl_Gl_Window,
  but this doesn't work if OpenGL support (libfltk_gl) is disabled.
2021-04-22 12:34:49 +02:00
Albrecht Schlosser b4c464f71b Add event handling test and demo program
This is intended to be used as
  (a) an example of event handling and
  (b) a test program to visualize many event related variables

This first version is compatible with FLTK 1.3.x but lacks the screen
scaling factor under 1.3.x (which is always assumed to be 100%).

Note: this does not reflect any system or monitor related settings.
2021-02-08 15:46:35 +01:00
Albrecht Schlosser 3b9a04ae2e CMake: add examples folder to build (optional)
- replace misnamed option 'OPTION_BUILD_EXAMPLES' with 'FLTK_BUILD_TEST'
- add option 'FLTK_BUILD_EXAMPLES' to build apps in examples folder
- move examples/fltk-versions.cxx to test/fltk-versions.cxx
- [Travis-CI] enable option 'FLTK_BUILD_EXAMPLES' for automatic builds
2020-08-21 18:55:12 +02:00
Albrecht Schlosser f3005a44f8 CMake: move test executables to build/bin/test 2020-08-21 17:10:30 +02:00
Albrecht Schlosser f357f4311c Use local images in test/help_dialog(.html)
- create subdir test/images
- copy images used by test/help_dialog to this subdir
- fix image URL's in test/help_dialog.html accordingly

CMake: copy the entire test/images folder to the <build>/data folder

This enables the demo test/help_dialog.cxx to find its images.
2020-07-23 01:53:24 +02:00
Albrecht Schlosser 0015e64671 macOS: don't add resource files to demo.app
Resources like demo.menu and help_dialog.html are no longer read
from the bundle directory on macOS. They are read from the build
folder build/data or in case of classic autoconf/make builds from
the source directory. We don't need to copy the files into the
bundle folder, they are copied to the build/data folder on all
platforms anyway.
2020-07-22 23:36:20 +02:00
Albrecht Schlosser af7f485e06 Consolidate test/demo for all build systems
This is an attempt to unify the code for all build systems (CMake,
autotools with make), platforms (operating systems) and toolchains
(make + gcc/clang, Visual Studio IDE, Xcode ...) to avoid duplicate
code and clarify the differences for future devs and to simplify
maintenance.

The goal is to minimize the platform specific code.

Much of the new code are comments to describe the different situations.
The main program does now all the "hard work" to construct the paths
necessary to access the other applications and data files.

Use macOS specific code to determine the application path (app_path)
in main() instead of function dobut(), when test apps are activated.

Remove obsolete comments and dead code.

Tested on Windows and Linux with both autotools/configure/make
and CMake with make (Linux + MinGW), Visual Studio.
2020-07-21 11:11:03 +02:00
Duncan Gibson c132ac564e add resize examples as per STR3433
add example code for creating images for resize.dox
based on Article #415: How does resizing work?
https://www.fltk.org/articles.php?L415

see also https://www.fltk.org/str.php?L3433
2020-07-20 14:08:47 +02:00
Albrecht Schlosser 4858882e1e CMake: simplify create_example macro
- move target (demo) specific code from macro to CMakeLists.txt
- refactor macOS specific code for a cleaner structure
- improve documentation

Note: CMake ignores platform specific code like creating bundles on
other platforms, hence the entire code could be simplified (less
conditional code)
2020-07-20 11:02:01 +02:00
Albrecht Schlosser 956a3bb160 CMake: simplify copying of test and demo files 2020-07-18 16:07:30 +02:00
Albrecht Schlosser c380a91361 Windows: add icon to sudoku.exe (PR #36)
The changes proposed by Tadej Panjtar (tpanj) were obsolete WRT
current Git repo. Thanks to tpanj anyway, I did also apply the
simplifications of sudoku.rc.
2020-07-16 12:25:51 +02:00
ManoloFLTK 13c1923b2a Restore file icons to 3 macOS test apps who have one 2020-07-15 17:06:05 +02:00