2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Helge Norberg, helge.norberg@svt.se
24 #include <common/memory.h>
26 #include "../frame/frame_transform.h"
30 namespace caspar { namespace core {
32 struct interaction_event
33 : public spl::enable_shared_from_this<interaction_event>
35 typedef spl::shared_ptr<const interaction_event> ptr;
39 interaction_event(int source_id)
40 : source_id(source_id)
44 virtual ~interaction_event()
49 struct position_event : public interaction_event
54 position_event(int source_id, double x, double y)
55 : interaction_event(source_id)
60 virtual interaction_event::ptr translate(
61 const frame_transform& transform) const
63 auto translated = ::caspar::core::translate(x, y, transform);
65 if (translated.first == x && translated.second == y)
66 return shared_from_this();
68 return clone(translated.first, translated.second);
71 virtual interaction_event::ptr clone(double new_x, double new_y) const = 0;
74 struct mouse_move_event : public position_event
76 typedef spl::shared_ptr<mouse_move_event> ptr;
78 mouse_move_event(int source_id, double x, double y)
79 : position_event(source_id, x, y)
83 virtual interaction_event::ptr clone(
84 double new_x, double new_y) const override
86 return spl::make_shared<mouse_move_event>(source_id, new_x, new_y);
90 struct mouse_wheel_event : public position_event
92 typedef spl::shared_ptr<mouse_wheel_event> ptr;
94 const int ticks_delta;
96 mouse_wheel_event(int source_id, double x, double y, int ticks_delta)
97 : position_event(source_id, x, y)
98 , ticks_delta(ticks_delta)
102 virtual interaction_event::ptr clone(
103 double new_x, double new_y) const override
105 return spl::make_shared<mouse_wheel_event>(source_id, new_x, new_y, ticks_delta);
109 struct mouse_button_event : public position_event
111 typedef spl::shared_ptr<mouse_button_event> ptr;
117 int source_id, double x, double y, int button, bool pressed)
118 : position_event(source_id, x, y)
124 virtual interaction_event::ptr clone(
125 double new_x, double new_y) const override
127 return spl::make_shared<mouse_button_event>(
128 source_id, new_x, new_y, button, pressed);