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 +4 -4
- data/Gemfile.lock +1 -1
- data/ext/nuklear/nkrb_context.c +14 -0
- data/lib/nuklear/ui/edit_string.rb +10 -1
- data/lib/nuklear/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f846542c142c2c65ef1cc020f98fff0640f07f54a453903cac5502d6aa130b92
|
4
|
+
data.tar.gz: 1f15ce1181825a123b55c30f461bc6b62d9725aba9bb62e02a303c26eff4f8d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91bf456e0db2f3f305ecc76936869b2aad2b3170874d68cba8e7883f652e80c03e653291ce15d7e2b4f378bce431bef8fdbfddf5bb6d2af2ee6b48cc8d7f9255
|
7
|
+
data.tar.gz: 6905172b24bc942221d883b6f9bef30fcfffd55c598a097c73c38df94d3d1bb26699addf4d54110ecab1576fc3f9d42259a15fda1cb0863cf6de127479cc4e28
|
data/Gemfile.lock
CHANGED
data/ext/nuklear/nkrb_context.c
CHANGED
@@ -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:
|
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
|
data/lib/nuklear/version.rb
CHANGED