summaryrefslogtreecommitdiff
path: root/src/player/CursorEvent.cpp
blob: ee4ba92ffc9e2cf5484c9b1abb42ca0fce5ad483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
//  libavg - Media Playback Engine. 
//  Copyright (C) 2003-2014 Ulrich von Zadow
//
//  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 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, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//  Current versions can be found at www.libavg.de
//
//  Original author of this file is igor@c-base.org
//

#include "CursorEvent.h"

#include "Node.h"
#include "Contact.h"

#include "../base/Exception.h"
#include "../base/Logger.h"

#include <iostream>

using namespace std;

namespace avg {

CursorEvent::CursorEvent(int id, Type eventType, const IntPoint& position, Source source,
        int when)
    : Event(eventType, source, when),
      m_Position(position),
      m_ID(id),
      m_Speed(0,0)
{
}

CursorEvent::~CursorEvent()
{
}

CursorEventPtr CursorEvent::cloneAs(Type eventType) const
{
    CursorEventPtr pClone(new CursorEvent(*this));
    pClone->m_Type = eventType;
    return pClone;
}

void CursorEvent::setPos(const glm::vec2& pos)
{
    m_Position = IntPoint(pos);
}

glm::vec2 CursorEvent::getPos() const
{
    return glm::vec2(m_Position);
}

int CursorEvent::getXPosition() const
{
    return m_Position.x;
}

int CursorEvent::getYPosition() const
{
    return m_Position.y;
}

void CursorEvent::setCursorID(int id)
{
    m_ID = id;
}

int CursorEvent::getCursorID() const
{
    return m_ID;
}

void CursorEvent::setNode(NodePtr pNode)
{
    m_pNode = pNode;
}

NodePtr CursorEvent::getNode() const
{
    return m_pNode;
}
        
void CursorEvent::setSpeed(glm::vec2 speed)
{
    m_Speed = speed;
}

const glm::vec2& CursorEvent::getSpeed() const
{
    return m_Speed;
}

void CursorEvent::setContact(ContactPtr pContact)
{
    m_pContact = pContact;
}

ContactPtr CursorEvent::getContact() const
{
    return m_pContact.lock();
}

bool operator ==(const CursorEvent& event1, const CursorEvent& event2)
{
    return (event1.m_Position == event2.m_Position && 
            event1.getWhen() == event2.getWhen()); 
}

void CursorEvent::trace()
{
    string sType = typeStr();
    if (!m_pNode) {
        AVG_TRACE(Logger::category::EVENTS, Logger::severity::DEBUG, sType); 
    } else {
        AVG_TRACE(Logger::category::EVENTS, Logger::severity::DEBUG,
                m_pNode->getID()+", "+sType); 
    }
}

}