23MouseSubregion(
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());
36 _pixel_xy =
new EventStoreVec2(LPoint2(0.0f, 0.0f));
37 _pixel_size =
new EventStoreVec2(LPoint2(0.0f, 0.0f));
38 _xy =
new EventStoreVec2(LPoint2(0.0f, 0.0f));
60 bool has_mouse =
false;
63 const EventStoreVec2 *xy;
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) {
74 output.set_data(_xy_output, EventParameter(_xy));
77 if (input.
has_data(_pixel_size_input)) {
78 const EventStoreVec2 *pixel_size;
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));
86 output.set_data(_pixel_xy_output, EventParameter(_pixel_xy));
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)) {
101 const ButtonEventList *button_events;
102 DCAST_INTO_V(button_events, input.
get_data(_button_events_input).
get_ptr());
104 for (
int i = 0; i < num_events; i++) {
105 const ButtonEvent &be = button_events->
get_event(i);
106 if (be._type == ButtonEvent::T_up) {
108 _button_events->add_event(be);
113 if (_button_events->get_num_events() != 0) {
114 output.set_data(_button_events_output, EventParameter(_button_events));
120 if (input.
has_data(_pixel_size_input)) {
121 const EventStoreVec2 *pixel_size;
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);
127 output.set_data(_pixel_size_output, EventParameter(_pixel_size));
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...
Encapsulates the data generated from (or sent into) any particular DataNode.
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...
bool has_data(int index) const
Returns true if the indicated parameter has been stored, false otherwise.
TypedWritableReferenceCount * get_ptr() const
Retrieves a pointer to the actual value stored in the parameter.
This is the base class for some classes that monitor the mouse and keyboard input and perform some ac...
void output(std::ostream &out) const
Outputs the Namable.
get_value
Retrieves the value stored in the parameter.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.