Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few graphics fixes after #4541 #4554

Merged
merged 16 commits into from Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 41 additions & 29 deletions frontend/apps/reader/modules/readerpaging.lua
Expand Up @@ -40,35 +40,47 @@ local ReaderPaging = InputContainer:new{
}

function ReaderPaging:init()
if Device:hasKeyboard() or Device:hasKeys() then
self.key_events = {
GotoNextPage = {
{Input.group.PgFwd}, doc = "go to next page",
event = "PagingRel", args = 1 },
GotoPrevPage = {
{Input.group.PgBack}, doc = "go to previous page",
event = "PagingRel", args = -1 },

GotoFirst = {
{"1"}, doc = "go to start", event = "GotoPercent", args = 0},
Goto11 = {
{"2"}, doc = "go to 11%", event = "GotoPercent", args = 11},
Goto22 = {
{"3"}, doc = "go to 22%", event = "GotoPercent", args = 22},
Goto33 = {
{"4"}, doc = "go to 33%", event = "GotoPercent", args = 33},
Goto44 = {
{"5"}, doc = "go to 44%", event = "GotoPercent", args = 44},
Goto55 = {
{"6"}, doc = "go to 55%", event = "GotoPercent", args = 55},
Goto66 = {
{"7"}, doc = "go to 66%", event = "GotoPercent", args = 66},
Goto77 = {
{"8"}, doc = "go to 77%", event = "GotoPercent", args = 77},
Goto88 = {
{"9"}, doc = "go to 88%", event = "GotoPercent", args = 88},
GotoLast = {
{"0"}, doc = "go to end", event = "GotoPercent", args = 100},
self.key_events = {}
if Device:hasKeys() then
self.key_events.GotoNextPage = {
{Input.group.PgFwd}, doc = "go to next page",
event = "PagingRel", args = 1,
}
self.key_events.GotoPrevPage = {
{Input.group.PgBack}, doc = "go to previous page",
event = "PagingRel", args = -1,
}
end
if Device:hasKeyboard() then
self.key_events.GotoFirst = {
{"1"}, doc = "go to start", event = "GotoPercent", args = 0,
}
self.key_events.Goto11 = {
{"2"}, doc = "go to 11%", event = "GotoPercent", args = 11,
}
self.key_events.Goto22 = {
{"3"}, doc = "go to 22%", event = "GotoPercent", args = 22,
}
self.key_events.Goto33 = {
{"4"}, doc = "go to 33%", event = "GotoPercent", args = 33,
}
self.key_events.Goto44 = {
{"5"}, doc = "go to 44%", event = "GotoPercent", args = 44,
}
self.key_events.Goto55 = {
{"6"}, doc = "go to 55%", event = "GotoPercent", args = 55,
}
self.key_events.Goto66 = {
{"7"}, doc = "go to 66%", event = "GotoPercent", args = 66,
}
self.key_events.Goto77 = {
{"8"}, doc = "go to 77%", event = "GotoPercent", args = 77,
}
self.key_events.Goto88 = {
{"9"}, doc = "go to 88%", event = "GotoPercent", args = 88,
}
self.key_events.GotoLast = {
{"0"}, doc = "go to end", event = "GotoPercent", args = 100,
}
end
self.number_of_pages = self.ui.document.info.number_of_pages
Expand Down
97 changes: 55 additions & 42 deletions frontend/apps/reader/modules/readerrolling.lua
Expand Up @@ -47,48 +47,61 @@ local ReaderRolling = InputContainer:new{
}

function ReaderRolling:init()
if Device:hasKeyboard() or Device:hasKeys() then
self.key_events = {
GotoNextView = {
{ Input.group.PgFwd },
doc = "go to next view",
event = "GotoViewRel", args = 1
},
GotoPrevView = {
{ Input.group.PgBack },
doc = "go to previous view",
event = "GotoViewRel", args = -1
},
MoveUp = {
{ "Up" },
doc = "move view up",
event = "Panning", args = {0, -1}
},
MoveDown = {
{ "Down" },
doc = "move view down",
event = "Panning", args = {0, 1}
},
GotoFirst = {
{"1"}, doc = "go to start", event = "GotoPercent", args = 0},
Goto11 = {
{"2"}, doc = "go to 11%", event = "GotoPercent", args = 11},
Goto22 = {
{"3"}, doc = "go to 22%", event = "GotoPercent", args = 22},
Goto33 = {
{"4"}, doc = "go to 33%", event = "GotoPercent", args = 33},
Goto44 = {
{"5"}, doc = "go to 44%", event = "GotoPercent", args = 44},
Goto55 = {
{"6"}, doc = "go to 55%", event = "GotoPercent", args = 55},
Goto66 = {
{"7"}, doc = "go to 66%", event = "GotoPercent", args = 66},
Goto77 = {
{"8"}, doc = "go to 77%", event = "GotoPercent", args = 77},
Goto88 = {
{"9"}, doc = "go to 88%", event = "GotoPercent", args = 88},
GotoLast = {
{"0"}, doc = "go to end", event = "GotoPercent", args = 100},
self.key_events = {}
if Device:hasKeys() then
self.key_events.GotoNextView = {
{ Input.group.PgFwd },
doc = "go to next view",
event = "GotoViewRel", args = 1,
}
self.key_events.GotoPrevView = {
{ Input.group.PgBack },
doc = "go to previous view",
event = "GotoViewRel", args = -1,
}
end
if Device:hasDPad() then
self.key_events.MoveUp = {
{ "Up" },
doc = "move view up",
event = "Panning", args = {0, -1},
}
self.key_events.MoveDown = {
{ "Down" },
doc = "move view down",
event = "Panning", args = {0, 1},
}
end
if Device:hasKeyboard() then
self.key_events.GotoFirst = {
{"1"}, doc = "go to start", event = "GotoPercent", args = 0,
}
self.key_events.Goto11 = {
{"2"}, doc = "go to 11%", event = "GotoPercent", args = 11,
}
self.key_events.Goto22 = {
{"3"}, doc = "go to 22%", event = "GotoPercent", args = 22,
}
self.key_events.Goto33 = {
{"4"}, doc = "go to 33%", event = "GotoPercent", args = 33,
}
self.key_events.Goto44 = {
{"5"}, doc = "go to 44%", event = "GotoPercent", args = 44,
}
self.key_events.Goto55 = {
{"6"}, doc = "go to 55%", event = "GotoPercent", args = 55,
}
self.key_events.Goto66 = {
{"7"}, doc = "go to 66%", event = "GotoPercent", args = 66,
}
self.key_events.Goto77 = {
{"8"}, doc = "go to 77%", event = "GotoPercent", args = 77,
}
self.key_events.Goto88 = {
{"9"}, doc = "go to 88%", event = "GotoPercent", args = 88,
}
self.key_events.GotoLast = {
{"0"}, doc = "go to end", event = "GotoPercent", args = 100,
}
end

Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/widget/buttontable.lua
Expand Up @@ -89,7 +89,7 @@ function ButtonTable:init()
end
end -- end for each button line
self:addHorizontalSep(true, false, false)
if Device:hasKeys() then
if Device:hasDPad() then
self.layout = self.buttons_layout
self.layout[1][1]:onFocus()
self.key_events.SelectByKeyPress = { {{"Press"}} }
Expand Down
4 changes: 2 additions & 2 deletions frontend/ui/widget/configdialog.lua
Expand Up @@ -772,7 +772,7 @@ function ConfigDialog:update()
self.config_menubar,
},
}
--reset the focusmanager cursor
-- Reset the focusmanager cursor
self.selected.y=#self.layout
self.selected.x=self.panel_index

