2
0
mirror of https://github.com/koreader/koreader synced 2024-11-11 19:11:14 +00:00
koreader/frontend/ui/data/creoptions.lua

192 lines
6.5 KiB
Lua
Raw Normal View History

2013-10-18 20:38:07 +00:00
local S = require("ui/data/strings")
local Screen = require("device").screen
2013-10-18 20:38:07 +00:00
local _ = require("gettext")
-- add multiply operator to Aa dict
local Aa = setmetatable({"Aa"}, {
2014-03-13 13:52:43 +00:00
__mul = function(t, mul)
local new = {}
for i = 1, mul do
for _, v in ipairs(t) do table.insert(new, v) end
end
return new
end
})
local function enable_if_equals(configurable, option, value)
return configurable[option] == value
end
2013-10-18 20:38:07 +00:00
local CreOptions = {
2014-03-13 13:52:43 +00:00
prefix = 'copt',
{
icon = "resources/icons/appbar.transform.rotate.right.large.png",
options = {
{
name = "screen_mode",
name_text = S.SCREEN_MODE,
toggle = {S.PORTRAIT, S.LANDSCAPE},
alternate = false,
args = {"portrait", "landscape"},
default_arg = "portrait",
current_func = function() return Screen:getScreenMode() end,
event = "ChangeScreenMode",
}
}
},
{
icon = "resources/icons/appbar.column.two.large.png",
options = {
{
name = "view_mode",
name_text = S.VIEW_MODE,
toggle = {S.VIEW_SCROLL, S.VIEW_PAGE},
values = {1, 0},
default_value = 0,
args = {"scroll", "page"},
default_arg = "page",
event = "SetViewMode",
},
2014-03-13 13:52:43 +00:00
{
name = "line_spacing",
name_text = S.LINE_SPACING,
toggle = {S.SMALL, S.MEDIUM, S.LARGE},
values = {
DCREREADER_CONFIG_LINE_SPACE_PERCENT_SMALL,
DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM,
DCREREADER_CONFIG_LINE_SPACE_PERCENT_LARGE,
},
default_value = DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM,
event = "SetLineSpace",
args = {
DCREREADER_CONFIG_LINE_SPACE_PERCENT_SMALL,
DCREREADER_CONFIG_LINE_SPACE_PERCENT_MEDIUM,
DCREREADER_CONFIG_LINE_SPACE_PERCENT_LARGE,
},
2014-03-13 13:52:43 +00:00
},
{
name = "page_margins",
name_text = S.PAGE_MARGIN,
toggle = {S.SMALL, S.MEDIUM, S.LARGE},
values = {
DCREREADER_CONFIG_MARGIN_SIZES_SMALL,
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM,
DCREREADER_CONFIG_MARGIN_SIZES_LARGE,
},
default_value = DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM,
event = "SetPageMargins",
2014-03-13 13:52:43 +00:00
args = {
DCREREADER_CONFIG_MARGIN_SIZES_SMALL,
DCREREADER_CONFIG_MARGIN_SIZES_MEDIUM,
DCREREADER_CONFIG_MARGIN_SIZES_LARGE,
},
},
}
},
{
icon = "resources/icons/appbar.text.size.large.png",
options = {
{
name = "font_size",
item_text = Aa * #DCREREADER_CONFIG_FONT_SIZES,
item_align_center = 1.0,
spacing = 15,
item_font_size = DCREREADER_CONFIG_FONT_SIZES,
values = DCREREADER_CONFIG_FONT_SIZES,
default_value = DCREREADER_CONFIG_DEFAULT_FONT_SIZE,
args = DCREREADER_CONFIG_FONT_SIZES,
event = "SetFontSize",
},
{
name = "font_fine_tune",
name_text = S.FONTSIZE_FINE_TUNING,
toggle = {S.DECREASE, S.INCREASE},
event = "ChangeSize",
args = {"decrease", "increase"},
alternate = false,
}
}
},
{
icon = "resources/icons/appbar.grade.b.large.png",
options = {
{
name = "font_weight",
name_text = S.FONT_WEIGHT,
toggle = {S.REGULAR, S.BOLD},
values = {0, 1},
default_value = 0,
args = {0, 1},
2014-03-13 13:52:43 +00:00
event = "ToggleFontBolder",
},
{
name = "font_gamma",
name_text = S.CONTRAST,
item_text = {S.LIGHTER, S.DEFAULT, S.DARKER},
default_value = DCREREADER_CONFIG_DEFAULT_FONT_GAMMA,
values = {
DCREREADER_CONFIG_LIGHTER_FONT_GAMMA,
DCREREADER_CONFIG_DEFAULT_FONT_GAMMA,
DCREREADER_CONFIG_DARKER_FONT_GAMMA,
},
event = "SetFontGamma",
args = {
DCREREADER_CONFIG_LIGHTER_FONT_GAMMA,
DCREREADER_CONFIG_DEFAULT_FONT_GAMMA,
DCREREADER_CONFIG_DARKER_FONT_GAMMA,
},
2017-09-08 15:38:51 +00:00
},
{
name = "font_hinting",
name_text = S.FONT_HINT,
toggle = {S.OFF, S.NATIVE, S.AUTO},
values = {0, 1, 2},
default_value = 2,
args = {0, 1, 2},
event = "SetFontHinting",
2014-03-13 13:52:43 +00:00
}
}
},
{
icon = "resources/icons/appbar.settings.large.png",
options = {
{
name = "status_line",
name_text = S.PROGRESS_BAR,
toggle = {S.FULL, S.MINI},
values = {0, 1},
default_value = DCREREADER_PROGRESS_BAR,
args = {0, 1},
default_arg = DCREREADER_PROGRESS_BAR,
event = "SetStatusLine",
},
{
name = "embedded_css",
name_text = S.EMBEDDED_STYLE,
toggle = {S.ON, S.OFF},
values = {1, 0},
default_value = 1,
args = {true, false},
default_arg = nil,
event = "ToggleEmbeddedStyleSheet",
},
{
name = "embedded_fonts",
name_text = S.EMBEDDED_FONTS,
toggle = {S.ON, S.OFF},
values = {1, 0},
default_value = 1,
args = {true, false},
default_arg = nil,
event = "ToggleEmbeddedFonts",
enabled_func = function(configurable)
return enable_if_equals(configurable, "embedded_css", 1)
end,
},
2014-03-13 13:52:43 +00:00
},
},
}
2013-10-18 20:38:07 +00:00
return CreOptions