mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-12 15:24:14 +03:00
lvgui: Reduce enhanced header bar size in landscape
This helps gain some precious screen real-estate for e.g. laptop use cases.
This commit is contained in:
parent
4937f6ad46
commit
9cd0668f23
@ -1,11 +1,25 @@
|
||||
class MobileNixOS::EnhancedHeaderBar < LVGUI::HeaderBar
|
||||
def portrait?()
|
||||
@parent.get_width() < @parent.get_height()
|
||||
end
|
||||
|
||||
def initialize(parent)
|
||||
@parent = parent
|
||||
|
||||
# In landscape mode, take less space.
|
||||
scale_factor =
|
||||
if portrait?
|
||||
1.0
|
||||
else
|
||||
1.0/2
|
||||
end
|
||||
|
||||
# Wrap the header bar so we can constrain to 720 scaled pixels wide.
|
||||
# The contents will be centered.
|
||||
@container = LVGL::LVContainer.new(parent)
|
||||
@container.set_fit2(LVGL::FIT::NONE, LVGL::FIT::NONE)
|
||||
@container.set_layout(LVGL::LAYOUT::COL_M)
|
||||
@container.set_height(LVGUI.pixel_scale(128))
|
||||
@container.set_height(LVGUI.pixel_scale(128*scale_factor))
|
||||
@container.set_width(parent.get_width())
|
||||
super(@container)
|
||||
@container.set_style(LVGL::CONT_STYLE::MAIN, self.get_style(LVGL::CONT_STYLE::MAIN))
|
||||
@ -15,20 +29,26 @@ class MobileNixOS::EnhancedHeaderBar < LVGUI::HeaderBar
|
||||
if File.exist?(logo_path)
|
||||
set_fit2(LVGL::FIT::NONE, LVGL::FIT::NONE)
|
||||
set_layout(LVGL::LAYOUT::OFF)
|
||||
set_height(LVGUI.pixel_scale(128))
|
||||
set_height(LVGUI.pixel_scale(@container.get_height()))
|
||||
set_width(LVGUI.pixel_scale(720))
|
||||
|
||||
@logo = LVGL::LVImage.new(self).tap do |el|
|
||||
el.set_height(LVGUI.pixel_scale(82))
|
||||
el.set_width(LVGUI.pixel_scale(375))
|
||||
el.set_x(LVGUI.pixel_scale(19))
|
||||
el.set_y(LVGUI.pixel_scale(25))
|
||||
el.set_src("#{logo_path}?width=#{el.get_width()}")
|
||||
el.set_height(LVGUI.pixel_scale(82*scale_factor))
|
||||
el.set_width(LVGUI.pixel_scale(375*scale_factor))
|
||||
el.set_x(LVGUI.pixel_scale(19*scale_factor))
|
||||
el.set_y(LVGUI.pixel_scale(25*scale_factor))
|
||||
el.set_src("#{logo_path}?height=#{el.get_height()}")
|
||||
end
|
||||
|
||||
# We don't scale the label text size by design.
|
||||
# Instead we move it a bit differently
|
||||
@label.set_width(LVGUI.pixel_scale(720) - @logo.get_width_fit() - LVGUI.col_padding*2)
|
||||
@label.set_align(LVGL::LABEL_ALIGN::CENTER)
|
||||
@label.set_y(LVGUI.pixel_scale(62))
|
||||
if portrait?
|
||||
@label.set_y(LVGUI.pixel_scale(62*scale_factor))
|
||||
else
|
||||
@label.set_y(LVGUI.pixel_scale(28*scale_factor))
|
||||
end
|
||||
@label.set_x([
|
||||
@logo.get_x(),
|
||||
@logo.get_width(),
|
||||
|
Loading…
Reference in New Issue
Block a user