From 7891e4a8c698f5ce3aaabc6e50b323cd0e97eefd Mon Sep 17 00:00:00 2001 From: marahmbawwab Date: Thu, 30 Mar 2023 15:59:52 +0300 Subject: [PATCH 1/3] Add rebuild cache instruction in makefile for build on Windows. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 1d7a385..33351fc 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ osx: deps/libuv.a $(CC) test-libversion.c deps/pugl/build/libpugl-0.a -ldl -o zest -framework OpenGL -framework AppKit -lpthread -I deps/pugl -std=gnu99 windows: buildpuglwin deps/libuv-win.a + ruby ./rebuild-fcache.rb cd deps/nanovg/src && $(CC) -mstackrealign nanovg.c -c $(AR) rc deps/libnanovg.a deps/nanovg/src/*.o cd src/osc-bridge && CFLAGS="-mstackrealign -I ../../deps/libuv/include " make lib From eb1320c7770a0dad963839cc0b09df3d2cfd60f4 Mon Sep 17 00:00:00 2001 From: marahmbawwab Date: Mon, 1 May 2023 20:06:01 +0300 Subject: [PATCH 2/3] Add changes in order to move cursor left and right, insert the chars where the cursor exist on the left of it in the comment and name text fileds in the scale settings window (the old behaviour was the insertion in the end and we can't move the cursor to left and right). --- src/mruby-zest/example/TextLine.qml | 60 +++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/src/mruby-zest/example/TextLine.qml b/src/mruby-zest/example/TextLine.qml index 6859c59..8436837 100644 --- a/src/mruby-zest/example/TextLine.qml +++ b/src/mruby-zest/example/TextLine.qml @@ -50,23 +50,67 @@ Widget { (0...l.length).each do |i| l[i] = "?" if l.getbyte(i) > 127 end - vg.text(8,h/2,l) - bnd = vg.text_bounds(0,0,l) - if(@state) - vg.text(8+bnd,h/2,"|") + + @edit ||= EditRegion.new($vg, self.label, w-20, h*0.8) + @edit.each_string do |x, y, str, cursor| + if(cursor == false) + vg.text(x+10, y, str) + else + if(@state) + vg.text_align NVG::ALIGN_LEFT| NVG::ALIGN_MIDDLE + vg.text(x+10, y, str) + end + end end + } function onKey(k, mode) { return if mode != "press" + pos = self.label.length + pos = @edit.pos if @edit + ll = self.label + + cursor_row = @edit.calc_cursor_y + if(k.ord == 8) - self.label = self.label[0...-1] - elsif k.ord >= 32 - self.label += k + pos -= 1 + if(pos >= ll.length) + self.label = ll[0...-1] + elsif(pos >= 0) + self.label = ll.slice(0, pos+cursor_row) + ll.slice(pos+1+cursor_row, ll.length) + end + else + self.label = ll.insert(pos+cursor_row, k) end + ll = self.label whenValue.call if whenValue valueRef.value = self.label if valueRef + @edit = EditRegion.new($vg, ll, w-20, 0.8*h) + if(k.ord == 8) + @edit.pos = pos + else + @edit.pos = pos+1 + end + damage_self + } + + + function onSpecial(k, mode) + { + return if @edit.nil? + return if mode != :press + + if(k == :left) + @edit.left + elsif(k == :right) + @edit.right + end + + @state = true + now = Time.new + @next = now + 0.7 damage_self } @@ -74,4 +118,4 @@ Widget { { self.label = val.label } -} +} \ No newline at end of file From c660be2cb9882ca4b7e983fee8c4c866aa367f53 Mon Sep 17 00:00:00 2001 From: marahmbawwab Date: Tue, 2 May 2023 17:22:59 +0300 Subject: [PATCH 3/3] Add changes in order to move cursor left and right in both comment and name fields in scale setting. --- src/mruby-zest/example/TextLine.qml | 6 +++--- src/mruby-zest/mrblib/util.rb | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mruby-zest/example/TextLine.qml b/src/mruby-zest/example/TextLine.qml index 8436837..00a27e3 100644 --- a/src/mruby-zest/example/TextLine.qml +++ b/src/mruby-zest/example/TextLine.qml @@ -72,17 +72,17 @@ Widget { pos = @edit.pos if @edit ll = self.label - cursor_row = @edit.calc_cursor_y + cursorrow = @edit.cursor_row if(k.ord == 8) pos -= 1 if(pos >= ll.length) self.label = ll[0...-1] elsif(pos >= 0) - self.label = ll.slice(0, pos+cursor_row) + ll.slice(pos+1+cursor_row, ll.length) + self.label = ll.slice(0, pos+cursorrow) + ll.slice(pos+1+cursorrow, ll.length) end else - self.label = ll.insert(pos+cursor_row, k) + self.label = ll.insert(pos+cursorrow, k) end ll = self.label whenValue.call if whenValue diff --git a/src/mruby-zest/mrblib/util.rb b/src/mruby-zest/mrblib/util.rb index 0afcd41..e625908 100644 --- a/src/mruby-zest/mrblib/util.rb +++ b/src/mruby-zest/mrblib/util.rb @@ -16,6 +16,10 @@ def pad(scale, bb) bb[3] = h; end +def cursor_row() + return @cursor_row +end + class EditRegion def initialize(vg, string, width, height)