gtkmm  4.8.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::EventControllerScroll Class Reference

Event controller for scroll events. More...

#include <gtkmm/eventcontrollerscroll.h>

Inheritance diagram for Gtk::EventControllerScroll:
Inheritance graph
[legend]

Public Types

enum class  Flags {
  NONE = 0x0 ,
  VERTICAL = 1 << 0 ,
  HORIZONTAL = 1 << 1 ,
  DISCRETE = 1 << 2 ,
  KINETIC = 1 << 3 ,
  BOTH_AXES = 0x3
}
 Describes the behavior of a Gtk::EventControllerScroll. More...
 

Public Member Functions

 EventControllerScroll (EventControllerScroll && src) noexcept
 
EventControllerScrolloperator= (EventControllerScroll && src) noexcept
 
 ~EventControllerScroll () noexcept override
 
GtkEventControllerScroll * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkEventControllerScroll * gobj () const
 Provides access to the underlying C GObject. More...
 
GtkEventControllerScroll * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
void set_flags (Flags flags)
 Sets the flags conditioning scroll controller behavior. More...
 
Flags get_flags () const
 Gets the flags conditioning the scroll controller behavior. More...
 
Gdk::ScrollUnit get_unit () const
 Gets the scroll unit of the last signal_scroll() signal received. More...
 
Glib::PropertyProxy< Flagsproperty_flags ()
 The flags affecting event controller behavior. More...
 
Glib::PropertyProxy_ReadOnly< Flagsproperty_flags () const
 The flags affecting event controller behavior. More...
 
Glib::SignalProxy< void()> signal_scroll_begin ()
 
Glib::SignalProxy< bool(double, double)> signal_scroll ()
 
Glib::SignalProxy< void()> signal_scroll_end ()
 
Glib::SignalProxy< void(double, double)> signal_decelerate ()
 
- Public Member Functions inherited from Gtk::EventController
 EventController (EventController && src) noexcept
 
EventControlleroperator= (EventController && src) noexcept
 
 ~EventController () noexcept override
 
GtkEventController * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkEventController * gobj () const
 Provides access to the underlying C GObject. More...
 
GtkEventController * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Widgetget_widget ()
 Returns the Gtk::Widget this controller relates to. More...
 
const Widgetget_widget () const
 Returns the Gtk::Widget this controller relates to. More...
 
void reset ()
 Resets the controller to a clean state. More...
 
PropagationPhase get_propagation_phase () const
 Gets the propagation phase at which controller handles events. More...
 
void set_propagation_phase (PropagationPhase phase)
 Sets the propagation phase at which a controller handles events. More...
 
PropagationLimit get_propagation_limit () const
 Gets the propagation limit of the event controller. More...
 
void set_propagation_limit (PropagationLimit limit)
 Sets the event propagation limit on the event controller. More...
 
Glib::ustring get_name () const
 Gets the name of controller. More...
 
void set_name (const Glib::ustring & name)
 Sets a name on the controller that can be used for debugging. More...
 
Glib::RefPtr< const Gdk::Eventget_current_event () const
 Returns the event that is currently being handled by the controller. More...
 
guint32 get_current_event_time () const
 Returns the timestamp of the event that is currently being handled by the controller. More...
 
Glib::RefPtr< Gdk::Deviceget_current_event_device ()
 Returns the device of the event that is currently being handled by the controller. More...
 
Glib::RefPtr< const Gdk::Deviceget_current_event_device () const
 Returns the event that is currently being handled by the controller. More...
 
Gdk::ModifierType get_current_event_state () const
 Returns the modifier state of the event that is currently being handled by the controller. More...
 
Glib::PropertyProxy_ReadOnly< Widget * > property_widget () const
 The widget receiving the Gdk::Events that the controller will handle. More...
 
Glib::PropertyProxy< PropagationPhaseproperty_propagation_phase ()
 The propagation phase at which this controller will handle events. More...
 
Glib::PropertyProxy_ReadOnly< PropagationPhaseproperty_propagation_phase () const
 The propagation phase at which this controller will handle events. More...
 
Glib::PropertyProxy< PropagationLimitproperty_propagation_limit ()
 The limit for which events this controller will handle. More...
 
Glib::PropertyProxy_ReadOnly< PropagationLimitproperty_propagation_limit () const
 The limit for which events this controller will handle. More...
 
Glib::PropertyProxy< Glib::ustring > property_name ()
 The name for this controller, typically used for debugging purposes. More...
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_name () const
 The name for this controller, typically used for debugging purposes. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< EventControllerScrollcreate ()
 
- Static Public Member Functions inherited from Gtk::EventController
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Protected Member Functions

 EventControllerScroll ()
 
