mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
3bc425127e
commit
4aec610818
193
panda/src/tform/mouseWatcherParameter.I
Normal file
193
panda/src/tform/mouseWatcherParameter.I
Normal file
@ -0,0 +1,193 @@
|
||||
// Filename: mouseWatcherParameter.I
|
||||
// Created by: drose (06Jul01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE MouseWatcherParameter::
|
||||
MouseWatcherParameter() {
|
||||
_flags = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE MouseWatcherParameter::
|
||||
MouseWatcherParameter(const MouseWatcherParameter ©) :
|
||||
_button(copy._button),
|
||||
_mods(copy._mods),
|
||||
_mouse(copy._mouse),
|
||||
_flags(copy._flags)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::Copy Assignment Operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcherParameter::
|
||||
operator = (const MouseWatcherParameter ©) {
|
||||
_button = copy._button;
|
||||
_mods = copy._mods;
|
||||
_mouse = copy._mouse;
|
||||
_flags = copy._flags;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::Destructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE MouseWatcherParameter::
|
||||
~MouseWatcherParameter() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::set_button
|
||||
// Access: Public
|
||||
// Description: Sets the mouse or keyboard button that generated this
|
||||
// event, if any.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcherParameter::
|
||||
set_button(const ButtonHandle &button) {
|
||||
_button = button;
|
||||
_flags |= F_has_button;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::set_modifier_buttons
|
||||
// Access: Public
|
||||
// Description: Sets the modifier buttons that were being held while
|
||||
// this event was generated.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcherParameter::
|
||||
set_modifier_buttons(const ModifierButtons &mods) {
|
||||
_mods = mods;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::set_mouse
|
||||
// Access: Public
|
||||
// Description: Sets the mouse position that was current at the time
|
||||
// the event was generated.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcherParameter::
|
||||
set_mouse(const LPoint2f &mouse) {
|
||||
_mouse = mouse;
|
||||
_flags |= F_has_mouse;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::set_outside
|
||||
// Access: Public
|
||||
// Description: Sets the state of the "outside" flag. This is true
|
||||
// if the mouse was outside the region at the time the
|
||||
// event was generated, false otherwise. This only has
|
||||
// meaning for "release" events.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void MouseWatcherParameter::
|
||||
set_outside(bool flag) {
|
||||
if (flag) {
|
||||
_flags |= F_is_outside;
|
||||
} else {
|
||||
_flags &= ~F_is_outside;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::has_button
|
||||
// Access: Published
|
||||
// Description: Returns true if this parameter has an associated
|
||||
// mouse or keyboard button, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool MouseWatcherParameter::
|
||||
has_button() const {
|
||||
return (_flags & F_has_button) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::get_button
|
||||
// Access: Published
|
||||
// Description: Returns the mouse or keyboard button associated with
|
||||
// this event. It is valid to call this only if
|
||||
// has_button(), above, returned true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ButtonHandle MouseWatcherParameter::
|
||||
get_button() const {
|
||||
nassertr(has_button(), ButtonHandle::none());
|
||||
return _button;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::get_modifier_buttons
|
||||
// Access: Published
|
||||
// Description: Returns the set of modifier buttons that were being
|
||||
// held down while the event was generated.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const ModifierButtons &MouseWatcherParameter::
|
||||
get_modifier_buttons() const {
|
||||
return _mods;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::has_mouse
|
||||
// Access: Published
|
||||
// Description: Returns true if this parameter has an associated
|
||||
// mouse position, false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool MouseWatcherParameter::
|
||||
has_mouse() const {
|
||||
return (_flags & F_has_mouse) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::get_mouse
|
||||
// Access: Published
|
||||
// Description: Returns the mouse position at the time the event was
|
||||
// generated, in the normalized range (-1 .. 1). It is
|
||||
// valid to call this only if has_mouse() returned true.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LPoint2f &MouseWatcherParameter::
|
||||
get_mouse() const {
|
||||
nassertr(has_mouse(), _mouse);
|
||||
return _mouse;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::is_outside
|
||||
// Access: Published
|
||||
// Description: Returns true if the mouse was outside the region at
|
||||
// the time the event was generated, false otherwise.
|
||||
// This is only valid for "release" type events.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool MouseWatcherParameter::
|
||||
is_outside() const {
|
||||
return (_flags & F_is_outside) != 0;
|
||||
}
|
||||
|
||||
INLINE ostream &
|
||||
operator << (ostream &out, const MouseWatcherParameter &parm) {
|
||||
parm.output(out);
|
||||
return out;
|
||||
}
|
62
panda/src/tform/mouseWatcherParameter.cxx
Normal file
62
panda/src/tform/mouseWatcherParameter.cxx
Normal file
@ -0,0 +1,62 @@
|
||||
// Filename: mouseWatcherParameter.cxx
|
||||
// Created by: drose (06Jul01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "mouseWatcherParameter.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: MouseWatcherParameter::output
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MouseWatcherParameter::
|
||||
output(ostream &out) const {
|
||||
bool output_anything = false;
|
||||
|
||||
if (has_button()) {
|
||||
out << _button;
|
||||
output_anything = true;
|
||||
}
|
||||
|
||||
if (_mods.is_any_down()) {
|
||||
if (output_anything) {
|
||||
out << ", ";
|
||||
}
|
||||
out << _mods;
|
||||
output_anything = true;
|
||||
}
|
||||
|
||||
if (has_mouse()) {
|
||||
if (output_anything) {
|
||||
out << ", ";
|
||||
}
|
||||
out << "(" << _mouse << ")";
|
||||
output_anything = true;
|
||||
}
|
||||
|
||||
if (is_outside()) {
|
||||
if (output_anything) {
|
||||
out << ", ";
|
||||
}
|
||||
out << "outside";
|
||||
output_anything = true;
|
||||
}
|
||||
|
||||
if (!output_anything) {
|
||||
out << "no parameters";
|
||||
}
|
||||
}
|
76
panda/src/tform/mouseWatcherParameter.h
Normal file
76
panda/src/tform/mouseWatcherParameter.h
Normal file
@ -0,0 +1,76 @@
|
||||
// Filename: mouseWatcherParameter.h
|
||||
// Created by: drose (06Jul01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef MOUSEWATCHERPARAMETER_H
|
||||
#define MOUSEWATCHERPARAMETER_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "buttonHandle.h"
|
||||
#include "modifierButtons.h"
|
||||
#include "luse.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : MouseWatcherParameter
|
||||
// Description : This is sent along as a parameter to most events
|
||||
// generated for a region to indicate the mouse and
|
||||
// button state for the event.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class EXPCL_PANDA MouseWatcherParameter {
|
||||
public:
|
||||
INLINE MouseWatcherParameter();
|
||||
INLINE MouseWatcherParameter(const MouseWatcherParameter &other);
|
||||
INLINE void operator = (const MouseWatcherParameter &other);
|
||||
INLINE ~MouseWatcherParameter();
|
||||
|
||||
INLINE void set_button(const ButtonHandle &button);
|
||||
INLINE void set_modifier_buttons(const ModifierButtons &mods);
|
||||
INLINE void set_mouse(const LPoint2f &mouse);
|
||||
INLINE void set_outside(bool flag);
|
||||
|
||||
PUBLISHED:
|
||||
INLINE bool has_button() const;
|
||||
INLINE ButtonHandle get_button() const;
|
||||
|
||||
INLINE const ModifierButtons &get_modifier_buttons() const;
|
||||
|
||||
INLINE bool has_mouse() const;
|
||||
INLINE const LPoint2f &get_mouse() const;
|
||||
|
||||
INLINE bool is_outside() const;
|
||||
|
||||
void output(ostream &out) const;
|
||||
|
||||
public:
|
||||
ButtonHandle _button;
|
||||
ModifierButtons _mods;
|
||||
LPoint2f _mouse;
|
||||
|
||||
enum Flags {
|
||||
F_has_button = 0x001,
|
||||
F_has_mouse = 0x002,
|
||||
F_is_outside = 0x004,
|
||||
};
|
||||
int _flags;
|
||||
};
|
||||
|
||||
INLINE ostream &operator << (ostream &out, const MouseWatcherParameter &parm);
|
||||
|
||||
#include "mouseWatcherParameter.I"
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user