#include "reflex/ruby/view.h" #include #include #include #include #include "reflex/ruby/selector.h" #include "reflex/ruby/timer.h" #include "reflex/ruby/style.h" #include "reflex/ruby/shape.h" #include "reflex/ruby/filter.h" #include "reflex/ruby/window.h" #include "defs.h" #include "selector.h" RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(Reflex::View) #define THIS to< Reflex::View*>(self) #define C_THIS to(self) #define CHECK RUCY_CHECK_OBJECT(Reflex::View, self) #define CALL(fun) RUCY_CALL_SUPER(THIS, fun) template static inline Value array (T begin, T end) { std::vector v; for (T it = begin; it != end; ++it) v.push_back(value(*it)); return value(v.size(), &v[0]); } static VALUE alloc(VALUE klass) { return value(new Reflex::RubyView, klass); } static VALUE show(VALUE self) { CHECK; THIS->show(); return self; } static VALUE hide(VALUE self) { CHECK; THIS->hide(); return self; } static VALUE hidden(VALUE self) { CHECK; return value(THIS->hidden()); } static VALUE redraw(VALUE self) { CHECK; THIS->redraw(); return self; } static VALUE focus(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#focus", argc, 0, 1); bool state = (argc >= 1) ? to(argv[0]) : true; THIS->focus(state); return self; } static VALUE blur(VALUE self) { CHECK; THIS->blur(); return self; } static VALUE has_focus(VALUE self) { CHECK; return value(THIS->has_focus()); } static VALUE start_timer(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#start_timer", argc, 1, 2); Reflex::Timer* timer = THIS->start_timer( to(argv[0]), argc >= 2 ? to(argv[1]) : 1); return value(timer); } static VALUE update_layout(VALUE self) { CHECK; THIS->update_layout(); return self; } static VALUE from_parent(VALUE self, VALUE point) { CHECK; return value(THIS->from_parent(to(point))); } static VALUE to_parent(VALUE self, VALUE point) { CHECK; return value(THIS->to_parent(to(point))); } static VALUE from_window(VALUE self, VALUE point) { CHECK; return value(THIS->from_window(to(point))); } static VALUE to_window(VALUE self, VALUE point) { CHECK; return value(THIS->to_window(to(point))); } static VALUE from_screen(VALUE self, VALUE point) { CHECK; return value(THIS->from_screen(to(point))); } static VALUE to_screen(VALUE self, VALUE point) { CHECK; return value(THIS->to_screen(to(point))); } static VALUE add_child(VALUE self, VALUE child) { CHECK; THIS->add_child(to(child)); return child; } static VALUE remove_child(VALUE self, VALUE child) { CHECK; THIS->remove_child(to(child)); return child; } static VALUE clear_children(VALUE self) { CHECK; THIS->clear_children(); return self; } static VALUE find_children(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#find_children", argc, 1, 2); bool recursive = (argc >= 2) ? to(argv[1]) : true; Reflex::View::ChildList children = THIS->find_children(to(argv[0]), recursive); return array(children.begin(), children.end()); } static VALUE each_child(VALUE self) { CHECK; Value ret; Reflex::View::child_iterator end = THIS->child_end(); for (Reflex::View::child_iterator it = THIS->child_begin(); it != end; ++it) ret = rb_yield(value(it->get())); return ret; } static VALUE add_style(VALUE self, VALUE style) { CHECK; THIS->add_style(to(style)); return style; } static VALUE remove_style(VALUE self, VALUE style) { CHECK; THIS->remove_style(to(style)); return style; } static VALUE get_style(VALUE self, VALUE selector) { CHECK; Reflex::Style* s = NULL; if (selector) s = THIS->get_style(to(selector)); else s = THIS->style(); return s ? value(*s) : nil(); } static VALUE find_styles(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#find_styles", argc, 1, 2); bool recursive = (argc >= 2) ? to(argv[1]) : false; Reflex::View::StyleList styles = THIS->find_styles(to(argv[0]), recursive); return array(styles.begin(), styles.end()); } static VALUE each_style(VALUE self) { CHECK; Value ret; Reflex::View::style_iterator end = THIS->style_end(); for (Reflex::View::style_iterator it = THIS->style_begin(); it != end; ++it) ret = rb_yield(value(*it)); return ret; } static Reflex::Shape::Ref to_shape (Value value) { if (value.is_nil()) return NULL; if (value.is_kind_of(Rays::polygon_class())) { Reflex::PolygonShape* shape = new Reflex::PolygonShape(); shape->set_polygon(to(value)); return shape; } else return to(value); } static VALUE set_shape(VALUE self, VALUE shape) { CHECK; THIS->set_shape(to_shape(shape)); return shape; } static VALUE get_shape(VALUE self) { CHECK; return value(THIS->shape()); } static VALUE add_shape(VALUE self, VALUE shape) { CHECK; THIS->add_shape(to_shape(shape)); return shape; } static VALUE remove_shape(VALUE self, VALUE shape) { CHECK; THIS->remove_shape(to(shape)); return shape; } static VALUE clear_shapes(VALUE self) { CHECK; THIS->clear_shapes(); return self; } static VALUE find_shapes(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#find_shapes", argc, 1); Reflex::View::ShapeList shapes = THIS->find_shapes(to(argv[0])); return array(shapes.begin(), shapes.end()); } static VALUE each_shape(VALUE self) { CHECK; Value ret; Reflex::View::shape_iterator end = THIS->shape_end(); for (Reflex::View::shape_iterator it = THIS->shape_begin(); it != end; ++it) ret = rb_yield(value(it->get())); return ret; } static VALUE set_filter(VALUE self, VALUE filter) { CHECK; THIS->set_filter(filter ? to(filter) : NULL); return filter; } static VALUE get_filter(VALUE self) { CHECK; return value(THIS->filter()); } static VALUE set_frame(VALUE self) { CHECK; THIS->set_frame(to(argc, argv)); return value(THIS->frame()); } static VALUE get_frame(VALUE self) { CHECK; return value(THIS->frame()); } static VALUE content_bounds(VALUE self) { CHECK; return value(CALL(content_bounds())); } static VALUE fit_to_content(VALUE self) { CHECK; THIS->fit_to_content(); return self; } static VALUE set_angle(VALUE self, VALUE degree) { CHECK; THIS->set_angle(to(degree)); return degree; } static VALUE get_angle(VALUE self) { CHECK; return value(THIS->angle()); } static VALUE set_pivot(VALUE self) { CHECK; if (argv[0].is_kind_of(Rays::point_class())) { check_arg_count(__FILE__, __LINE__, "View#pivot=(Point)", argc, 1); THIS->set_pivot(to(argv[0])); } else { if (argv[0].is_array()) { argc = argv[0].size(); argv = &argv[0][0]; } check_arg_count(__FILE__, __LINE__, "View#pivot=(Numeric, ...)", argc, 2, 3); const Rays::Point& p = THIS->pivot(); float x = to(argv[0]); float y = to(argv[1]); float z = (argc >= 3 && argv[2]) ? to(argv[2]) : p.z; THIS->set_pivot(x, y, z); } return value(THIS->pivot()); } static VALUE get_pivot(VALUE self) { CHECK; return value(THIS->pivot()); } static VALUE scroll_to(VALUE self) { CHECK; if (argv[0].is_kind_of(Rays::point_class())) { check_arg_count(__FILE__, __LINE__, "View#scroll_to(Point)", argc, 1); THIS->scroll_to(to(argv[0])); } else { if (argv[0].is_array()) { argc = argv[0].size(); argv = &argv[0][0]; } check_arg_count(__FILE__, __LINE__, "View#scroll_to(Numeric, ...)", argc, 2, 3); const Rays::Point& p = THIS->scroll(); coord x = (argc >= 1 && argv[0]) ? to(argv[0]) : p.x; coord y = (argc >= 2 && argv[1]) ? to(argv[1]) : p.y; coord z = (argc >= 3 && argv[2]) ? to(argv[2]) : p.z; THIS->scroll_to(x, y, z); } return self; } static VALUE scroll_by(VALUE self) { CHECK; if (argv[0].is_kind_of(Rays::point_class())) { check_arg_count(__FILE__, __LINE__, "View#scroll_by", argc, 1); THIS->scroll_by(to(argv[0])); } else { if (argv[0].is_array()) { argc = argv[0].size(); argv = &argv[0][0]; } check_arg_count(__FILE__, __LINE__, "View#scroll_by(Numeric, ...)", argc, 2, 3); coord x = (argc >= 1 && argv[0]) ? to(argv[0]) : 0; coord y = (argc >= 2 && argv[1]) ? to(argv[1]) : 0; coord z = (argc >= 3 && argv[2]) ? to(argv[2]) : 0; THIS->scroll_by(x, y, z); } return self; } static VALUE get_scroll(VALUE self) { CHECK; return value(THIS->scroll()); } static VALUE set_zoom(VALUE self, VALUE zoom) { CHECK; THIS->set_zoom(to(zoom)); return zoom; } static VALUE get_zoom(VALUE self) { CHECK; return value(THIS->zoom()); } static VALUE set_capture(VALUE self, VALUE types) { CHECK; THIS->set_capture(to(types)); return types; } static VALUE get_capture(VALUE self) { CHECK; return value(THIS->capture()); } static VALUE set_clip(VALUE self, VALUE clip) { CHECK; if (clip) THIS-> add_flag(Reflex::View::FLAG_CLIP); else THIS->remove_flag(Reflex::View::FLAG_CLIP); return clip; } static VALUE get_clip(VALUE self) { CHECK; return value(THIS->has_flag(Reflex::View::FLAG_CLIP)); } static VALUE set_cache(VALUE self, VALUE cache) { CHECK; if (cache) THIS-> add_flag(Reflex::View::FLAG_CACHE); else THIS->remove_flag(Reflex::View::FLAG_CACHE); return cache; } static VALUE get_cache(VALUE self) { CHECK; return value(THIS->has_flag(Reflex::View::FLAG_CACHE)); } static VALUE set_resize_to_fit(VALUE self, VALUE resize) { CHECK; if (resize) THIS-> add_flag(Reflex::View::FLAG_RESIZE_TO_FIT); else THIS->remove_flag(Reflex::View::FLAG_RESIZE_TO_FIT); return resize; } static VALUE get_resize_to_fit(VALUE self) { CHECK; return value(THIS->has_flag(Reflex::View::FLAG_RESIZE_TO_FIT)); } static VALUE set_scroll_to_fit(VALUE self, VALUE scroll) { CHECK; if (scroll) THIS-> add_flag(Reflex::View::FLAG_SCROLL_TO_FIT); else THIS->remove_flag(Reflex::View::FLAG_SCROLL_TO_FIT); return scroll; } static VALUE get_scroll_to_fit(VALUE self) { CHECK; return value(THIS->has_flag(Reflex::View::FLAG_SCROLL_TO_FIT)); } static VALUE set_fix_angle(VALUE self, VALUE fix) { CHECK; if (fix) THIS-> add_flag(Reflex::View::FLAG_FIX_ANGLE); else THIS->remove_flag(Reflex::View::FLAG_FIX_ANGLE); return fix; } static VALUE get_fix_angle(VALUE self) { CHECK; return value(THIS->has_flag(Reflex::View::FLAG_FIX_ANGLE)); } static VALUE parent(VALUE self) { CHECK; return value(THIS->parent()); } static VALUE window(VALUE self) { CHECK; return value(THIS->window()); } static VALUE apply_force(VALUE self) { CHECK; THIS->apply_force(to(argc, argv)); return self; } static VALUE apply_torque(VALUE self, VALUE torque) { CHECK; THIS->apply_torque(to(torque)); return self; } static VALUE apply_linear_impulse(VALUE self) { CHECK; THIS->apply_linear_impulse(to(argc, argv)); return self; } static VALUE apply_angular_impulse(VALUE self, VALUE impulse) { CHECK; THIS->apply_angular_impulse(to(impulse)); return self; } static VALUE set_static(VALUE self, VALUE state) { CHECK; THIS->set_static(state); return state; } static VALUE is_static(VALUE self) { CHECK; return value(THIS->is_static()); } static VALUE set_dynamic(VALUE self, VALUE state) { CHECK; THIS->set_dynamic(state); return state; } static VALUE is_dynamic(VALUE self) { CHECK; return value(THIS->is_dynamic()); } static VALUE set_density(VALUE self, VALUE density) { CHECK; THIS->set_density(to(density)); return density; } static VALUE get_density(VALUE self) { CHECK; return value(THIS->density()); } static VALUE set_friction(VALUE self, VALUE friction) { CHECK; THIS->set_friction(to(friction)); return friction; } static VALUE get_friction(VALUE self) { CHECK; return value(THIS->friction()); } static VALUE set_restitution(VALUE self, VALUE restitution) { CHECK; THIS->set_restitution(to(restitution)); return restitution; } static VALUE get_restitution(VALUE self) { CHECK; return value(THIS->restitution()); } static VALUE set_sensor(VALUE self, VALUE state) { CHECK; THIS->set_sensor(state); return state; } static VALUE is_sensor(VALUE self) { CHECK; return value(THIS->is_sensor()); } static VALUE set_linear_velocity(VALUE self) { CHECK; THIS->set_linear_velocity(to(argc, argv)); return value(THIS->linear_velocity()); } static VALUE get_linear_velocity(VALUE self) { CHECK; return value(THIS->linear_velocity()); } static VALUE set_angular_velocity(VALUE self, VALUE velocity) { CHECK; THIS->set_angular_velocity(to(velocity)); return velocity; } static VALUE get_angular_velocity(VALUE self) { CHECK; return value(THIS->angular_velocity()); } static VALUE set_gravity_scale(VALUE self, VALUE scale) { CHECK; THIS->set_gravity_scale(to(scale)); return scale; } static VALUE get_gravity_scale(VALUE self) { CHECK; return value(THIS->gravity_scale()); } static VALUE update_physics(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#update_physics", argc, 0, 1); float duration = argc >= 1 ? to(argv[0]) : 0; THIS->update_physics(duration); return self; } static VALUE meter2pixel(VALUE self) { CHECK; check_arg_count(__FILE__, __LINE__, "View#meter2pixel", argc, 0, 1, 2); float meter = argc >= 1 ? to(argv[0]) : 1; bool create_world = argc >= 2 ? to (argv[1]) : true; return value(THIS->meter2pixel(meter, create_world)); } static VALUE set_gravity(VALUE self) { CHECK; THIS->set_gravity(to(argc, argv)); return value(THIS->gravity()); } static VALUE get_gravity(VALUE self) { CHECK; return value(THIS->gravity()); } static VALUE set_time_scale(VALUE self, VALUE scale) { CHECK; THIS->set_time_scale(to(scale)); return scale; } static VALUE get_time_scale(VALUE self) { CHECK; return value(THIS->time_scale()); } static VALUE wall(VALUE self) { CHECK; return value(THIS->wall()); } static VALUE set_debug(VALUE self, VALUE state) { CHECK; THIS->set_debug(state); return state; } static VALUE get_debug(VALUE self) { CHECK; return value(THIS->debug()); } static VALUE on_attach(VALUE self, VALUE event) { CHECK; CALL(on_attach(to(event))); } static VALUE on_detach(VALUE self, VALUE event) { CHECK; CALL(on_detach(to(event))); } static VALUE on_show(VALUE self, VALUE event) { CHECK; CALL(on_show(to(event))); } static VALUE on_hide(VALUE self, VALUE event) { CHECK; CALL(on_hide(to(event))); } static VALUE on_update(VALUE self, VALUE event) { CHECK; CALL(on_update(to(event))); } static VALUE on_draw(VALUE self, VALUE event) { CHECK; CALL(on_draw(to(event))); } static VALUE on_move(VALUE self, VALUE event) { CHECK; CALL(on_move(to(event))); } static VALUE on_resize(VALUE self, VALUE event) { CHECK; CALL(on_resize(to(event))); } static VALUE on_zoom(VALUE self, VALUE event) { CHECK; CALL(on_zoom(to(event))); } static VALUE on_rotate(VALUE self, VALUE event) { CHECK; CALL(on_rotate(to(event))); } static VALUE on_scroll(VALUE self, VALUE event) { CHECK; CALL(on_scroll(to(event))); } static VALUE on_focus(VALUE self, VALUE event) { CHECK; CALL(on_focus(to(event))); } static VALUE on_key(VALUE self, VALUE event) { CHECK; CALL(on_key(to(event))); } static VALUE on_key_down(VALUE self, VALUE event) { CHECK; CALL(on_key_down(to(event))); } static VALUE on_key_up(VALUE self, VALUE event) { CHECK; CALL(on_key_up(to(event))); } static VALUE on_pointer(VALUE self, VALUE event) { CHECK; CALL(on_pointer(to(event))); } static VALUE on_pointer_down(VALUE self, VALUE event) { CHECK; CALL(on_pointer_down(to(event))); } static VALUE on_pointer_up(VALUE self, VALUE event) { CHECK; CALL(on_pointer_up(to(event))); } static VALUE on_pointer_move(VALUE self, VALUE event) { CHECK; CALL(on_pointer_move(to(event))); } static VALUE on_pointer_cancel(VALUE self, VALUE event) { CHECK; CALL(on_pointer_cancel(to(event))); } static VALUE on_wheel(VALUE self, VALUE event) { CHECK; CALL(on_wheel(to(event))); } static VALUE on_capture(VALUE self, VALUE event) { CHECK; CALL(on_capture(to(event))); } static VALUE on_timer(VALUE self, VALUE event) { CHECK; CALL(on_timer(to(event))); } static VALUE will_contact(VALUE self, VALUE view) { CHECK; return value(CALL(will_contact(to(view)))); } static VALUE on_contact(VALUE self, VALUE event) { CHECK; CALL(on_contact(to(event))); } static VALUE on_contact_begin(VALUE self, VALUE event) { CHECK; CALL(on_contact_begin(to(event))); } static VALUE on_contact_end(VALUE self, VALUE event) { CHECK; CALL(on_contact_end(to(event))); } static Class cView; void Init_reflex_view () { Module mReflex = rb_define_module("Reflex"); cView = rb_define_class_under(mReflex, "View", rb_cObject); rb_define_alloc_func(cView, alloc); rb_define_method(cView, "show", RUBY_METHOD_FUNC(show), 0); rb_define_method(cView, "hide", RUBY_METHOD_FUNC(hide), 0); cView.define_method("hidden?", hidden); rb_define_method(cView, "redraw", RUBY_METHOD_FUNC(redraw), 0); rb_define_method(cView, "focus", RUBY_METHOD_FUNC(focus), -1); rb_define_method(cView, "blur", RUBY_METHOD_FUNC(blur), 0); cView.define_method("focus?", has_focus); rb_define_private_method(cView, "start_timer", RUBY_METHOD_FUNC(start_timer), -1); rb_define_method(cView, "update_layout", RUBY_METHOD_FUNC(update_layout), 0); rb_define_method(cView, "from_parent", RUBY_METHOD_FUNC(from_parent), 1); rb_define_method(cView, "to_parent", RUBY_METHOD_FUNC(to_parent), 1); rb_define_method(cView, "from_window", RUBY_METHOD_FUNC(from_window), 1); rb_define_method(cView, "to_window", RUBY_METHOD_FUNC(to_window), 1); rb_define_method(cView, "from_screen", RUBY_METHOD_FUNC(from_screen), 1); rb_define_method(cView, "to_screen", RUBY_METHOD_FUNC(to_screen), 1); rb_define_method(cView, "add_child", RUBY_METHOD_FUNC(add_child), 1); rb_define_method(cView, "remove_child", RUBY_METHOD_FUNC(remove_child), 1); rb_define_method(cView, "clear_children", RUBY_METHOD_FUNC(clear_children), 0); rb_define_method(cView, "find_children", RUBY_METHOD_FUNC(find_children), -1); rb_define_method(cView, "each_child", RUBY_METHOD_FUNC(each_child), 0); rb_define_method(cView, "add_style", RUBY_METHOD_FUNC(add_style), 1); rb_define_method(cView, "remove_style", RUBY_METHOD_FUNC(remove_style), 1); rb_define_method(cView, "get_style", RUBY_METHOD_FUNC(get_style), 1); rb_define_method(cView, "find_styles", RUBY_METHOD_FUNC(find_styles), -1); rb_define_method(cView, "each_style", RUBY_METHOD_FUNC(each_style), 0); rb_define_method(cView, "shape=", RUBY_METHOD_FUNC(set_shape), 1); rb_define_method(cView, "shape", RUBY_METHOD_FUNC(get_shape), 0); rb_define_method(cView, "add_shape", RUBY_METHOD_FUNC(add_shape), 1); rb_define_method(cView, "remove_shape", RUBY_METHOD_FUNC(remove_shape), 1); rb_define_method(cView, "clear_shapes", RUBY_METHOD_FUNC(clear_shapes), 0); rb_define_method(cView, "find_shapes", RUBY_METHOD_FUNC(find_shapes), -1); rb_define_method(cView, "each_shape", RUBY_METHOD_FUNC(each_shape), 0); rb_define_method(cView, "filter=", RUBY_METHOD_FUNC(set_filter), 1); rb_define_method(cView, "filter", RUBY_METHOD_FUNC(get_filter), 0); rb_define_method(cView, "frame=", RUBY_METHOD_FUNC(set_frame), -1); rb_define_method(cView, "frame", RUBY_METHOD_FUNC(get_frame), 0); rb_define_method(cView, "content_bounds", RUBY_METHOD_FUNC(content_bounds), 0); rb_define_method(cView, "fit_to_content", RUBY_METHOD_FUNC(fit_to_content), 0); rb_define_method(cView, "angle=", RUBY_METHOD_FUNC(set_angle), 1); rb_define_method(cView, "angle", RUBY_METHOD_FUNC(get_angle), 0); rb_define_method(cView, "pivot=", RUBY_METHOD_FUNC(set_pivot), -1); rb_define_method(cView, "pivot", RUBY_METHOD_FUNC(get_pivot), 0); rb_define_method(cView, "scroll_to", RUBY_METHOD_FUNC(scroll_to), -1); rb_define_method(cView, "scroll_by", RUBY_METHOD_FUNC(scroll_by), -1); rb_define_method(cView, "scroll", RUBY_METHOD_FUNC(get_scroll), 0); rb_define_method(cView, "zoom=", RUBY_METHOD_FUNC(set_zoom), 1); rb_define_method(cView, "zoom", RUBY_METHOD_FUNC(get_zoom), 0); rb_define_method(cView, "capture=", RUBY_METHOD_FUNC(set_capture), 1); rb_define_method(cView, "capture", RUBY_METHOD_FUNC(get_capture), 0); rb_define_method(cView, "clip=", RUBY_METHOD_FUNC(set_clip), 1); cView.define_method("clip?", get_clip); rb_define_method(cView, "cache=", RUBY_METHOD_FUNC(set_cache), 1); cView.define_method("cache?", get_cache); rb_define_method(cView, "resize_to_fit=", RUBY_METHOD_FUNC(set_resize_to_fit), 1); cView.define_method("resize_to_fit?", get_resize_to_fit); rb_define_method(cView, "scroll_to_fit=", RUBY_METHOD_FUNC(set_scroll_to_fit), 1); cView.define_method("scroll_to_fit?", get_scroll_to_fit); rb_define_method(cView, "fix_angle=", RUBY_METHOD_FUNC(set_fix_angle), 1); cView.define_method("fix_angle?", get_fix_angle); rb_define_method(cView, "parent", RUBY_METHOD_FUNC(parent), 0); rb_define_method(cView, "window", RUBY_METHOD_FUNC(window), 0); rb_define_method(cView, "apply_force", RUBY_METHOD_FUNC(apply_force), -1); rb_define_method(cView, "apply_torque", RUBY_METHOD_FUNC(apply_torque), 1); rb_define_method(cView, "apply_linear_impulse", RUBY_METHOD_FUNC(apply_linear_impulse), -1); rb_define_method(cView, "apply_angular_impulse", RUBY_METHOD_FUNC(apply_angular_impulse), 1); rb_define_method(cView, "static=", RUBY_METHOD_FUNC(set_static), 1); cView.define_method("static?", is_static); rb_define_method(cView, "dynamic=", RUBY_METHOD_FUNC(set_dynamic), 1); cView.define_method("dynamic?", is_dynamic); rb_define_method(cView, "density=", RUBY_METHOD_FUNC(set_density), 1); rb_define_method(cView, "density", RUBY_METHOD_FUNC(get_density), 0); rb_define_method(cView, "friction=", RUBY_METHOD_FUNC(set_friction), 1); rb_define_method(cView, "friction", RUBY_METHOD_FUNC(get_friction), 0); rb_define_method(cView, "restitution=", RUBY_METHOD_FUNC(set_restitution), 1); rb_define_method(cView, "restitution", RUBY_METHOD_FUNC(get_restitution), 0); rb_define_method(cView, "sensor=", RUBY_METHOD_FUNC(set_sensor), 1); cView.define_method("sensor?", is_sensor); rb_define_method(cView, "linear_velocity=", RUBY_METHOD_FUNC(set_linear_velocity), -1); rb_define_method(cView, "linear_velocity", RUBY_METHOD_FUNC(get_linear_velocity), 0); rb_define_method(cView, "angular_velocity=", RUBY_METHOD_FUNC(set_angular_velocity), 1); rb_define_method(cView, "angular_velocity", RUBY_METHOD_FUNC(get_angular_velocity), 0); rb_define_method(cView, "gravity_scale=", RUBY_METHOD_FUNC(set_gravity_scale), 1); rb_define_method(cView, "gravity_scale", RUBY_METHOD_FUNC(get_gravity_scale), 0); rb_define_method(cView, "update_physics", RUBY_METHOD_FUNC(update_physics), -1); rb_define_method(cView, "meter2pixel", RUBY_METHOD_FUNC(meter2pixel), -1); rb_define_method(cView, "gravity=", RUBY_METHOD_FUNC(set_gravity), -1); rb_define_method(cView, "gravity", RUBY_METHOD_FUNC(get_gravity), 0); rb_define_method(cView, "time_scale=", RUBY_METHOD_FUNC(set_time_scale), 1); rb_define_method(cView, "time_scale", RUBY_METHOD_FUNC(get_time_scale), 0); rb_define_method(cView, "wall", RUBY_METHOD_FUNC(wall), 0); rb_define_method(cView, "debug=", RUBY_METHOD_FUNC(set_debug), 1); cView.define_method("debug?", get_debug); rb_define_method(cView, "on_attach", RUBY_METHOD_FUNC(on_attach), 1); rb_define_method(cView, "on_detach", RUBY_METHOD_FUNC(on_detach), 1); rb_define_method(cView, "on_show", RUBY_METHOD_FUNC(on_show), 1); rb_define_method(cView, "on_hide", RUBY_METHOD_FUNC(on_hide), 1); rb_define_method(cView, "on_update", RUBY_METHOD_FUNC(on_update), 1); rb_define_method(cView, "on_draw", RUBY_METHOD_FUNC(on_draw), 1); rb_define_method(cView, "on_move", RUBY_METHOD_FUNC(on_move), 1); rb_define_method(cView, "on_resize", RUBY_METHOD_FUNC(on_resize), 1); rb_define_method(cView, "on_zoom", RUBY_METHOD_FUNC(on_zoom), 1); rb_define_method(cView, "on_rotate", RUBY_METHOD_FUNC(on_rotate), 1); rb_define_method(cView, "on_scroll", RUBY_METHOD_FUNC(on_scroll), 1); rb_define_method(cView, "on_focus", RUBY_METHOD_FUNC(on_focus), 1); rb_define_method(cView, "on_key", RUBY_METHOD_FUNC(on_key), 1); rb_define_method(cView, "on_key_down", RUBY_METHOD_FUNC(on_key_down), 1); rb_define_method(cView, "on_key_up", RUBY_METHOD_FUNC(on_key_up), 1); rb_define_method(cView, "on_pointer", RUBY_METHOD_FUNC(on_pointer), 1); rb_define_method(cView, "on_pointer_down", RUBY_METHOD_FUNC(on_pointer_down), 1); rb_define_method(cView, "on_pointer_up", RUBY_METHOD_FUNC(on_pointer_up), 1); rb_define_method(cView, "on_pointer_move", RUBY_METHOD_FUNC(on_pointer_move), 1); rb_define_method(cView, "on_pointer_cancel", RUBY_METHOD_FUNC(on_pointer_cancel), 1); rb_define_method(cView, "on_wheel", RUBY_METHOD_FUNC(on_wheel), 1); rb_define_method(cView, "on_capture", RUBY_METHOD_FUNC(on_capture), 1); rb_define_method(cView, "on_timer", RUBY_METHOD_FUNC(on_timer), 1); cView.define_method( "will_contact?", will_contact); cView.define_private_method("call_contact!", on_contact); cView.define_private_method("call_contact_begin!", on_contact_begin); cView.define_private_method("call_contact_end!", on_contact_end); cView.define_const("CAPTURE_NONE", Reflex::View::CAPTURE_NONE); cView.define_const("CAPTURE_KEY", Reflex::View::CAPTURE_KEY); cView.define_const("CAPTURE_POINTER", Reflex::View::CAPTURE_POINTER); cView.define_const("CAPTURE_ALL", Reflex::View::CAPTURE_ALL); define_selector_methods(cView); } namespace Reflex { Class view_class () { return cView; } }// Reflex