nuklear 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -2
- data/examples/calculator.png +0 -0
- data/examples/hello_nuklear.png +0 -0
- data/examples/hello_nuklear.rb +1 -1
- data/examples/lib/window.rb +1 -1
- data/ext/nuklear/nkrb_context.c +20 -0
- data/ext/nuklear/nkrb_renderer.c +6 -6
- data/ext/nuklear/nuklear.h +790 -447
- data/ext/nuklear_renderer_opengl2/nuklear_renderer_opengl2.c +9 -9
- data/ext/nuklear_renderer_opengl4/nuklear_renderer_opengl4.c +9 -11
- data/lib/nuklear/context.rb +1 -1
- data/lib/nuklear/renderer.rb +4 -5
- data/lib/nuklear/ui/edit_string.rb +10 -1
- data/lib/nuklear/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5bca942f9f7773800ed3c18cada4a1c1c0a9d01af36017fb38f80cdd635f85f
|
4
|
+
data.tar.gz: d02823a9278976bff31b19161cc63ac520c7b05f7eee72d695d49300aa26c5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f938721dc6625e984dc57ff44e9be4fcf921be975a041cb28f67f1abdf9a8ab51bfe528397fda26c9ec2d358ca51fdd484fefe3f04251725a87d7874c1cb3e
|
7
|
+
data.tar.gz: 47254f116883251a131bac91b43d465a1fbe34254c77274fe96c6522adb1ce1d97e172b2184f98d8f083dfc90e195b7197fa96ef3eb9be4c1c6d76fd3ca7714d
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,13 @@ This project implements a set of Ruby classes which wrap the Nuklear API. It
|
|
18
18
|
also provides two sample renderers (OpenGL 2 and OpenGL 4).
|
19
19
|
|
20
20
|
|
21
|
+
## Screenshots
|
22
|
+
|
23
|
+
![Hello Nuklear](https://github.com/sinisterchipmunk/nuklear-ruby/blob/master/examples/hello_nuklear.png)
|
24
|
+
|
25
|
+
![Calculator](https://github.com/sinisterchipmunk/nuklear-ruby/blob/master/examples/calculator.png)
|
26
|
+
|
27
|
+
|
21
28
|
## Installation
|
22
29
|
|
23
30
|
Add this line to your application's Gemfile:
|
@@ -75,7 +82,7 @@ ctx = Nuklear::Context.new(font)
|
|
75
82
|
# to actually implement our real renderer on top of. Here, we'll use the
|
76
83
|
# bundled OpenGL 2 renderer.
|
77
84
|
require 'nuklear/nuklear_renderer_opengl2'
|
78
|
-
ctx.renderer = Nuklear::Renderer::OpenGL2.new
|
85
|
+
ctx.renderer = Nuklear::Renderer::OpenGL2.new
|
79
86
|
```
|
80
87
|
|
81
88
|
### With DSL
|
@@ -188,7 +195,7 @@ push git commits and tags, and push the `.gem` file to
|
|
188
195
|
## Contributing
|
189
196
|
|
190
197
|
Bug reports and pull requests are welcome on GitHub at
|
191
|
-
https://github.com/
|
198
|
+
https://github.com/sinisterchipmunk/nuklear-ruby.
|
192
199
|
|
193
200
|
## License
|
194
201
|
|
Binary file
|
Binary file
|
data/examples/hello_nuklear.rb
CHANGED
@@ -56,7 +56,7 @@ ctx = Nuklear::Context.new(font)
|
|
56
56
|
# renderer the size of the window and the size of the drawing surface, which
|
57
57
|
# aren't always the same thing.
|
58
58
|
require 'nuklear/nuklear_renderer_opengl2'
|
59
|
-
ctx.renderer = Nuklear::Renderer::OpenGL2.new
|
59
|
+
ctx.renderer = Nuklear::Renderer::OpenGL2.new
|
60
60
|
ctx.renderer.window_size = window.size
|
61
61
|
ctx.renderer.drawable_size = window.gl_drawable_size
|
62
62
|
|
data/examples/lib/window.rb
CHANGED
@@ -35,7 +35,7 @@ module Examples
|
|
35
35
|
|
36
36
|
def nuklear_context=(ctx)
|
37
37
|
@nuklear_context = ctx
|
38
|
-
@nuklear_context.renderer = Nuklear::Renderer::OpenGL2.new
|
38
|
+
@nuklear_context.renderer = Nuklear::Renderer::OpenGL2.new
|
39
39
|
@nuklear_context.renderer.window_size = @handle.size
|
40
40
|
@nuklear_context.renderer.drawable_size = renderable_size
|
41
41
|
end
|
data/ext/nuklear/nkrb_context.c
CHANGED
@@ -220,6 +220,24 @@ VALUE nkrb_context_ui(VALUE self) {
|
|
220
220
|
return ui;
|
221
221
|
}
|
222
222
|
|
223
|
+
static VALUE nkrb_context_is_any_editor_active(VALUE self) {
|
224
|
+
struct nk_context *ctx = nkrb_context_get(self);
|
225
|
+
struct nk_window *iter;
|
226
|
+
iter = ctx->begin;
|
227
|
+
while (iter) {
|
228
|
+
if (iter->edit.active & NK_EDIT_ACTIVE)
|
229
|
+
return Qtrue;
|
230
|
+
iter = iter->next;
|
231
|
+
}
|
232
|
+
return Qfalse;
|
233
|
+
}
|
234
|
+
|
235
|
+
static VALUE nkrb_context_is_any_item_active(VALUE self) {
|
236
|
+
struct nk_context *ctx = nkrb_context_get(self);
|
237
|
+
if (nkrb_context_is_any_editor_active(self) == Qtrue) return Qtrue;
|
238
|
+
return nk_item_is_any_active(ctx) ? Qtrue : Qfalse;
|
239
|
+
}
|
240
|
+
|
223
241
|
void nkrb_context_init(void) {
|
224
242
|
cNuklearContext = rb_define_class_under(mNuklear, "Context", rb_cObject);
|
225
243
|
rb_define_alloc_func(cNuklearContext, nkrb_context_alloc);
|
@@ -228,6 +246,8 @@ void nkrb_context_init(void) {
|
|
228
246
|
rb_define_method(cNuklearContext, "initialize", nkrb_context_initialize, 1);
|
229
247
|
rb_define_method(cNuklearContext, "tick", nkrb_context_tick, 0);
|
230
248
|
rb_define_method(cNuklearContext, "ui", nkrb_context_ui, 0);
|
249
|
+
rb_define_method(cNuklearContext, "any_item_active?", nkrb_context_is_any_item_active, 0);
|
250
|
+
rb_define_method(cNuklearContext, "any_editor_active?", nkrb_context_is_any_editor_active, 0);
|
231
251
|
|
232
252
|
cNuklearContextEventSink = rb_define_class_under(cNuklearContext, "EventSink", rb_cObject);
|
233
253
|
rb_define_method(cNuklearContextEventSink, "initialize", rb_nkrb_event_sink_initialize, 1);
|
data/ext/nuklear/nkrb_renderer.c
CHANGED
@@ -33,12 +33,12 @@ static enum nk_draw_vertex_layout_format rb2nk_format(VALUE v) {
|
|
33
33
|
else rb_raise(rb_eArgError, "Invalid vertex layout format name");
|
34
34
|
}
|
35
35
|
|
36
|
-
VALUE nkrb_renderer_convert(VALUE self) {
|
36
|
+
VALUE nkrb_renderer_convert(VALUE self, VALUE rcontext) {
|
37
37
|
struct nk_context *context = NULL;
|
38
38
|
struct nk_buffer *commands = NULL;
|
39
39
|
struct nk_buffer *vertices = NULL;
|
40
40
|
struct nk_buffer *indices = NULL;
|
41
|
-
Data_Get_Struct(
|
41
|
+
Data_Get_Struct(rcontext, struct nk_context, context);
|
42
42
|
Data_Get_Struct(rb_funcall(self, rb_intern("commands"), 0), struct nk_buffer, commands);
|
43
43
|
Data_Get_Struct(rb_funcall(self, rb_intern("vertices"), 0), struct nk_buffer, vertices);
|
44
44
|
Data_Get_Struct(rb_funcall(self, rb_intern("vertex_indices"), 0), struct nk_buffer, indices);
|
@@ -77,10 +77,10 @@ VALUE nkrb_renderer_convert(VALUE self) {
|
|
77
77
|
return self;
|
78
78
|
}
|
79
79
|
|
80
|
-
VALUE nkrb_renderer_draw_foreach(VALUE self) {
|
80
|
+
VALUE nkrb_renderer_draw_foreach(VALUE self, VALUE rcontext) {
|
81
81
|
struct nk_context *context = NULL;
|
82
82
|
struct nk_buffer *commands = NULL;
|
83
|
-
Data_Get_Struct(
|
83
|
+
Data_Get_Struct(rcontext, struct nk_context, context);
|
84
84
|
Data_Get_Struct(rb_funcall(self, rb_intern("commands"), 0), struct nk_buffer, commands);
|
85
85
|
|
86
86
|
/* convert from command queue into draw list and draw to screen */
|
@@ -109,6 +109,6 @@ VALUE nkrb_renderer_draw_foreach(VALUE self) {
|
|
109
109
|
|
110
110
|
void nkrb_renderer_init(void) {
|
111
111
|
VALUE cRenderer = rb_define_class_under(mNuklear, "Renderer", rb_cObject);
|
112
|
-
rb_define_method(cRenderer, "nk_convert", nkrb_renderer_convert,
|
113
|
-
rb_define_method(cRenderer, "nk_draw_foreach", nkrb_renderer_draw_foreach,
|
112
|
+
rb_define_method(cRenderer, "nk_convert", nkrb_renderer_convert, 1);
|
113
|
+
rb_define_method(cRenderer, "nk_draw_foreach", nkrb_renderer_draw_foreach, 1);
|
114
114
|
}
|