Non-Touch: improve bottom menu usability (#8712)

- FocusManager: allow managing sub widgets by merging their
  "layout" in the main one; make "press" support simpler by
  handling it as a fake tap event at the center of the
  focused widget.
- Setup gestures on non-touch devices for new focus manager.
- ToggleSwitch: use child layout.
- ButtonProgressWidget: use child layout.
- SpinWidget and DoubleSpinWidget: add keyboard navigation.
This commit is contained in:
Philip Chan
2022-01-25 08:32:46 +08:00
committed by GitHub
parent 21932c24a2
commit 3af268dd7a
16 changed files with 300 additions and 169 deletions

View File

@@ -41,6 +41,9 @@ local FrameContainer = WidgetContainer:new{
invert = false,
allow_mirroring = true,
_mirroredUI = BD.mirroredUILayout(),
focusable = false,
focus_border_size = Size.border.window * 2,
focus_border_color = Blitbuffer.COLOR_BLACK,
}
function FrameContainer:getSize()
@@ -58,6 +61,27 @@ function FrameContainer:getSize()
}
end
function FrameContainer:onFocus()
if not self.focusable then
return
end
self._origin_bordersize = self.bordersize
self._origin_border_color = self.color
self.bordersize = self.focus_border_size
self.color = self.focus_border_color
return true
end
function FrameContainer:onUnfocus()
if not self.focusable then
return
end
self.bordersize = self._origin_bordersize
self.color = self._origin_border_color
return true
end
function FrameContainer:paintTo(bb, x, y)
local my_size = self:getSize()
self.dimen = Geom:new{