Skip to content

Commit

Permalink
[example] Fix most luacheck warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 21, 2023
1 parent 09a3176 commit e76b0eb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
8 changes: 2 additions & 6 deletions example/demo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ end

local function makeMainComponent()
local lnf = juce.LookAndFeel_V4.new()
function lnf:drawButtonBackground(g, btn, color, highlighted, down)
local b = btn:getBounds()
local bf = juce.Rectangle_int.new(b:getX(), b:getY(), b:getWidth(),
b:getHeight())
local c = highlighted and juce.Colours.red or juce.Colours.blue
g:setColour(c)
function lnf:drawButtonBackground(g, btn, colour, highlighted, down)
g:setColour(highlighted and colour or juce.Colours.blue)
g:fillAll()
end

Expand Down
2 changes: 1 addition & 1 deletion example/jml/equalizer.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jml = require("jml")
local jml = require("jml")

local eq = {}

Expand Down
23 changes: 6 additions & 17 deletions example/jml/jml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,12 @@ end
local function getTableSize(t)
assert(isTable(t))
local count = 0
for k in pairs(t) do
for _ in pairs(t) do
count = count + 1
end
return count
end

local function max(lhs, rhs)
assert(isNumber(lhs))
assert(isNumber(rhs))

if lhs > rhs then
return lhs
end

return rhs
end

local function setEmptyProperties(spec, properties)
assert(isTable(spec))
assert(isTable(properties))
Expand All @@ -45,7 +34,7 @@ local function setEmptyProperties(spec, properties)
{"margin", 0},
}

local addProperty = function(k, v)
local addProperty = function(_, v)
local id = v[1]
local value = v[2]
if spec[id] == nil then
Expand All @@ -64,19 +53,19 @@ local function setEmptyProperties(spec, properties)
return spec
end

function isPercentageString(str)
local function isPercentageString(str)
if type(str) == "string" then
return str:sub(-1) == "%"
end
return false
end

function parsePercentageToFraction(str)
local function parsePercentageToFraction(str)
assert(isString(str))
return tonumber(str:sub(1, -2)) / 100.0
end

function calculatePercentageBasedSize(parentSize, children, property)
local function calculatePercentageBasedSize(parentSize, children, property)
assert(isNumber(parentSize))
assert(isTable(children))
assert(isString(property))
Expand Down Expand Up @@ -156,7 +145,7 @@ function jml.Component(spec)
component:setComponentID(juce.String.new(spec.id))

-- CHILDREN
for k, child in ipairs(spec.children) do
for _, child in ipairs(spec.children) do
child.component = child.build()
component:addAndMakeVisible(child.component)
end
Expand Down
2 changes: 1 addition & 1 deletion example/jml/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jml = require("jml")
local jml = require("jml")

local ui = jml.Component{
id = "Main Window",
Expand Down

0 comments on commit e76b0eb

Please sign in to comment.