- Protected Member Functions inherited from Gtk::EventController
 EventController ()
 There is no create() method that corresponds to this constructor, because only derived classes shall be created. More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::EventControllerScrollwrap (GtkEventControllerScroll * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Event controller for scroll events.

Gtk::EventControllerScroll is an event controller meant to handle scroll events from mice and touchpads. It is capable of handling both discrete and continuous scroll events, abstracting them both on the signal_scroll() signal (deltas in the discrete case are multiples of 1).

In the case of continuous scroll events, EventControllerScroll encloses all signal_scroll() events between two signal_scroll_begin() and signal_scroll_end() signals.

The behavior of the event controller can be modified by the flags given at creation time, or modified at a later point through set_flags() (e.g. because the scrolling conditions of the widget changed).

The controller can be set up to emit motion for either/both vertical and horizontal scroll events through Gtk::EventControllerScroll::Flags::VERTICAL, Gtk::EventControllerScroll::Flags::HORIZONTAL and Gtk::EventControllerScroll::Flags::BOTH_AXES. If any axis is disabled, the respective signal_scroll() delta will be 0. Vertical scroll events will be translated to horizontal motion for the devices incapable of horizontal scrolling.

The event controller can also be forced to emit discrete events on all devices through Gtk::EventControllerScroll::Flags::DISCRETE. This can be used to implement discrete actions triggered through scroll events (e.g. switching across combobox options).

The Gtk::EventControllerScroll::Flags::KINETIC flag toggles the emission of the signal_decelerate() signal, emitted at the end of scrolling with two X/Y velocity arguments that are consistent with the motion that was received.

Since gtkmm 3.94:

Constructor & Destructor Documentation

◆ EventControllerScroll() [1/2]

Gtk::EventControllerScroll::EventControllerScroll ( EventControllerScroll &&  src)
noexcept

◆ ~EventControllerScroll()

Gtk::EventControllerScroll::~EventControllerScroll ( )
overridenoexcept

◆ EventControllerScroll() [2/2]

Gtk::EventControllerScroll::EventControllerScroll ( )
protected

Member Function Documentation

◆ create()

static Glib::RefPtr<EventControllerScroll> Gtk::EventControllerScroll::create ( )
static

◆ get_flags()

Flags Gtk::EventControllerScroll::get_flags ( ) const

Gets the flags conditioning the scroll controller behavior.

Returns
The controller flags.

◆ get_type()

static GType Gtk::EventControllerScroll::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_unit()

Gdk::ScrollUnit Gtk::EventControllerScroll::get_unit ( ) const

Gets the scroll unit of the last signal_scroll() signal received.

Always returns Gdk::ScrollUnit::WHEEL if the Gtk::EventControllerScroll::Flags::DISCRETE flag is set.

Since gtkmm 4.8:
Returns
The scroll unit.

◆ gobj() [1/2]

GtkEventControllerScroll* Gtk::EventControllerScroll::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkEventControllerScroll* Gtk::EventControllerScroll::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkEventControllerScroll* Gtk::EventControllerScroll::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

EventControllerScroll& Gtk::EventControllerScroll::operator= ( EventControllerScroll &&  src)
noexcept

◆ property_flags() [1/2]

Glib::PropertyProxy< Flags > Gtk::EventControllerScroll::property_flags ( )

The flags affecting event controller behavior.

Default value: Gtk::EventControllerScroll::Flags::NONE

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_flags() [2/2]

Glib::PropertyProxy_ReadOnly< Flags > Gtk::EventControllerScroll::property_flags ( ) const

The flags affecting event controller behavior.

Default value: Gtk::EventControllerScroll::Flags::NONE

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ set_flags()

void Gtk::EventControllerScroll::set_flags ( Flags  flags)

Sets the flags conditioning scroll controller behavior.

Parameters
flagsFlags affecting the controller behavior.

◆ signal_decelerate()

Glib::SignalProxy<void(double, double)> Gtk::EventControllerScroll::signal_decelerate ( )
Slot Prototype:
void on_my_decelerate(double vel_x, double vel_y)

Flags: Run First

Emitted after scroll is finished if the Gtk::EventControllerScroll::Flags::KINETIC flag is set.

vel_x and vel_y express the initial velocity that was imprinted by the scroll events. vel_x and vel_y are expressed in pixels/ms.

Parameters
vel_xX velocity.
vel_yY velocity.

◆ signal_scroll()

Glib::SignalProxy<bool(double, double)> Gtk::EventControllerScroll::signal_scroll ( )
Slot Prototype:
bool on_my_scroll(double dx, double dy)

Flags: Run Last

Signals that the widget should scroll by the amount specified by dx and dy.

For the representation unit of the deltas, see Gtk::EventControllerScroll::get_unit().

Parameters
dxX delta.
dyY delta.
Returns
true if the scroll event was handled, false otherwise.

◆ signal_scroll_begin()

Glib::SignalProxy<void()> Gtk::EventControllerScroll::signal_scroll_begin ( )
Slot Prototype:
void on_my_scroll_begin()

Flags: Run First

Signals that a new scrolling operation has begun.

It will only be emitted on devices capable of it.

◆ signal_scroll_end()

Glib::SignalProxy<void()> Gtk::EventControllerScroll::signal_scroll_end ( )
Slot Prototype:
void on_my_scroll_end()

Flags: Run First

Signals that a scrolling operation has finished.

It will only be emitted on devices capable of it.

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gtk::EventControllerScroll > wrap ( GtkEventControllerScroll *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.