From 3fd8c97556164e5d768b3013c9d4e2e658535a01 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Fri, 16 Sep 2022 00:39:42 -0400 Subject: [PATCH] lvgui: Add button enabled/disabled state --- boot/lib/lvgui/lvgui/_button.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/boot/lib/lvgui/lvgui/_button.rb b/boot/lib/lvgui/lvgui/_button.rb index f327a64f..a6160695 100644 --- a/boot/lib/lvgui/lvgui/_button.rb +++ b/boot/lib/lvgui/lvgui/_button.rb @@ -58,6 +58,7 @@ class LVGUI::Button < LVGUI::Widget end def initialize(parent) + @enabled = true super(LVGL::LVButton.new(parent)) set_layout(LVGL::LAYOUT::COL_M) set_ink_in_time(200) @@ -65,9 +66,23 @@ class LVGUI::Button < LVGUI::Widget set_ink_out_time(500) set_fit2(LVGL::FIT::FILL, LVGL::FIT::TIGHT) @label = LVGL::LVLabel.new(self) + set_opa_scale_enable(true) end def set_label(label) @label.set_text(label) end + + def enabled?() + @enabled + end + + def set_enabled(state) + @enabled = state + if enabled?() + set_opa_scale(LVGL::OPA.scale(100)) + else + set_opa_scale(LVGL::OPA.scale(20)) + end + end end