add check and radio controls

This commit is contained in:
airstruck
2015-11-29 23:24:12 -05:00
parent 2d64e6ca69
commit ed98c0beb2
31 changed files with 150 additions and 14 deletions

View File

@@ -45,9 +45,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -159,7 +161,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -46,9 +46,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -399,7 +401,7 @@ found, and focuses that widget.
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -47,9 +47,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -566,7 +568,7 @@ This table is identical to the constructed widget.
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -32,9 +32,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="widget types/button.html">button</a></li>
<li><a href="widget types/check.html">check</a></li>
<li><a href="widget types/menu.html">menu</a></li>
<li><a href="widget types/menu.item.html">menu.item</a></li>
<li><a href="widget types/progress.html">progress</a></li>
<li><a href="widget types/radio.html">radio</a></li>
<li><a href="widget types/sash.html">sash</a></li>
<li><a href="widget types/slider.html">slider</a></li>
<li><a href="widget types/stepper.html">stepper</a></li>
@@ -65,6 +67,10 @@
<td class="name" nowrap><a href="widget_types/button.html">button</a></td>
<td class="summary">A simple button.</td>
</tr>
<tr>
<td class="name" nowrap><a href="widget_types/check.html">check</a></td>
<td class="summary">A check box.</td>
</tr>
<tr>
<td class="name" nowrap><a href="widget_types/menu.html">menu</a></td>
<td class="summary">A menu bar.</td>
@@ -77,6 +83,10 @@
<td class="name" nowrap><a href="widget_types/progress.html">progress</a></td>
<td class="summary">A progress bar.</td>
</tr>
<tr>
<td class="name" nowrap><a href="widget_types/radio.html">radio</a></td>
<td class="summary">A radio button.</td>
</tr>
<tr>
<td class="name" nowrap><a href="widget_types/sash.html">sash</a></td>
<td class="summary">A sash.</td>
@@ -121,7 +131,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -47,9 +47,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -597,7 +599,7 @@ child widgets appear.
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><strong>button</strong></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -76,7 +78,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><strong>menu</strong></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -76,7 +78,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><strong>menu.item</strong></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -76,7 +78,7 @@ not be explicitly created.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><strong>progress</strong></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -75,7 +77,7 @@ between 0 and 1 (inclusive) to change the width of the bar.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><strong>sash</strong></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -80,7 +82,7 @@ must have a specified <code>width</code> property.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><strong>slider</strong></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -75,7 +77,7 @@ number between 0 and 1, inclusive.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><strong>stepper</strong></li>
@@ -78,7 +80,7 @@ item displayed in the content area.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -35,9 +35,11 @@
<h2>Widget Types</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../widget types/button.html">button</a></li>
<li><a href="../widget types/check.html">check</a></li>
<li><a href="../widget types/menu.html">menu</a></li>
<li><a href="../widget types/menu.item.html">menu.item</a></li>
<li><a href="../widget types/progress.html">progress</a></li>
<li><a href="../widget types/radio.html">radio</a></li>
<li><a href="../widget types/sash.html">sash</a></li>
<li><a href="../widget types/slider.html">slider</a></li>
<li><a href="../widget types/stepper.html">stepper</a></li>
@@ -76,7 +78,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
<i style="float:right;">Last updated 2015-11-29 14:57:48 </i>
<i style="float:right;">Last updated 2015-11-29 23:24:00 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -92,6 +92,13 @@ local mainForm = { id = 'mainWindow', type = 'panel',
},
{ type = 'panel', text = 'A progress bar', align = 'bottom', height = 24, padding = 4 },
{ type = 'progress', height = 32, margin = 4, id = 'progressBar', },
{ type = 'panel', text = 'A check box', align = 'bottom', height = 24, padding = 4 },
{ type = 'check', text = 'Check it out', height = 32, padding = 4, id = 'checkBox', },
{ type = 'panel', text = 'Some radio widgets', align = 'bottom', height = 24, padding = 4 },
{ type = 'radio', text = 'One fish', height = 32, padding = 4, },
{ type = 'radio', text = 'Two fish', height = 32, padding = 4, },
{ type = 'radio', text = 'Red fish', height = 32, padding = 4, },
{ type = 'radio', text = 'Blue fish', height = 32, padding = 4, },
},
},
{ type = 'sash', height = 4, },
@@ -120,7 +127,7 @@ end)
layout:onMove(function (event)
local w = event.target
layout.statusbar.text = (w.type or '(generic) ') ..
layout.statusbar.text = (tostring(w.type)) ..
(w.id or '(unnamed)') .. ' ' ..
w:getX() .. ', ' .. w:getY() .. ' | ' ..
w:getWidth() .. 'x' .. w:getHeight()

View File

@@ -101,6 +101,48 @@ return function (config)
text_focused = {
slices = RESOURCE .. 'text_focused.png',
},
check = {
canFocus = true,
},
['check.unchecked'] = {
icon = RESOURCE .. 'check_unchecked.png',
},
['check.checked'] = {
icon = RESOURCE .. 'check_checked.png',
},
['check.unchecked_pressed'] = {
icon = RESOURCE .. 'check_unchecked_pressed.png',
},
['check.checked_pressed'] = {
icon = RESOURCE .. 'check_checked_pressed.png',
},
['check.unchecked_focused'] = {
icon = RESOURCE .. 'check_unchecked_focused.png',
},
['check.checked_focused'] = {
icon = RESOURCE .. 'check_checked_focused.png',
},
radio = {
canFocus = true,
},
['radio.unchecked'] = {
icon = RESOURCE .. 'radio_unchecked.png',
},
['radio.checked'] = {
icon = RESOURCE .. 'radio_checked.png',
},
['radio.unchecked_pressed'] = {
icon = RESOURCE .. 'radio_unchecked_pressed.png',
},
['radio.checked_pressed'] = {
icon = RESOURCE .. 'radio_checked_pressed.png',
},
['radio.unchecked_focused'] = {
icon = RESOURCE .. 'radio_unchecked_focused.png',
},
['radio.checked_focused'] = {
icon = RESOURCE .. 'radio_checked_focused.png',
},
}
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

