From 5a7d09bcd64a973f3c54042b4422635b69d9f458 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sun, 13 Jun 2021 18:08:23 -0400 Subject: [PATCH] lvgui: Make base window use the app background --- boot/lib/lvgui/lvgui/base_window.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/boot/lib/lvgui/lvgui/base_window.rb b/boot/lib/lvgui/lvgui/base_window.rb index 61e2e8a9..9164c904 100644 --- a/boot/lib/lvgui/lvgui/base_window.rb +++ b/boot/lib/lvgui/lvgui/base_window.rb @@ -18,6 +18,7 @@ module LVGUI # Preps a basic display @screen = Screen.new() + on_background_init() @status_bar = StatusBar.new(@screen) on_header_init() @toolbar = Toolbar.new(@screen) @@ -81,5 +82,21 @@ module LVGUI # Hooking point to customize initialization def on_initialization_finished() end + + # Hook point to customize the background + def on_background_init() + background_path = LVGL::Hacks.get_asset_path("app-background.svg") + if File.exist?(background_path) + + @background = LVGL::LVImage.new(@screen).tap do |el| + el.set_protect(LVGL::PROTECT::POS) + el.set_height(@screen.get_height()) + el.set_width(@screen.get_width()) + el.set_x(0) + el.set_y(LVGUI.pixel_scale(0)) + el.set_src("#{background_path}?height=#{el.get_height()}") + end + end + end end end