Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/mruby-widget-lib/mrblib/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def initialize(url)
@view_pos[:subsubview] = nil
@view_pos[:vis] = :env
@view_pos[:slot] = 0

@isPlugin = false
@myIsPlugin = OSC::RemoteParam.new($remote, "/isPlugin")
@myIsPlugin.callback = lambda { |enabled| @isPlugin = enabled }
end

def isPlugin
@isPlugin
end

def search_path=(val)
Expand Down
10 changes: 9 additions & 1 deletion src/mruby-zest/example/MainMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Widget {
function file_select()
{
opt = file.options[file.selected]
if(opt == "setup record" && root.isPlugin) then
self.root.log(:tooltip, "Recorder not available in Plugin mode")
return
end

win = window()
wid = Qml::FileSelector.new(db)
wid.whenValue = lambda { |x| menu.file_value(x)}
Expand Down Expand Up @@ -120,6 +125,7 @@ Widget {
$remote.action("/load_xlz", val)
elsif(opt == "setup record")
$remote.action("/HDDRecorder/preparefile", val)
record.onRecordSetup()
end
}
//1
Expand All @@ -130,7 +136,9 @@ Widget {
layoutOpts: [:no_constraint]
}
//2
Record {}
Record {
id: record;
}
//3
LearnButton {
tooltip: "just click on a widget while in learning mode to start mapping"
Expand Down
3 changes: 3 additions & 0 deletions src/mruby-zest/example/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Widget {
return if main_widget.content
@info = Hash.new

isPlugin = OSC::RemoteParam.new($remote, "/isPlugin")
Comment thread
JohannesLorenz marked this conversation as resolved.
Outdated
isPlugin.callback = lambda {|enabled| isPlugin = enabled}

#Assume parts are active for testing purposes
(0...16).each do |prt|
(0...16).each do |kit|
Expand Down
105 changes: 81 additions & 24 deletions src/mruby-zest/example/Record.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Widget {
property Symbol state: :notsetup

function draw(vg)
{
pad = 1.0/64
pad2 = (1-2*pad)
vg.path do |v|
v.rect(w*pad, h*pad, w*pad2, h*pad2)
v.rect(w*pad, h*pad, (2.0/3)*w*pad2, h*pad2)
paint = v.linear_gradient(0,0,0,h,
Theme::ButtonGrad1, Theme::ButtonGrad2)
v.fill_paint paint
Expand All @@ -16,19 +18,18 @@ Widget {
vg.path do |v|
v.move_to(w*1.0/3, 0)
v.line_to(w*1.0/3, h)
v.move_to(w*2.0/3, 0)
v.line_to(w*2.0/3, h)
v.stroke
end

text_color = Theme::TextColor
active_color = Theme::TextActiveColor

draw_stop(vg, text_color)
draw_pause( vg, text_color)
draw_play( vg, text_color)
draw_stop(vg, active_color, text_color)
draw_playpause( vg, active_color, text_color)
}

function draw_record(vg, text_color) {
function draw_record(vg, active_color, text_color) {
color = (self.state == :stopped || self.state == :paused) ? active_color : text_color
r = [1.0/6*w, 1.0/2*h].min*0.4
vg.path do |v|
v.circle(1.0/6*w, 1.0/2*h, r)
Expand All @@ -37,45 +38,101 @@ Widget {
end
}

function draw_stop(vg, text_color) {
function draw_stop(vg, active_color, text_color) {
color = (self.state == :recording || self.state == :paused) ? active_color : text_color
r = [1.0/6*w, 1.0/2*h].min*0.4
vg.path do |v|
v.rect(1.0/6*w-r, 1.0/2*h-r, 2*r, 2*r)
v.fill_color text_color
v.fill_color color
v.fill
end
}

function draw_pause(vg, text_color) {
function draw_pause(vg, active_color, text_color) {
color = (self.state == :recording) ? active_color : text_color
vg.path do |v|
v.rect((3.0/6-1.0/18)*w, 0.2*h, 1.0/24*w, 0.6*h)
v.rect((3.0/6+1.0/18)*w, 0.2*h, 1.0/24*w, 0.6*h)
v.fill_color text_color
v.fill_color color
v.fill
end
}

function draw_play(vg, text_color) {
function draw_play(vg, active_color, text_color) {
color = (self.state == :stopped || self.state == :paused) ? active_color : text_color
vg.path do |v|
v.move_to((5.0/6-1.0/18)*w, 0.25*h)
v.line_to((5.0/6-1.0/18)*w, 0.75*h)
v.line_to((5.0/6+1.0/18)*w, 0.5*h)
v.move_to((3.0/6-1.0/18)*w, 0.25*h)
v.line_to((3.0/6-1.0/18)*w, 0.75*h)
v.line_to((3.0/6+1.0/18)*w, 0.5*h)
v.close_path
v.fill_color text_color
v.fill_color color
v.fill
end
}

function onMousePress(ev)
{
px = (ev.pos.x-global_x)*1.0/w
if(px > 0.666)
$remote.action("/HDDRecorder/start")
elsif(px > 0.333)
$remote.action("/HDDRecorder/pause")
function draw_playpause(vg, active_color, text_color) {
if(self.state == :recording)
draw_pause(vg, active_color, text_color)
else
draw_play(vg, active_color, text_color)
end
}

function handleToolTip(ev) {
if (root.isPlugin)
dsp = "Recorder not available in Plugin mode"
else
$remote.action("/HDDRecorder/stop")
if(self.state == :notsetup) then
dsp = "Use \"File -> Setup Record\" to use Recorder"
else
px = (ev.pos.x-global_x)*1.0/w
if(px <= 0.333)
dsp = "Stop"
elsif(px > 0.333 && px < 0.666) then
if(self.state == :recording) then
dsp = "Pause"
else
dsp = "Start"
end
end
end
end
self.root.log(:tooltip, dsp)
}

function onMouseHover(ev) {
handleToolTip(ev)
}

function onMouseEnter(ev) {
handleToolTip(ev)
}

function onMousePress(ev) {
if(self.state != :notsetup) then
px = (ev.pos.x-global_x)*1.0/w
if(px > 0.333 && px < 0.666) then # play/pause button
if(self.state == :recording) then
$remote.action("/HDDRecorder/pause")
self.state = :paused
else
# it is stopped or paused
$remote.action("/HDDRecorder/start")
self.state = :recording
end
damage_self
else # stop button
if(self.state == :recording || self.state == :paused)
$remote.action("/HDDRecorder/stop")
self.state = :notsetup
damage_self
end
end
end
}

function onRecordSetup() {
self.state = :stopped
damage_self
}
}