View File

@@ -19,9 +19,11 @@ Widget.isWidget = true
Widget.typeDecorators = {
button = require(ROOT .. 'widget.button'),
check = require(ROOT .. 'widget.check'),
menu = require(ROOT .. 'widget.menu'),
['menu.item'] = require(ROOT .. 'widget.menu.item'),
progress = require(ROOT .. 'widget.progress'),
radio = require(ROOT .. 'widget.radio'),
sash = require(ROOT .. 'widget.sash'),
slider = require(ROOT .. 'widget.slider'),
stepper = require(ROOT .. 'widget.stepper'),

18
luigi/widget/check.lua Normal file
View File

@@ -0,0 +1,18 @@
--[[--
A check box.
@widget check
--]]--
return function (self)
self:onPress(function ()
self.value = not self.value
end)
self:onChange(function ()
local subtype = self.value and 'check.checked' or 'check.unchecked'
self.type = { 'check', subtype }
end)
self.value = not not self.value
end

33
luigi/widget/radio.lua Normal file
View File

@@ -0,0 +1,33 @@
--[[--
A radio button.
@widget radio
--]]--
-- TODO: make `group` a first-class attribute
local groups = {}
return function (self)
local groupName = self.group or 'default'
if not groups[groupName] then
groups[groupName] = {}
end
local group = groups[groupName]
group[#group + 1] = self
self:onPress(function ()
for _, widget in ipairs(group) do
widget.value = widget == self
end
end)
self:onChange(function ()
local subtype = self.value and 'radio.checked' or 'radio.unchecked'
self.type = { 'radio', subtype }
end)
self.value = not not self.value
end