nuklear 0.1.1 → 0.1.2

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: 71711825cf0d022f9c47979905f5bf685067e9f2c1fdd8f9755a21142de60c6b
4
- data.tar.gz: 23eae0b964a56384d2224018b3a5c54414286ee4ddcdab5a64e84db408e0d35e
3
+ metadata.gz: f846542c142c2c65ef1cc020f98fff0640f07f54a453903cac5502d6aa130b92
4
+ data.tar.gz: 1f15ce1181825a123b55c30f461bc6b62d9725aba9bb62e02a303c26eff4f8d7
5
5
  SHA512:
6
- metadata.gz: 609432ea3c0dad02a1814ae94c6a42f7b96da73c1b2b8f1934481e22767473bb97723389c7f8dd698c07e2c343715d47be137918b93b4fa3b423b29ff7dd6102
7
- data.tar.gz: e740ab30d11e8a9fb607342e5c150758510c06ebae411acf2609c7cd82bf4a4c11098c0b2d34d49864212cd637230b644bd9bbeb937f31496f0a105286d87c72
6
+ metadata.gz: 91bf456e0db2f3f305ecc76936869b2aad2b3170874d68cba8e7883f652e80c03e653291ce15d7e2b4f378bce431bef8fdbfddf5bb6d2af2ee6b48cc8d7f9255
7
+ data.tar.gz: 6905172b24bc942221d883b6f9bef30fcfffd55c598a097c73c38df94d3d1bb26699addf4d54110ecab1576fc3f9d42259a15fda1cb0863cf6de127479cc4e28
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nuklear (0.1.1)
4
+ nuklear (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -220,8 +220,21 @@ 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
+
223
235
  static VALUE nkrb_context_is_any_item_active(VALUE self) {
224
236
  struct nk_context *ctx = nkrb_context_get(self);
237
+ if (nkrb_context_is_any_editor_active(self) == Qtrue) return Qtrue;
225
238
  return nk_item_is_any_active(ctx) ? Qtrue : Qfalse;
226
239
  }
227
240
 
@@ -234,6 +247,7 @@ void nkrb_context_init(void) {
234
247
  rb_define_method(cNuklearContext, "tick", nkrb_context_tick, 0);
235
248
  rb_define_method(cNuklearContext, "ui", nkrb_context_ui, 0);
236
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);
237
251
 
238
252
  cNuklearContextEventSink = rb_define_class_under(cNuklearContext, "EventSink", rb_cObject);
239
253
  rb_define_method(cNuklearContextEventSink, "initialize", rb_nkrb_event_sink_initialize, 1);
@@ -2,14 +2,18 @@ module Nuklear
2
2
  module UI
3
3
  class EditString < Nuklear::UI::Base
4
4
  attr_accessor :flags, :max_length, :filter, :text
5
+ attr_reader :text_was
5
6
 
6
- def initialize(text: "", flags: 0, max_length: 255, filter: nil, enabled: true)
7
+ def initialize(text: "", flags: :simple, max_length: 255, filter: nil,
8
+ enabled: true, &on_change)
7
9
  super enabled: enabled
8
10
  @text = text
9
11
  @flags = Nuklear.parse_flags :edit, flags
10
12
  @max_length = max_length
11
13
  @filter = filter
12
14
  @demand_focus = false
15
+ @text_was = text.dup
16
+ on(:change, &on_change) if block_given?
13
17
  end
14
18
 
15
19
  def demand_focus?
@@ -42,6 +46,11 @@ module Nuklear
42
46
  trigger(:committed) if (result & Nuklear::NK_EDIT_COMMITED) > 0
43
47
  trigger(:active) if (result & Nuklear::NK_EDIT_ACTIVE) > 0
44
48
  trigger(:inactive) if (result & Nuklear::NK_EDIT_INACTIVE) > 0
49
+ if @text != @text_was
50
+ trigger :change
51
+ @text_was.clear
52
+ @text_was.concat @text
53
+ end
45
54
  end
46
55
  end
47
56
  end
@@ -1,3 +1,3 @@
1
1
  module Nuklear
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuklear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin MacKenzie IV