Expand Down Expand Up @@ -896,7 +896,7 @@ end

function ConfigDialog:onSelect()
self:getFocusItem():handleEvent(Event:new("TapSelect"))
return true
return true
end

return ConfigDialog
5 changes: 3 additions & 2 deletions frontend/ui/widget/focusmanager.lua
Expand Up @@ -34,7 +34,8 @@ function FocusManager:init()
if not self.selected then
self.selected = { x = 1, y = 1 }
end
if Device:hasKeys() then

if Device:hasDPad() then
self.key_events = {
-- these will all generate the same event, just with different arguments
FocusUp = { {"Up"}, doc = "move focus up", event = "FocusMove", args = {0, -1} },
Expand Down Expand Up @@ -84,7 +85,7 @@ function FocusManager:onFocusMove(args)
self.layout[self.selected.y][self.selected.x]:handleEvent(Event:new("Focus"))
-- trigger a fast repaint, this does not count toward a flashing eink resfresh
-- TODO: is this really needed?
UIManager:setDirty(self.show_parent or self, "fast")
--UIManager:setDirty(self.show_parent or self, "fast")
break
end
end
Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/widget/inputdialog.lua
Expand Up @@ -373,7 +373,7 @@ function InputDialog:init()
if self.allow_newline then -- remove any enter_callback
self._input_widget.enter_callback = nil
end
if Device:hasKeys() then
if Device:hasDPad() then
--little hack to piggyback on the layout of the button_table to handle the new InputText
table.insert(self.button_table.layout, 1, {self._input_widget})
end
Expand Down
6 changes: 3 additions & 3 deletions frontend/ui/widget/inputtext.lua
Expand Up @@ -150,20 +150,20 @@ if Device.isTouchDevice() or Device.hasDPad() then
end

end
if Device.hasKeys() then
if Device.hasDPad() then
if not InputText.initEventListener then
function InputText:initEventListener() end
end

function InputText:onFocus()
--Event called by the focusmanager
-- Event called by the focusmanager
self.key_events.ShowKeyboard = { {"Press"}, doc = "show keyboard" }
self:focus()
return true
end

function InputText:onUnfocus()
--Event called by the focusmanager
-- Event called by the focusmanager
self.key_events = {}
self:unfocus()
return true
Expand Down
6 changes: 4 additions & 2 deletions frontend/ui/widget/menu.lua
Expand Up @@ -813,6 +813,9 @@ function Menu:init()
self.key_events.PrevPage = {
{Input.group.PgBack}, doc = "goto previous page of the menu"
}
end

if Device:hasDPad() then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this affect regular computer keyboards too? (AppImage)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh never mind, the SDL device already hasDPad = yes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I double-checked that stuff with a keyboard always had hasDPad enabled ;).

-- we won't catch presses to "Right", leave that to MenuItem.
self.key_events.FocusRight = nil
-- shortcut icon is not needed for touch device
Expand All @@ -827,7 +830,6 @@ function Menu:init()
}
end


if #self.item_table > 0 then
-- if the table is not yet initialized, this call
-- must be done manually:
Expand Down Expand Up @@ -868,7 +870,7 @@ end

function Menu:updatePageInfo(select_number)
if self.item_group[1] then
if Device:hasKeys() then
if Device:hasDPad() then
-- reset focus manager accordingly
self.selected = { x = 1, y = select_number }
end
Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/widget/scrolltextwidget.lua
Expand Up @@ -97,7 +97,7 @@ function ScrollTextWidget:init()
}
end
end
if Device:hasKeyboard() or Device:hasKeys() then
if Device:hasKeys() then
self.key_events = {
ScrollDown = {{Input.group.PgFwd}, doc = "scroll down"},
ScrollUp = {{Input.group.PgBack}, doc = "scroll up"},
Expand Down