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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00d829f1e7f4d4d305a18e1d831df3cd95874224581986977a89fd2eb114da0f
4
- data.tar.gz: 45da4ef0e277ca42d642919a06c8086952c695a139b45265df6d5b7ceb4d5aaa
3
+ metadata.gz: c5bca942f9f7773800ed3c18cada4a1c1c0a9d01af36017fb38f80cdd635f85f
4
+ data.tar.gz: d02823a9278976bff31b19161cc63ac520c7b05f7eee72d695d49300aa26c5da
5
5
  SHA512:
6
- metadata.gz: baa5798e57b4f1765b4e819ee7dac4db9aa40e172f44fd48c74ff6b6942bc8c0d5afdc55cc137aeb400b4c48f51cd5286000b4b849505e11b94f2de2e8e9ec43
7
- data.tar.gz: f37d1e63dcb902f2752c21e37d3ceaebccb0a2b5b9d50d615925049010dc2eedf3c726da9edc0687a63ba9ec651ffcd03cbc052cd0ea16c1b38e28275aa9e777
6
+ metadata.gz: f3f938721dc6625e984dc57ff44e9be4fcf921be975a041cb28f67f1abdf9a8ab51bfe528397fda26c9ec2d358ca51fdd484fefe3f04251725a87d7874c1cb3e
7
+ data.tar.gz: 47254f116883251a131bac91b43d465a1fbe34254c77274fe96c6522adb1ce1d97e172b2184f98d8f083dfc90e195b7197fa96ef3eb9be4c1c6d76fd3ca7714d
data/.gitignore CHANGED
@@ -11,3 +11,4 @@
11
11
  *.o
12
12
  *.a
13
13
  mkmf.log
14
+ .DS_Store
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nuklear (0.1.0)
4
+ nuklear (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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(ctx)
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/[USERNAME]/nuklear.
198
+ https://github.com/sinisterchipmunk/nuklear-ruby.
192
199
 
193
200
  ## License
194
201
 
Binary file
Binary file
@@ -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(ctx)
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
 
@@ -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(@nuklear_context)
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
@@ -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);
@@ -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(rb_funcall(self, rb_intern("context"), 0), struct nk_context, context);
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(rb_funcall(self, rb_intern("context"), 0), struct nk_context, context);
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, 0);
113
- rb_define_method(cRenderer, "nk_draw_foreach", nkrb_renderer_draw_foreach, 0);
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
  }