1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-11 09:04:01 +03:00

lvgui: Extract page

This commit is contained in:
Samuel Dionne-Riel 2021-06-08 21:37:19 -04:00
parent 1127cee44f
commit 90f629e309
2 changed files with 34 additions and 35 deletions

View File

@ -262,41 +262,6 @@ module LVGUI
end
end
# Scrolling page.
class Page < Widget
def initialize(parent)
@parent = parent
# A "holder" widget to work around idiosyncracies of pages.
@holder = LVGL::LVContainer.new(parent)
@holder.set_fit2(LVGL::FIT::FILL, LVGL::FIT::NONE)
@holder.set_style(LVGL::CONT_STYLE::MAIN, LVGL::LVStyle::STYLE_TRANSP.dup)
# The actual widget we interact with
super(LVGL::LVPage.new(@holder))
style = LVGL::LVStyle::STYLE_TRANSP.dup
# Padding to zero in the actual scrolling widget makes the scrollbar visible
style.body_padding_left = 0
style.body_padding_right = 0
set_style(LVGL::PAGE_STYLE::BG, style)
set_style(LVGL::PAGE_STYLE::SCRL, style)
set_fit2(LVGL::FIT::FILL, LVGL::FIT::NONE)
# Make this scroll
set_scrl_layout(LVGL::LAYOUT::COL_M)
refresh
end
# Call this function when the position of the Page is changed.
# Mainly, this would be after filling the toolbar.
def refresh()
# Filling the parent that is at the root of the screen is apparently broken :/.
@holder.set_height(@parent.get_height_fit - @holder.get_y)
set_height(@holder.get_height - get_y)
end
end
# Widget implementing the topmost status bar
class StatusBar < Widget
def initialize(parent)

View File

@ -0,0 +1,34 @@
# Scrolling page.
class LVGUI::Page < LVGUI::Widget
def initialize(parent)
@parent = parent
# A "holder" widget to work around idiosyncracies of pages.
@holder = LVGL::LVContainer.new(parent)
@holder.set_fit2(LVGL::FIT::FILL, LVGL::FIT::NONE)
@holder.set_style(LVGL::CONT_STYLE::MAIN, LVGL::LVStyle::STYLE_TRANSP.dup)
# The actual widget we interact with
super(LVGL::LVPage.new(@holder))
style = LVGL::LVStyle::STYLE_TRANSP.dup
# Padding to zero in the actual scrolling widget makes the scrollbar visible
style.body_padding_left = 0
style.body_padding_right = 0
set_style(LVGL::PAGE_STYLE::BG, style)
set_style(LVGL::PAGE_STYLE::SCRL, style)
set_fit2(LVGL::FIT::FILL, LVGL::FIT::NONE)
# Make this scroll
set_scrl_layout(LVGL::LAYOUT::COL_M)
refresh
end
# Call this function when the position of the Page is changed.
# Mainly, this would be after filling the toolbar.
def refresh()
# Filling the parent that is at the root of the screen is apparently broken :/.
@holder.set_height(@parent.get_height_fit - @holder.get_y)
set_height(@holder.get_height - get_y)
end
end