/* Copyright (C) 2018 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/eventcontroller.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/eventcontroller_p.h)

namespace Gtk
{
/** 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.
 * 
 * @newin{3,94}
 *
 * @ingroup Gestures
 */
class GTKMM_API EventControllerScroll : public EventController
{
  _CLASS_GOBJECT(EventControllerScroll, GtkEventControllerScroll, GTK_EVENT_CONTROLLER_SCROLL, EventController, GtkEventController, , , GTKMM_API)

protected:
  _CTOR_DEFAULT

public:
  _WRAP_ENUM(Flags, GtkEventControllerScrollFlags, decl_prefix GTKMM_API)

  _WRAP_CREATE()

  _WRAP_METHOD(void set_flags(Flags flags), gtk_event_controller_scroll_set_flags)
  _WRAP_METHOD(Flags get_flags() const, gtk_event_controller_scroll_get_flags)
  _WRAP_METHOD(Gdk::ScrollUnit get_unit() const, gtk_event_controller_scroll_get_unit)

  _WRAP_PROPERTY("flags", Flags)

  // no_default_handler because GtkEventControllerScrollClass is private.
  _WRAP_SIGNAL(void scroll_begin(), "scroll-begin", no_default_handler)
  _WRAP_SIGNAL(bool scroll(double dx, double dy), "scroll", no_default_handler)
  _WRAP_SIGNAL(void scroll_end(), "scroll-end", no_default_handler)
  _WRAP_SIGNAL(void decelerate(double vel_x, double vel_y), "decelerate", no_default_handler)

  // There are no vfuncs.
};

} // namespace Gtk
