From 1bf21564f9417a18d2b4ed4a069d8c974ac37031 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Mon, 12 Sep 2022 14:43:01 -0400 Subject: [PATCH] #91 recoloring of horizontal and vertical bar indicators --- graphics/elements/indicators/hbar.lua | 1 + graphics/elements/indicators/vbar.lua | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/graphics/elements/indicators/hbar.lua b/graphics/elements/indicators/hbar.lua index 4fc8532..4a291ff 100644 --- a/graphics/elements/indicators/hbar.lua +++ b/graphics/elements/indicators/hbar.lua @@ -98,6 +98,7 @@ local function hbar(args) end end + -- change bar color ---@param bar_fg_bg cpair new bar colors function e.recolor(bar_fg_bg) bar_bkg = bar_fg_bg.blit_bkg diff --git a/graphics/elements/indicators/vbar.lua b/graphics/elements/indicators/vbar.lua index 7888033..38eb023 100644 --- a/graphics/elements/indicators/vbar.lua +++ b/graphics/elements/indicators/vbar.lua @@ -80,6 +80,17 @@ local function vbar(args) end end + -- change bar color + ---@param fg_bg cpair new bar colors + function e.recolor(fg_bg) + fgd = util.strrep(fg_bg.blit_fgd, e.frame.w) + bkg = util.strrep(fg_bg.blit_bkg, e.frame.w) + + -- re-draw + last_num_bars = 0 + e.on_update(e.value) + end + function e.set_value(val) e.on_update(val) end return e.get()