mirror of
https://github.com/airstruck/luigi.git
synced 2026-01-11 08:48:23 +00:00
add progress bar
This commit is contained in:
@@ -69,6 +69,8 @@ local mainForm = { title = "Test window", id = 'mainWindow', type = 'panel',
|
|||||||
{ value = 2, text = 'Thing Two' },
|
{ value = 2, text = 'Thing Two' },
|
||||||
{ value = 3, text = 'Thing Three' },
|
{ value = 3, text = 'Thing Three' },
|
||||||
} },
|
} },
|
||||||
|
{ type = 'panel', text = 'A progress bar', align = 'bottom', height = 24, padding = 4 },
|
||||||
|
{ type = 'progress', height = 32, margin = 4, id = 'progressBar', },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type = 'sash', height = 4, },
|
{ type = 'sash', height = 4, },
|
||||||
@@ -91,9 +93,9 @@ layout.leftSideBox:addChild {
|
|||||||
align = 'middle right'
|
align = 'middle right'
|
||||||
}
|
}
|
||||||
|
|
||||||
layout.slidey:onMotion(function (event)
|
layout.slidey:onPressDrag(function (event)
|
||||||
layout.statusbar.text = event.x
|
layout.progressBar.value = layout.slidey.value
|
||||||
return false
|
layout.progressBar:reflow()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|||||||
@@ -42,10 +42,18 @@ return function (config)
|
|||||||
slices = RESOURCE .. 'button_pressed.png',
|
slices = RESOURCE .. 'button_pressed.png',
|
||||||
padding = 0,
|
padding = 0,
|
||||||
},
|
},
|
||||||
|
progress = {
|
||||||
|
slices = RESOURCE .. 'button_pressed.png',
|
||||||
|
padding = 0,
|
||||||
|
},
|
||||||
|
progressInner = {
|
||||||
|
slices = RESOURCE .. 'progress.png',
|
||||||
|
padding = 0,
|
||||||
|
minimumWidth = 12,
|
||||||
|
},
|
||||||
slider_hovered = {
|
slider_hovered = {
|
||||||
},
|
},
|
||||||
stepper = {
|
stepper = {
|
||||||
type = 'panel',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
luigi/theme/light/button_disabled.png
Normal file
BIN
luigi/theme/light/button_disabled.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 534 B |
Binary file not shown.
|
Before Width: | Height: | Size: 507 B After Width: | Height: | Size: 495 B |
Binary file not shown.
BIN
luigi/theme/light/progress.png
Normal file
BIN
luigi/theme/light/progress.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 388 B |
@@ -8,6 +8,7 @@ local Widget = Base:extend()
|
|||||||
Widget.isWidget = true
|
Widget.isWidget = true
|
||||||
|
|
||||||
Widget.typeDecorators = {
|
Widget.typeDecorators = {
|
||||||
|
progress = require(ROOT .. 'widget.progress'),
|
||||||
sash = require(ROOT .. 'widget.sash'),
|
sash = require(ROOT .. 'widget.sash'),
|
||||||
slider = require(ROOT .. 'widget.slider'),
|
slider = require(ROOT .. 'widget.slider'),
|
||||||
stepper = require(ROOT .. 'widget.stepper'),
|
stepper = require(ROOT .. 'widget.stepper'),
|
||||||
|
|||||||
15
luigi/widget/progress.lua
Normal file
15
luigi/widget/progress.lua
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
return function (self)
|
||||||
|
|
||||||
|
self.value = 0.5
|
||||||
|
self.flow = 'x' -- TODO: support vertical slider
|
||||||
|
|
||||||
|
local bar = self:addChild {
|
||||||
|
type = 'progressInner',
|
||||||
|
width = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
self:onReshape(function (event)
|
||||||
|
local x1, y1, x2, y2 = self:getRectangle(true, true)
|
||||||
|
bar.width = self.value * (x2 - x1)
|
||||||
|
end)
|
||||||
|
end
|
||||||
@@ -19,12 +19,24 @@ return function (self)
|
|||||||
thumb:onPressStart(unpress)
|
thumb:onPressStart(unpress)
|
||||||
thumb:onPressEnter(unpress)
|
thumb:onPressEnter(unpress)
|
||||||
|
|
||||||
self:onPressDrag(function (event)
|
local function press (event)
|
||||||
local x1, y1, x2, y2 = self:getRectangle(true, true)
|
local x1, y1, x2, y2 = self:getRectangle(true, true)
|
||||||
self.value = (event.x - x1) / (x2 - x1)
|
self.value = (event.x - x1) / (x2 - x1)
|
||||||
if self.value < 0 then self.value = 0 end
|
if self.value < 0 then self.value = 0 end
|
||||||
if self.value > 1 then self.value = 1 end
|
if self.value > 1 then self.value = 1 end
|
||||||
self:reflow()
|
self:reflow()
|
||||||
|
end
|
||||||
|
|
||||||
|
self:onPressStart(press)
|
||||||
|
|
||||||
|
self:onPressDrag(press)
|
||||||
|
|
||||||
|
self:onEnter(function (event)
|
||||||
|
thumb.hovered = true
|
||||||
|
end)
|
||||||
|
|
||||||
|
self:onLeave(function (event)
|
||||||
|
thumb.hovered = false
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self:onReshape(function (event)
|
self:onReshape(function (event)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ return function (self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
local view = self:addChild {
|
local view = self:addChild {
|
||||||
|
type = 'text',
|
||||||
align = 'middle center',
|
align = 'middle center',
|
||||||
margin = 0,
|
margin = 0,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user