Add Pen event handler stub.

This is a fallback for platforms that don't
support pens and tablets yet.
This commit is contained in:
Matthias Melcher 2025-11-04 20:38:53 +01:00
parent c987ffa1d6
commit b2443410a0
3 changed files with 117 additions and 16 deletions

View File

@ -59,6 +59,8 @@ namespace Pen {
If a bit is clear, the corresponding event value will not be set.
*/
enum Features : uint32_t {
/// Return this if this implementation of FLTK does not support pens and tablets.
NONE = 0x0000,
/// Set if FLTK supports tablets and pens on this platform
SUPPORTED = 0x0001,
/// Set if the system found a pen and/or tablet device
@ -362,43 +364,65 @@ FL_EXPORT extern State event_trigger();
} // namespace Fl
/**
* \brief Bitwise OR operator for Features enum.
* \param lhs Left-hand side feature flags
* \param rhs Right-hand side feature flags
* \return Combined feature flags
\brief Bitwise OR operator for Features enum.
\param lhs Left-hand side feature flags
\param rhs Right-hand side feature flags
\return Combined feature flags
*/
inline constexpr Fl::Pen::Features operator|(Fl::Pen::Features lhs, Fl::Pen::Features rhs) {
return static_cast<Fl::Pen::Features>(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
}
/**
* \brief Bitwise AND operator for Features enum.
* \param lhs Left-hand side feature flags
* \param rhs Right-hand side feature flags
* \return Intersection of feature flags
\brief Bitwise AND operator for Features enum.
\param lhs Left-hand side feature flags
\param rhs Right-hand side feature flags
\return Intersection of feature flags
*/
inline constexpr Fl::Pen::Features operator&(Fl::Pen::Features lhs, Fl::Pen::Features rhs) {
return static_cast<Fl::Pen::Features>(static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs));
}
/**
* \brief Bitwise OR operator for State enum.
* \param lhs Left-hand side state flags
* \param rhs Right-hand side state flags
* \return Combined state flags
\brief Bitwise OR assignment operator for Features enum.
\param lhs Left-hand side feature flags (modified in place)
\param rhs Right-hand side feature flags
\return Reference to modified lhs
*/
inline Fl::Pen::Features& operator|=(Fl::Pen::Features& lhs, Fl::Pen::Features rhs) {
lhs = lhs | rhs;
return lhs;
}
/**
\brief Bitwise OR operator for State enum.
\param lhs Left-hand side state flags
\param rhs Right-hand side state flags
\return Combined state flags
*/
inline constexpr Fl::Pen::State operator|(Fl::Pen::State lhs, Fl::Pen::State rhs) {
return static_cast<Fl::Pen::State>(static_cast<uint32_t>(lhs) | static_cast<uint32_t>(rhs));
}
/**
* \brief Bitwise AND operator for State enum.
* \param lhs Left-hand side state flags
* \param rhs Right-hand side state flags
* \return Intersection of state flags
\brief Bitwise AND operator for State enum.
\param lhs Left-hand side state flags
\param rhs Right-hand side state flags
\return Intersection of state flags
*/
inline constexpr Fl::Pen::State operator&(Fl::Pen::State lhs, Fl::Pen::State rhs) {
return static_cast<Fl::Pen::State>(static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs));
}
/**
\brief Bitwise OR assignment operator for State enum.
\param lhs Left-hand side state flags (modified in place)
\param rhs Right-hand side state flags
\return Reference to modified lhs
*/
inline Fl::Pen::State& operator|=(Fl::Pen::State& lhs, Fl::Pen::State rhs) {
lhs = lhs | rhs;
return lhs;
}
#endif // !Fl_core_pen_events_H

View File

@ -241,6 +241,7 @@ if(FLTK_USE_X11 AND NOT FLTK_USE_WAYLAND)
drivers/Xlib/Fl_Xlib_Copy_Surface_Driver.cxx
drivers/Xlib/Fl_Xlib_Image_Surface_Driver.cxx
drivers/X11/fl_X11_platform_init.cxx
drivers/Stubs/Fl_Stubs_Pen_Events.cxx
Fl_x.cxx
fl_dnd_x.cxx
Fl_Native_File_Chooser_FLTK.cxx
@ -317,6 +318,7 @@ elseif(FLTK_USE_WAYLAND)
drivers/Wayland/fl_wayland_clipboard_dnd.cxx
drivers/Wayland/fl_wayland_platform_init.cxx
drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
drivers/Stubs/Fl_Stubs_Pen_Events.cxx
Fl_Native_File_Chooser_FLTK.cxx
Fl_Native_File_Chooser_GTK.cxx
)
@ -369,6 +371,7 @@ elseif(APPLE)
drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
drivers/Posix/Fl_Posix_System_Driver.cxx
drivers/Darwin/Fl_Darwin_System_Driver.cxx
drivers/Stubs/Fl_Stubs_Pen_Events.cxx
Fl_get_key_mac.cxx
drivers/Darwin/fl_macOS_platform_init.cxx
)
@ -403,6 +406,7 @@ else()
drivers/GDI/Fl_GDI_Graphics_Driver_vertex.cxx
drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx
drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx
drivers/Stubs/Fl_Stubs_Pen_Events.cxx
Fl_win32.cxx
fl_dnd_win32.cxx
Fl_Native_File_Chooser_WIN32.cxx

View File

@ -0,0 +1,73 @@
//
// Definition of default Pen/Tablet event driver.
//
// Copyright 2025 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//
#include <config.h>
#include <FL/platform.H>
#include <FL/core/pen_events.H>
#include <FL/Fl.H>
class Fl_Widget;
namespace Fl {
namespace Pen {
// double e_pressure_;
} // namespace Pen
} // namespace Fl
using namespace Fl::Pen;
Features Fl::Pen::features() { return NONE; }
void Fl::Pen::subscribe(Fl_Widget*, bool) { }
void Fl::Pen::unsubscribe(Fl_Widget*) { }
void Fl::Pen::grab(Fl_Widget*) { }
void Fl::Pen::release() { }
double Fl::Pen::event_x() { return static_cast<double>(Fl::event_x()); }
double Fl::Pen::event_y() { return static_cast<double>(Fl::event_y()); }
double Fl::Pen::event_x_root() { return static_cast<double>(Fl::event_x_root()); }
double Fl::Pen::event_y_root() { return static_cast<double>(Fl::event_y_root()); }
int Fl::Pen::event_id() { return -1; }
double Fl::Pen::event_pressure() { return 0.0; }
double Fl::Pen::event_tangential_pressure() { return 0.0; }
double Fl::Pen::event_tilt_x() { return 0.0; }
double Fl::Pen::event_tilt_y() { return 0.0; }
double Fl::Pen::event_twist() { return 0.0; }
double Fl::Pen::event_proximity() { return 0.0; }
State Fl::Pen::event_state() { return static_cast<State>(0); }
State Fl::Pen::event_trigger() { return static_cast<State>(0); }