FLTK logo

[fltk.coredev] WIP: new Cairo support features

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

WIP: new Cairo support features Albrecht Schlosser Mar 21, 2023  
  Hi all,

I'm currently working on new "Cairo support" features. The main goal is to support users who want to use Cairo in FLTK windows and widgets w/o the need to configure FLTK for Cairo with configure --enable-cairo, --enable-cairoext, or CMake options OPTION_CAIRO and OPTION_CAIROEXT.

The current status is that I have completed support to draw in windows and widgets, roughly equivalent to our current Cairo support. Users can use Cairo drawing in their own subclasses of windows and widgets using stock FLTK libraries. I don't want to bother you with too many details, but if you're interested, this is all in my branch Fl_Cairo2a on my fork: https://github.com/Albrecht-S/fltk/tree/Fl_Cairo2a. Note that building the full library currently fails, but this is a known issue and has nothing to do with the new functionality (only demo programs should fail).

I could now finish this, but I would like to add a feature to draw in other surfaces than the active window, like Fl_Image_Surface, Fl_Copy_Surface and siblings.

My current implementation works for Windows but I need help for other platforms. If anybody can help I would appreciate this very much.

Details can be found here: https://github.com/Albrecht-S/fltk/blob/676743ea6c6819f67da08bcc89158aed6220de4e/test/cairo2_image.cxx#L45

The function below: cairo_t *cairo_context(Fl_Image_Surface *surf) works so far for Windows but for no other platform. I'd like to have this completed for macOS, Linux (X11), and Wayland. Once I have the basics, I intend to put this code into appropriate FLTK methods.

The output on Windows looks like this:


The inner (smallest) square is drawn using Cairo and is missing on all platforms other than Windows. Window resizing and zooming (ctrl/+/-/0) works well.

I could probably figure this out myself for X11 and even on macOS, but I don't think that I can do this easily for Wayland. Maybe we need accessor methods for the Cairo surface or Cairo context on Wayland.

Manolo and others, can you help to complete the method mentioned above?

Thanks you all for helping in advance.

A note to the implementation: since the FLTK library can be a stock FLTK build w/o direct Cairo support the user is responsible for b

The relevant code follows, just in case ...

// Create a Cairo context that can be used on an FLTK image surface.
// In this demo we assume that the surface is the "current surface" after
// 'Fl_Surface_Device::push_current(surf)' but it would be great if it
// worked without this assumption.
cairo_t *cairo_context(Fl_Image_Surface *surf) {
// Windows: proof of concept, tested, works well:
#if defined(_WIN32)
cairo_surface_t *cairo_surface = cairo_win32_surface_create((HDC)fl_gc);
cairo_t *cairo_context = cairo_create(cairo_surface);
return cairo_context;
#endif
// other platforms still need implementation ...
return NULL; // not yet implemented
} // cairo_context(Fl_Image_Surface *surf)

    As you can see the code for Windows is implemented, all other
    platforms are missing.

Thanks for reading so far and for any help, even if it's only for one missing platform.

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/aecbe337-e629-b95a-d851-f961d9e12711%40online.de.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.