mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
disable reflow options when reflow is not ON
This should also fix #1061.
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
local Screen = require("device").screen
|
||||
local S = require("ui/data/strings")
|
||||
|
||||
local _ = require("gettext")
|
||||
|
||||
local function enable_if_equals(configurable, option, value)
|
||||
return configurable[option] == value
|
||||
end
|
||||
|
||||
local function enable_if_greater_than(configurable, option, value)
|
||||
return configurable[option] > value
|
||||
end
|
||||
|
||||
local function enable_if_less_than(configurable, option, value)
|
||||
return configurable[option] < value
|
||||
end
|
||||
|
||||
local KoptOptions = {
|
||||
prefix = 'kopt',
|
||||
{
|
||||
@@ -84,6 +95,9 @@ local KoptOptions = {
|
||||
},
|
||||
values = {1,2,3},
|
||||
default_value = DKOPTREADER_CONFIG_MAX_COLUMNS,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "justification",
|
||||
@@ -98,6 +112,9 @@ local KoptOptions = {
|
||||
values = {-1,0,1,2,3},
|
||||
default_value = DKOPTREADER_CONFIG_JUSTIFICATION,
|
||||
advanced = true,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -114,6 +131,9 @@ local KoptOptions = {
|
||||
values = {0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0},
|
||||
default_value = DKOPTREADER_CONFIG_FONT_SIZE,
|
||||
event = "FontSizeUpdate",
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "font_fine_tune",
|
||||
@@ -125,6 +145,9 @@ local KoptOptions = {
|
||||
args = {-0.05, 0.05},
|
||||
alternate = false,
|
||||
height = 60,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -188,6 +211,9 @@ local KoptOptions = {
|
||||
toggle = {S.SMALL, S.AUTO, S.LARGE},
|
||||
values = DKOPTREADER_CONFIG_WORD_SPACINGS,
|
||||
default_value = DKOPTREADER_CONFIG_DEFAULT_WORD_SPACING,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "writing_direction",
|
||||
@@ -195,6 +221,9 @@ local KoptOptions = {
|
||||
toggle = {S.LTR, S.RTL, S.TBRTL},
|
||||
values = {0, 1, 2},
|
||||
default_value = 0,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "quality",
|
||||
@@ -203,6 +232,9 @@ local KoptOptions = {
|
||||
values={0.5, 1.0, 1.5},
|
||||
default_value = DKOPTREADER_CONFIG_RENDER_QUALITY,
|
||||
advanced = true,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "forced_ocr",
|
||||
@@ -220,6 +252,9 @@ local KoptOptions = {
|
||||
default_value = DKOPTREADER_CONFIG_DEFECT_SIZE,
|
||||
event = "DefectSizeUpdate",
|
||||
show = false,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "auto_straighten",
|
||||
@@ -228,6 +263,9 @@ local KoptOptions = {
|
||||
values = {0, 5, 10},
|
||||
default_value = DKOPTREADER_CONFIG_AUTO_STRAIGHTEN,
|
||||
show = false,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
{
|
||||
name = "detect_indent",
|
||||
@@ -236,6 +274,9 @@ local KoptOptions = {
|
||||
values = {1, 0},
|
||||
default_value = DKOPTREADER_CONFIG_DETECT_INDENT,
|
||||
show = false,
|
||||
enabled_func = function(configurable)
|
||||
return enable_if_equals(configurable, "text_wrap", 1)
|
||||
end,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -63,6 +63,7 @@ function OptionTextItem:init()
|
||||
end
|
||||
|
||||
function OptionTextItem:onTapSelect()
|
||||
if not self.enabled then return true end
|
||||
for _, item in pairs(self.items) do
|
||||
item[1].color = Blitbuffer.COLOR_WHITE
|
||||
end
|
||||
@@ -115,6 +116,7 @@ function OptionIconItem:init()
|
||||
end
|
||||
|
||||
function OptionIconItem:onTapSelect()
|
||||
if not self.enabled then return true end
|
||||
for _, item in pairs(self.items) do
|
||||
--item[1][1].invert = false
|
||||
item[1].color = Blitbuffer.COLOR_WHITE
|
||||
@@ -177,6 +179,10 @@ function ConfigOption:init()
|
||||
local items_spacing = HorizontalSpan:new{
|
||||
width = Screen:scaleBySize(item_spacing_with)
|
||||
}
|
||||
local enabled = true
|
||||
if self.options[c].enabled_func then
|
||||
enabled = self.options[c].enabled_func(self.config.configurable)
|
||||
end
|
||||
local horizontal_group = HorizontalGroup:new{}
|
||||
if self.options[c].name_text then
|
||||
local option_name_container = RightContainer:new{
|
||||
@@ -185,27 +191,12 @@ function ConfigOption:init()
|
||||
local option_name = TextWidget:new{
|
||||
text = self.options[c].name_text,
|
||||
face = Font:getFace(name_font_face, name_font_size),
|
||||
fgcolor = Blitbuffer.gray(enabled and 1.0 or 0.5),
|
||||
}
|
||||
table.insert(option_name_container, option_name)
|
||||
table.insert(horizontal_group, option_name_container)
|
||||
end
|
||||
|
||||
if self.options[c].widget == "ProgressWidget" then
|
||||
local widget_container = CenterContainer:new{
|
||||
dimen = Geom:new{
|
||||
w = Screen:getWidth()*self.options[c].widget_align_center,
|
||||
h = option_height
|
||||
}
|
||||
}
|
||||
local widget = ProgressWidget:new{
|
||||
width = self.options[c].width,
|
||||
height = self.options[c].height,
|
||||
percentage = self.options[c].percentage,
|
||||
}
|
||||
table.insert(widget_container, widget)
|
||||
table.insert(horizontal_group, widget_container)
|
||||
end
|
||||
|
||||
local option_items_container = CenterContainer:new{
|
||||
dimen = Geom:new{w = Screen:getWidth()*item_align, h = option_height}
|
||||
}
|
||||
@@ -292,18 +283,22 @@ function ConfigOption:init()
|
||||
FixedTextWidget:new{
|
||||
text = self.options[c].item_text[d],
|
||||
face = Font:getFace(item_font_face, item_font_size[d]),
|
||||
fgcolor = Blitbuffer.gray(enabled and 1.0 or 0.5),
|
||||
},
|
||||
padding = 3,
|
||||
color = d == current_item and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_WHITE,
|
||||
color = d == current_item and Blitbuffer.gray(enabled and 1.0 or 0.5) or Blitbuffer.COLOR_WHITE,
|
||||
enabled = enabled,
|
||||
}
|
||||
else
|
||||
option_item = OptionTextItem:new{
|
||||
TextWidget:new{
|
||||
text = self.options[c].item_text[d],
|
||||
face = Font:getFace(item_font_face, item_font_size),
|
||||
fgcolor = Blitbuffer.gray(enabled and 1.0 or 0.5),
|
||||
},
|
||||
padding = -3,
|
||||
color = d == current_item and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_WHITE,
|
||||
color = d == current_item and Blitbuffer.gray(enabled and 1.0 or 0.5) or Blitbuffer.COLOR_WHITE,
|
||||
enabled = enabled,
|
||||
}
|
||||
end
|
||||
option_items[d] = option_item
|
||||
@@ -338,10 +333,12 @@ function ConfigOption:init()
|
||||
for d = 1, #self.options[c].item_icons do
|
||||
local option_item = OptionIconItem:new{
|
||||
icon = ImageWidget:new{
|
||||
file = self.options[c].item_icons[d]
|
||||
file = self.options[c].item_icons[d],
|
||||
dim = not enabled,
|
||||
},
|
||||
padding = -2,
|
||||
color = d == current_item and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_WHITE,
|
||||
color = d == current_item and Blitbuffer.gray(enabled and 1.0 or 0.5) or Blitbuffer.COLOR_WHITE,
|
||||
enabled = enabled,
|
||||
}
|
||||
option_items[d] = option_item
|
||||
option_item.items = option_items
|
||||
@@ -375,6 +372,7 @@ function ConfigOption:init()
|
||||
event = self.options[c].event,
|
||||
events = self.options[c].events,
|
||||
config = self.config,
|
||||
enabled = enabled,
|
||||
}
|
||||
local position = current_item
|
||||
switch:setPosition(position)
|
||||
@@ -573,6 +571,7 @@ function ConfigDialog:onConfigChoose(values, name, event, args, events, position
|
||||
if events then
|
||||
self:onConfigEvents(events, position)
|
||||
end
|
||||
self:update()
|
||||
UIManager:setDirty("all")
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -57,6 +57,11 @@ function FrameContainer:paintTo(bb, x, y)
|
||||
container_width - 2*self.bordersize,
|
||||
container_height - 2*self.bordersize)
|
||||
end
|
||||
if self.dim then
|
||||
bb:dimRect(x + self.bordersize, y + self.bordersize,
|
||||
container_width - 2*self.bordersize,
|
||||
container_height - 2*self.bordersize)
|
||||
end
|
||||
end
|
||||
|
||||
return FrameContainer
|
||||
|
||||
@@ -31,6 +31,7 @@ local ToggleSwitch = InputContainer:new{
|
||||
fgcolor = Blitbuffer.gray(0.5), -- focused item color
|
||||
font_face = "cfont",
|
||||
font_size = 16,
|
||||
enabled = true,
|
||||
}
|
||||
|
||||
function ToggleSwitch:init()
|
||||
@@ -43,6 +44,7 @@ function ToggleSwitch:init()
|
||||
radius = 7,
|
||||
bordersize = 1,
|
||||
padding = 2,
|
||||
dim = not self.enabled,
|
||||
}
|
||||
self.toggle_content = HorizontalGroup:new{}
|
||||
|
||||
@@ -124,6 +126,7 @@ function ToggleSwitch:togglePosition(position)
|
||||
end
|
||||
|
||||
function ToggleSwitch:onTapSelect(arg, gev)
|
||||
if not self.enabled then return true end
|
||||
local position = math.ceil(
|
||||
(gev.pos.x - self.dimen.x) / self.dimen.w * self.n_pos
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user