First light of mouse wheel support.

Only working (soso) on osx.
Maarten
This commit is contained in:
Maarten Gribnau 2003-01-23 21:39:29 +00:00
parent cb4f2e1a4e
commit 5b845badef
4 changed files with 111 additions and 12 deletions

@ -110,9 +110,10 @@ typedef enum {
typedef enum {
GHOST_kEventUnknown = 0,
GHOST_kEventCursorMove,
GHOST_kEventButtonDown,
GHOST_kEventButtonUp,
GHOST_kEventCursorMove, /// Mouse move event
GHOST_kEventButtonDown, /// Mouse button event
GHOST_kEventButtonUp, /// Mouse button event
GHOST_kEventWheel, /// Mouse wheel event
GHOST_kEventKeyDown,
GHOST_kEventKeyUp,
@ -310,6 +311,11 @@ typedef struct {
GHOST_TButtonMask button;
} GHOST_TEventButtonData;
typedef struct {
/** Displacement of a mouse wheel. */
GHOST_TInt32 z;
} GHOST_TEventWheelData;
typedef struct {
/** The key code. */
GHOST_TKey key;

@ -28,13 +28,9 @@
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* $Id$
* Copyright (C) 2001 NaN Technologies B.V.
* @author Maarten Gribnau
* @date May 15, 2001
* @file GHOST_EventPrinter.h
* Declaration of GHOST_EventPrinter class.
*/
#include "GHOST_EventPrinter.h"
@ -73,6 +69,13 @@ bool GHOST_EventPrinter::processEvent(GHOST_IEvent* event)
}
break;
case GHOST_kEventWheel:
{
GHOST_TEventWheelData* wheelData = (GHOST_TEventWheelData*)((GHOST_IEvent*)event)->getData();
std::cout << "GHOST_kEventWheel, z: " << wheelData->z;
}
break;
case GHOST_kEventCursorMove:
{
GHOST_TEventCursorData* cursorData = (GHOST_TEventCursorData*)((GHOST_IEvent*)event)->getData();

@ -0,0 +1,69 @@
/**
* $Id$
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. The Blender
* Foundation also sells licenses for use in proprietary software under
* the Blender License. See http://www.blender.org/BL/ for information
* about this.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
/**
* @file GHOST_EventWheel.h
* Declaration of GHOST_EventWheel class.
*/
#ifndef _GHOST_EVENT_WHEEL_H_
#define _GHOST_EVENT_WHEEL_H_
#include "GHOST_Event.h"
/**
* Mouse wheel event.
* @author Maarten Gribnau
* @date May 11, 2001
*/
class GHOST_EventWheel : public GHOST_Event
{
public:
/**
* Constructor.
* @param msec The time this event was generated.
* @param type The type of this event.
* @param z The displacement of the mouse wheel.
*/
GHOST_EventWheel(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TInt32 z)
: GHOST_Event(msec, type, window)
{
m_wheelEventData.z = z;
m_data = &m_wheelEventData;
}
protected:
/** The z-displacement of the mouse wheel. */
GHOST_TEventWheelData m_wheelEventData;
};
#endif // _GHOST_EVENT_WHEEL_H_

@ -47,6 +47,7 @@
#include "GHOST_EventKey.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
#include "GHOST_EventWheel.h"
#include "GHOST_TimerManager.h"
#include "GHOST_TimerTask.h"
#include "GHOST_WindowManager.h"
@ -72,6 +73,7 @@ const EventTypeSpec kEvents[] =
{ kEventClassMouse, kEventMouseUp },
{ kEventClassMouse, kEventMouseMoved },
{ kEventClassMouse, kEventMouseDragged },
{ kEventClassMouse, kEventMouseWheelMoved },
{ kEventClassWindow, kEventWindowClose },
{ kEventClassWindow, kEventWindowActivated },
@ -552,6 +554,25 @@ OSStatus GHOST_SystemCarbon::handleMouseEvent(EventRef event)
pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
}
break;
case kEventMouseWheelMoved:
{
OSStatus status;
//UInt32 modifiers;
EventMouseWheelAxis axis;
SInt32 delta;
//status = ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers);
//GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
status = ::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis);
GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
status = ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta);
GHOST_ASSERT(status == noErr, "GHOST_SystemCarbon::handleMouseEvent(): GetEventParameter() failed");
if (axis == kEventMouseWheelAxisY)
{
pushEvent(new GHOST_EventWheel(getMilliSeconds(), GHOST_kEventWheel, window, delta));
}
}
break;
}
return noErr;