Formalize type attribute and support it in styles

This commit is contained in:
airstruck
2015-12-02 15:48:21 -05:00
parent a902385d55
commit f03b5c7bd4
29 changed files with 302 additions and 344 deletions

Binary file not shown.

99
example/font/LICENSE Normal file
View File

@@ -0,0 +1,99 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
Bitstream Vera Fonts Copyright
------------------------------
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:
The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".
This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.
The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.
Arev Fonts Copyright
------------------------------
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:
The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.
The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".
This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.
The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.
$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $

View File

@@ -1,12 +0,0 @@
AUTHORS
Current Contributors (sorted alphabetically):
- Pravin Satpute <psatpute at redhat dot com>
Project Owner (Current)
Red Hat, Inc.
Previous Contributors
- Steve Matteson
Original Designer
Ascender, Inc.

View File

@@ -1,14 +0,0 @@
* Thu Oct 04 2012 Pravin Satpute <psatpute AT redhat DOT com>
- Resolved "Glyphs with multiple unicode encodings inhibit subsetting" #851790
- Resolved #851791, #854601 and #851825
- Following GASP table version as per Liberation old version. (Anti-aliasing disabled)
- Added support for Serbian glyphs for wikipedia #657849
- In Monospace fonts, isFixedPitch bit set via script for getting it recognized as Monospace in putty.exe
* Fri Jul 06 2012 Pravin Satpute <psatpute AT redhat DOT com>
- Initial version of Liberation fonts based on croscore fonts version 1.21.0
- Converted TTF files into SFD files to be open source.
- Update Copyright and License file
- set fsType bit to 0, Installable Embedding is allowed.
- Absolute value in HHeadAscent/Descent values for maintaining Metric compatibility.

View File

@@ -1,102 +0,0 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
PREAMBLE The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to provide
a free and open framework in which fonts may be shared and improved in
partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves.
The fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such.
This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting ? in part or in whole ?
any of the components of the Original Version, by changing formats or
by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer
or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a
copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,in
Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under
this license does not apply to any document created using the Font
Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
DEALINGS IN THE FONT SOFTWARE.

View File

@@ -1,80 +0,0 @@
1. What's this?
=================
The Liberation Fonts is font collection which aims to provide document
layout compatibility as usage of Times New Roman, Arial, Courier New.
2. Requirements
=================
* fontforge is installed.
(http://fontforge.sourceforge.net)
3. Install
============
3.1 Decompress tarball
You can extract the files by following command:
$ tar zxvf liberation-fonts-[VERSION].tar.gz
3.2 Build from the source
Change into directory liberation-fonts-[VERSION]/ and build from sources by
following commands:
$ cd liberation-fonts-[VERSION]
$ make
The built font files will be available in 'build' directory.
3.3 Install to system
For Fedora, you could manually install the fonts by copying the TTFs to
~/.fonts for user wide usage, or to /usr/share/fonts/truetype/liberation
for system-wide availability. Then, run "fc-cache" to let that cached.
For other distributions, please check out corresponding documentation.
4. Usage
==========
Simply select preferred liberation font in applications and start using.
5. License
============
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
Please read file "LICENSE" for details.
6. For Maintainers
====================
Before packaging a new release based on a new source tarball, you have to
update the version suffix in the Makefile:
VER = [VERSION]
Make sure that the defined version corresponds to the font software metadata
which you can check with ftinfo/otfinfo or fontforge itself. It is highly
recommended that file 'ChangeLog' is updated to reflect changes.
Create a tarball with the following command:
$ make dist
The new versioned tarball will be available in the dist/ folder as
'liberation-fonts-[NEW_VERSION].tar.gz'.
7. Credits
============
Please read file "AUTHORS" for list of contributors.

View File

@@ -1,5 +0,0 @@
Here are todo for next release
1) Serbian glyph for wikipedia https://bugzilla.redhat.com/show_bug.cgi?id=657849
- Improving shape of S_BE https://bugzilla.redhat.com/show_bug.cgi?id=657849#c96
2) Liberation Mono not recognizing as Mono in Windows application #861003
- presently it is patch, we have to update zero width characters to fixed width

0
example/layout/about.lua Normal file
View File

View File

