Class: Ray::Window
Instance Method Summary collapse
-
#close ⇒ Object
Closes the window.
- #each_event {|event| ... } ⇒ Object
-
#hide_cursor ⇒ Object
Hides the window cursor.
-
#icon=(icon) ⇒ Object
Sets the icon used by the window.
-
#initialize(title = nil, size = [640, 480], opts = {}) ⇒ Window
constructor
A new instance of Window.
-
#input ⇒ Ray::Input
The input used by this object.
- #open(size, opts = {}) ⇒ Object
-
#poll_event(ev) ⇒ Object
Gets the next event from the event queue.
-
#resize(size) ⇒ Object
(also: #size=)
Resizes the window.
-
#show_cursor ⇒ Object
Shows the window cursor.
-
#title=(title) ⇒ Object
Sets the title of the window.
-
#update ⇒ Object
Updates the content of the window.
-
#wait_event(ev) ⇒ Object
Gets the next event from the event queue.
Methods inherited from Target
#[], #clear, #clip, #default_view, #draw, #make_current, #rect, #shader, #size, #to_image, #turtle, #view, #view=, #viewport_for, #with_view
Constructor Details
#initialize(title = nil, size = [640, 480], opts = {}) ⇒ Window
Returns a new instance of Window.
6 7 8 |
# File 'lib/ray/window.rb', line 6 def initialize(title = nil, size = [640, 480], opts = {}) open(title, size, opts) if title end |
Instance Method Details
#close ⇒ Object
Closes the window
64 65 66 67 68 |
# File 'ext/window.c', line 64 static VALUE ray_window_close(VALUE self) { say_window_close(ray_rb2window(self)); return self; } |
#each_event {|event| ... } ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ray/window.rb', line 13 def each_event return Enumerator.new(self, :each_event) unless block_given? ev = Ray::Event.new until poll_event(ev).type == Ray::Event::TypeNone yield ev end end |
#hide_cursor ⇒ Object
Hides the window cursor
127 128 129 130 131 |
# File 'ext/window.c', line 127 static VALUE ray_window_hide_cursor(VALUE self) { say_window_hide_cursor(ray_rb2window(self)); return self; } |
#icon=(icon) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'ext/window.c', line 75
static
VALUE ray_window_set_icon(VALUE self, VALUE icon) {
if (!say_window_set_icon(ray_rb2window(self), ray_rb2image(icon))) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return icon;
}
|
#input ⇒ Ray::Input
Returns The input used by this object.
158 159 160 161 |
# File 'ext/window.c', line 158 static VALUE ray_window_input(VALUE self) { return ray_input2rb(say_window_get_input(ray_rb2window(self)), self); } |
#open(size, opts = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'ext/window.c', line 34
static
VALUE ray_window_open(int argc, VALUE *argv, VALUE self) {
VALUE title = Qnil, size = Qnil, opts = Qnil;
rb_scan_args(argc, argv, "21", &title, &size, &opts);
say_window *window = ray_rb2window(self);
uint8_t flags = 0;
if (!NIL_P(opts)) {
if (RTEST(rb_hash_aref(opts, RAY_SYM("resizable"))))
flags |= SAY_WINDOW_RESIZABLE;
if (RTEST(rb_hash_aref(opts, RAY_SYM("no_frame"))))
flags |= SAY_WINDOW_NO_FRAME;
if (RTEST(rb_hash_aref(opts, RAY_SYM("fullscreen"))))
flags |= SAY_WINDOW_FULLSCREEN;
}
say_vector2 c_size = ray_convert_to_vector2(size);
if (!say_window_open(window, c_size.x, c_size.y,
StringValuePtr(title), flags)) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return self;
}
|
#poll_event(ev) ⇒ Object
138 139 140 141 142 |
# File 'ext/window.c', line 138
static
VALUE ray_window_poll_event(VALUE self, VALUE ev) {
say_window_poll_event(ray_rb2window(self), ray_rb2event(ev));
return ev;
}
|
#resize(size) ⇒ Object Also known as: size=
100 101 102 103 104 105 106 107 108 |
# File 'ext/window.c', line 100
static
VALUE ray_window_resize(VALUE self, VALUE size) {
say_vector2 c_size = ray_convert_to_vector2(size);
if (!say_window_resize(ray_rb2window(self), c_size.x, c_size.y)) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return size;
}
|
#show_cursor ⇒ Object
Shows the window cursor
120 121 122 123 124 |
# File 'ext/window.c', line 120 static VALUE ray_window_show_cursor(VALUE self) { say_window_show_cursor(ray_rb2window(self)); return self; } |
#title=(title) ⇒ Object
89 90 91 92 93 |
# File 'ext/window.c', line 89
static
VALUE ray_window_set_title(VALUE self, VALUE title) {
say_window_set_title(ray_rb2window(self), StringValuePtr(title));
return title;
}
|
#update ⇒ Object
Updates the content of the window. Must be updated at the end of each frame.
113 114 115 116 117 |
# File 'ext/window.c', line 113 static VALUE ray_window_update(VALUE self) { say_window_update(ray_rb2window(self)); return self; } |
#wait_event(ev) ⇒ Object
151 152 153 154 155 |
# File 'ext/window.c', line 151
static
VALUE ray_window_wait_event(VALUE self, VALUE ev) {
say_window_wait_event(ray_rb2window(self), ray_rb2event(ev));
return ev;
}
|