23 MouseSubregion(
const std::string &name) :
26 _pixel_xy_input = define_input(
"pixel_xy", EventStoreVec2::get_class_type());
27 _pixel_size_input = define_input(
"pixel_size", EventStoreVec2::get_class_type());
28 _xy_input = define_input(
"xy", EventStoreVec2::get_class_type());
29 _button_events_input = define_input(
"button_events", ButtonEventList::get_class_type());
31 _pixel_xy_output = define_output(
"pixel_xy", EventStoreVec2::get_class_type());
32 _pixel_size_output = define_output(
"pixel_size", EventStoreVec2::get_class_type());
33 _xy_output = define_output(
"xy", EventStoreVec2::get_class_type());
34 _button_events_output = define_output(
"button_events", ButtonEventList::get_class_type());
60 bool has_mouse =
false;
68 LVecBase2 n((p[0] - _minx) * _scalex - 1.0f, (p[1] - _miny) * _scaley - 1.0f);
71 if (n[0] >= -1.0f && n[0] <= 1.0f &&
72 n[1] >= -1.0f && n[1] <= 1.0f) {
77 if (input.
has_data(_pixel_size_input)) {
80 const LVecBase2 &s = pixel_size->
get_value();
82 PN_stdfloat xf = (1.0f + n[0]) * 0.5f * s[0];
83 PN_stdfloat yf = (1.0f - n[1]) * 0.5f * s[1];
85 _pixel_xy->set_value(LPoint2(xf, yf));
95 output.
set_data(_button_events_output, input.
get_data(_button_events_input));
98 _button_events->clear();
100 if (input.
has_data(_button_events_input)) {
102 DCAST_INTO_V(button_events, input.
get_data(_button_events_input).
get_ptr());
104 for (
int i = 0; i < num_events; i++) {
106 if (be._type == ButtonEvent::T_up) {
108 _button_events->add_event(be);
113 if (_button_events->get_num_events() != 0) {
120 if (input.
has_data(_pixel_size_input)) {
123 const LVecBase2 &s = pixel_size->
get_value();
125 LVecBase2 n(s[0] * (_r - _l), s[1] * (_t - _b));
126 _pixel_size->set_value(n);
An optional parameter associated with an event.
get_value
Retrieves the value stored in the parameter.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
A handy class object for storing simple values (like integers or strings) passed along with an Event ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_data(int index, const EventParameter &data)
Sets the data for the indicated parameter.
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
const EventParameter & get_data(int index) const
Extracts the data for the indicated index, if it has been stored, or the empty parameter if it has no...
TypeHandle is the identifier used to differentiate C++ class types.
Encapsulates the data generated from (or sent into) any particular DataNode.
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...