@@ -1,6 +1,6 @@
return { type = 'submenu', width = 600, height = 400, float = true,
{ type = 'panel', text = 'License', height = 40, size = 24, align = 'middle center', },
{ wrap = true, margin = 4, text = [[
return { style = 'dialog',
{ style = 'dialogHead', text = 'License' },
{ style = 'dialogBody', text = [[
The MIT License (MIT)
Copyright (c) 2015 airstruck
@@ -23,8 +23,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]] },
{ type = 'panel', flow = 'x', height = 40,
{},
{ type = 'button', text = 'Close', id = 'closeButton', width = 100, margin = 4 }
{ style = 'dialogFoot',
{}, -- spacer
{ style = 'dialogButton', id = 'closeButton', text = 'Close' }
}
}

76
example/layout/main.lua Normal file
View File

@@ -0,0 +1,76 @@
return { id = 'mainWindow', type = 'panel',
{ type = 'menu', id = 'menubar', flow = 'x',
{ text = 'File',
{ text = 'Save', id = 'menuSave', key = 'ctrl-s' },
{ text = 'Quit', id = 'menuQuit', key = 'escape' },
},
{ text = 'Edit',
{ text = 'Cut', key = 'ctrl-c' },
{ text = 'Copy', key = 'ctrl-x' },
{ text = 'Paste', key = 'ctrl-v' },
{ type = 'slider' },
},
{ text = 'View',
{ text = 'Theme',
{ text = 'Light', key = 'ctrl-l', id = 'themeLight', },
{ text = 'Dark', key = 'ctrl-d', id = 'themeDark' },
},
{ text = 'Style',
{ text = 'Default' },
},
},
{ text = 'Help',
{ id = 'about', text = 'About Luigi', icon = 'icon/16px/Book.png', key = 'f1', },
{ id = 'aboutDemo', text = 'About Luigi Demo', icon = 'icon/16px/Book Red.png', key = 'f2' },
{ id = 'license', text = 'License', key = 'f3' },
},
},
{ type = 'panel', id = 'toolbar', style = 'toolbar', flow = 'x',
{ type = 'button', id = 'newButton', style = 'toolButton', key = 'z',
icon = 'icon/32px/Blueprint.png' },
{ type = 'button', id = 'loadButton', style = 'toolButton',
icon = 'icon/32px/Calendar.png' },
{ type = 'button', id = 'saveButton', style = 'toolButton',
icon = 'icon/32px/Harddrive.png' },
},
{ flow = 'x',
{ id = 'leftSideBox', width = 200, minwidth = 64, scroll = true,
{ text = 'Hi, I\'m centered middle. ', style = 'listThing',
align = 'middle center' },
{ text = 'Hi, I\'m right bottom.\nAlso two lines, woopdy woop.Hi, I\'m right bottom.\nAlso two lines, woopdy woop.Hi, I\'m right bottom.\nAlso two lines, woopdy woop.', style = 'listThing',
align = 'bottom right' },
{ text = 'Hi, I\'m centered top. ', style = 'listThing',
align = 'top center' },
{ text = 'A man, a plan, a canal: Panama!', style = 'listThing' },
},
{ type = 'sash', width = 4, },
{ id = 'mainCanvas' },
{ type = 'sash', width = 4, },
{ type = 'panel', id = 'rightSideBox', width = 200, minwidth = 64,
{ type = 'panel', text = 'A slider', align = 'bottom', height = 24, padding = 4 },
{ type = 'slider', height = 32, margin = 4, id = 'slidey', value = 0 },
{ type = 'panel', text = 'A stepper', align = 'bottom', height = 24, padding = 4 },
{ type = 'stepper', height = 32, margin = 4,
{ value = 1, text = 'Thing One' },
{ value = 2, text = 'Thing Two' },
{ 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 = '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, },
{ type = 'panel', flow = 'x', height = 48, padding = 2,
{ type = 'text', id = 'aTextField', text = 'Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!' },
{ type = 'button', key='return', width = 80, id = 'aButton', text = 'Styling!',
font = 'font/DejaVuSansMono.ttf' },
},
{ type = 'panel', id = 'statusbar', height = 24, padding = 4, color = { 255, 0, 0 } },
}

View File

@@ -1,116 +1,8 @@
local Layout = require 'luigi.layout'
local style = {
short = {
height = 48,
},
toolbar = {
style = { 'short' },
},
toolButton = {
align = 'center middle',
width = 48,
},
toolButton_focused = {
slices = 'defer',
},
toolButton_not_hovered = {
slices = false,
},
statusbar = {
style = 'panel',
align = 'left middle',
},
listThing = {
style = { 'short', 'panel' },
align = 'left middle',
outline = { 200, 200, 200 },
height = 120,
padding = 8,
background = { 255, 255, 255 },
icon = 'icon/32px/Box.png',
wrap = true,
},
}
local style = require 'style'
local mainForm = { id = 'mainWindow', type = 'panel',
{ type = 'menu', id = 'menubar', flow = 'x',
{ text = 'File',
{ text = 'Save', id = 'menuSave', key = 'ctrl-s' },
{ text = 'Quit', id = 'menuQuit', key = 'escape' },
},
{ text = 'Edit',
{ text = 'Cut', key = 'ctrl-c' },
{ text = 'Copy', key = 'ctrl-x' },
{ text = 'Paste', key = 'ctrl-v' },
{ type = 'slider' },
},
{ text = 'View',
{ text = 'Theme',
{ text = 'Light', key = 'ctrl-l', id = 'themeLight', },
{ text = 'Dark', key = 'ctrl-d', id = 'themeDark' },
},
{ text = 'Style',
{ text = 'Default' },
},
},
{ text = 'Help',
{ id = 'about', text = 'About Luigi', icon = 'icon/16px/Book.png', key = 'f1', },
{ id = 'aboutDemo', text = 'About Luigi Demo', icon = 'icon/16px/Book Red.png', key = 'f2' },
{ id = 'license', text = 'License', key = 'f3' },
},
},
{ type = 'panel', id = 'toolbar', style = 'toolbar', flow = 'x',
{ type = 'button', id = 'newButton', style = 'toolButton', key = 'z',
icon = 'icon/32px/Blueprint.png' },
{ type = 'button', id = 'loadButton', style = 'toolButton',
icon = 'icon/32px/Calendar.png' },
{ type = 'button', id = 'saveButton', style = 'toolButton',
icon = 'icon/32px/Harddrive.png' },
},
{ flow = 'x',
{ id = 'leftSideBox', width = 200, minwidth = 64, scroll = true,
{ text = 'Hi, I\'m centered middle. ', style = 'listThing',
align = 'middle center' },
{ text = 'Hi, I\'m right bottom.\nAlso two lines, woopdy woop.Hi, I\'m right bottom.\nAlso two lines, woopdy woop.Hi, I\'m right bottom.\nAlso two lines, woopdy woop.', style = 'listThing',
align = 'bottom right', slices = 'luigi/theme/light/button.png' },
{ text = 'Hi, I\'m centered top. ', style = 'listThing',
align = 'top center' },
{ text = 'A man, a plan, a canal: Panama!', style = 'listThing' },
},
{ type = 'sash', width = 4, },
{ id = 'mainCanvas' },
{ type = 'sash', width = 4, },
{ type = 'panel', id = 'rightSideBox', width = 200, minwidth = 64,
{ type = 'panel', text = 'A slider', align = 'bottom', height = 24, padding = 4 },
{ type = 'slider', height = 32, margin = 4, id = 'slidey', value = 0 },
{ type = 'panel', text = 'A stepper', align = 'bottom', height = 24, padding = 4 },
{ type = 'stepper', height = 32, margin = 4,
{ value = 1, text = 'Thing One' },
{ value = 2, text = 'Thing Two' },
{ 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 = '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, },
{ type = 'panel', flow = 'x', height = 48, padding = 2,
{ type = 'text', id = 'aTextField', text = 'Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20% off!', font = 'font/liberation/LiberationMono-Regular.ttf' },
{ type = 'button', key='return', width = 80, id = 'aButton', text = 'Styling!',
font = 'font/liberation/LiberationMono-Regular.ttf' },
},
{ type = 'panel', id = 'statusbar', height = 24, padding = 4, color = { 255, 0, 0 } },
}
local layout = Layout(mainForm)
local layout = Layout(require 'layout.main')
layout:setStyle(style)
-- layout:setTheme(require 'luigi.theme.light')
@@ -160,7 +52,7 @@ layout.aButton:onPress(function (event)
foo:show()
end)
layout.mainCanvas.font = 'font/liberation/LiberationMono-Regular.ttf'
layout.mainCanvas.font = 'font/DejaVuSansMono.ttf'
layout.mainCanvas.text = [[
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
@@ -194,7 +86,9 @@ layout.themeLight:onPress(function (event) Backend.quit() end)
-- license dialog
local licenseDialog = Layout(require 'dialog.license')
local licenseDialog = Layout(require 'layout.license')
licenseDialog:setStyle(style)
licenseDialog.closeButton:onPress(function()
licenseDialog:hide()

59
example/style.lua Normal file
View File

@@ -0,0 +1,59 @@
return {
short = {
height = 48,
},
toolbar = {
style = { 'short' },
},
toolButton = {
align = 'center middle',
width = 48,
},
toolButton_focused = {
slices = 'defer',
},
toolButton_not_hovered = {
slices = false,
},
statusbar = {
style = 'panel',
align = 'left middle',
},
listThing = {
style = { 'short', 'panel' },
align = 'left middle',
outline = { 200, 200, 200 },
height = 120,
padding = 8,
background = { 255, 255, 255 },
icon = 'icon/32px/Box.png',
wrap = true,
},
dialog = {
type = 'submenu',
width = 600,
height = 400,
float = true,
},
dialogHead = {
type = 'panel',
height = 40,
size = 16,
align = 'middle center',
},
dialogBody = {
wrap = true,
margin = 4,
font = 'font/DejaVuSansMono.ttf',
},
dialogFoot = {
type = 'panel',
flow = 'x',
height = 40,
},
dialogButton = {
type = 'button',
width = 100,
margin = 4,
}
}

View File

@@ -11,8 +11,26 @@ Setting attributes can have side effects. For example, setting
to recalculate their size and position.
--]]--
local ROOT = (...):gsub('[^.]*$', '')
local Attribute = {}
function Attribute.type (widget, value)
local oldType = widget.attributes.type
widget.attributes.type = value
if value and not widget.hasType then
widget.hasType = true
local Widget = require(ROOT .. 'widget')
local decorate = Widget.typeDecorators[value]
if decorate then
decorate(widget)
end
end
end
--[[--
widget identifier.

View File

@@ -58,6 +58,26 @@ function Layout:constructor (data, master)
Widget(self, data)
end
local function clearWidget (widget)
widget.textData = nil
widget.fontData = nil
widget.position = {}
widget.dimensions = {}
widget.type = widget.type
end
local function reset (self)
if not self.root then return end
local widget = self.root:getNextNeighbor()
clearWidget(self.root)
while widget ~= self.root do
clearWidget(widget)
widget = widget:getNextNeighbor()
end
end
--[[--
Set the master layout for this layout.
@@ -77,6 +97,7 @@ function Layout:setMaster (layout)
return layout:addWidget(...)
end
reset(self)
return self
end
@@ -94,6 +115,7 @@ function Layout:setStyle (rules)
end
self.style = Style(rules or {}, { 'style' })
reset(self)
return self
end
@@ -108,6 +130,8 @@ function Layout:setTheme (rules)
rules = rules()
end
self.theme = Style(rules or {}, { 'type' })
reset(self)
return self
end
--[[--

View File

@@ -74,9 +74,13 @@ end
local attributeNames = {}
for name in pairs(Attribute) do
attributeNames[#attributeNames + 1] = name
if name ~= 'type' then -- type must be handled last
attributeNames[#attributeNames + 1] = name
end
end
attributeNames[#attributeNames + 1] = 'type'
--[[--
Widget pseudo-constructor.
@@ -109,17 +113,6 @@ local function metaCall (Widget, layout, self)
self[property] = value
end
self.type = self.type or 'generic'
self.fontData = Font(self.font, self.size, self.color)
-- layout:addWidget(self)
local decorate = Widget.typeDecorators[self.type]
if decorate then
decorate(self)
end
for k, v in ipairs(self) do
self[k] = v.isWidget and v or metaCall(Widget, self.layout, v)
self[k].parent = self

View File

@@ -9,6 +9,8 @@ not be explicitly created.
--]]--
local ROOT = (...):gsub('[^.]*.[^.]*.[^.]*$', '')
local Backend = require(ROOT .. 'backend')
local Layout, Event
local function addLayoutChildren (self)
@@ -141,12 +143,14 @@ local function registerLayoutEvents (self)
end
end)
menuLayout:onEnter(activate)
menuLayout:onPressEnter(activate)
end
local function initialize (self)
if not self.fontData then
self.fontData = Backend.Font(self.font, self.size)
end
local pad = self.padding or 0
local isSubmenu = self.parentMenu and self.parentMenu.parentMenu
local text, key, icon = self.text or '', self.key or '', self.icon

View File

@@ -178,6 +178,10 @@ local function insertText (self, newText)
end
return function (self)
if not self.fontData then
self.fontData = Backend.Font(self.font, self.size)
end
self.value = self.value or self.text or ''
self.text = ''
self.highlight = self.highlight or { 0x80, 0x80, 0x80 }