Program Listing for File scroll_axis.h

↰ Return to documentation for file (/home/docs/checkouts/readthedocs.org/user_builds/canonical-mir-documentation/checkouts/2.26/include/common/mir/events/scroll_axis.h)

/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 2 or 3,
 * as published by the Free Software Foundation.
 *
 * This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MIR_EVENTS_SCROLL_AXIS_H_
#define MIR_EVENTS_SCROLL_AXIS_H_

#include <mir/geometry/dimensions.h>

namespace mir
{
namespace events
{

template<typename Tag>
struct ScrollAxisV1
{
    ScrollAxisV1()
        : stop{false}
    {
    }

    ScrollAxisV1(
        mir::geometry::generic::Value<float, Tag> precise,
        mir::geometry::generic::Value<int, Tag> discrete,
        mir::geometry::generic::Value<int, Tag> value120,
        bool stop)
        : precise{precise},
          discrete{discrete},
          value120{value120},
          stop{stop}
    {
    }

    ScrollAxisV1(
        mir::geometry::generic::Value<float, Tag> precise,
        mir::geometry::generic::Value<int, Tag> discrete,
        bool stop)
        : precise{precise},
          discrete{discrete},
          value120{discrete * 120},
          stop{stop}
    {
    }

    auto operator==(ScrollAxisV1 const& other) const -> bool {
        return precise  == other.precise &&
               discrete == other.discrete &&
               value120 == other.value120 &&
               stop     == other.stop;
    }

    auto operator!=(ScrollAxisV1 const& other) const -> bool {
        return !(*this == other);
    }

    mir::geometry::generic::Value<float, Tag> precise;
    mir::geometry::generic::Value<int, Tag> discrete;
    mir::geometry::generic::Value<int, Tag> value120;
    bool stop;
};

using ScrollAxisV1H = ScrollAxisV1<geometry::DeltaXTag>;
using ScrollAxisV1V = ScrollAxisV1<geometry::DeltaYTag>;

template<typename Tag>
using ScrollAxis = ScrollAxisV1<Tag>;
using ScrollAxisH = ScrollAxis<geometry::DeltaXTag>;
using ScrollAxisV = ScrollAxis<geometry::DeltaYTag>;

}
}

#endif // MIR_EVENTS_SCROLL_AXIS_H_