From 3c8596a5be45eda48701499fc70a085b67b85725 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 10 Oct 2021 16:55:38 +0200 Subject: [PATCH] hourglass: use count of images as calculation base for paint interval We are using possible 3rd party theme packages (installed via package manager) with other counts of images. This should ensure an automatic adaptation of interval in case of different count of images. --- src/gui/widget/hourglass.cpp | 2 +- src/gui/widget/hourglass.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/widget/hourglass.cpp b/src/gui/widget/hourglass.cpp index f17d9c637..1dd9a278d 100644 --- a/src/gui/widget/hourglass.cpp +++ b/src/gui/widget/hourglass.cpp @@ -55,7 +55,7 @@ CHourGlass::CHourGlass( const int x_pos, initImageFiles(); hg_file_num = 0; - hg_interval = interval; + hg_interval = interval == HG_AUTO_PAINT_INTERVAL ? 1000/hg_img_files.size() : interval; hg_timer = new CComponentsTimer(hg_interval); hg_timer->OnTimer.connect(sigc::bind(sigc::mem_fun(*this, &CHourGlass::paint), true)); } diff --git a/src/gui/widget/hourglass.h b/src/gui/widget/hourglass.h index cf5a9c226..4e55cd9c6 100644 --- a/src/gui/widget/hourglass.h +++ b/src/gui/widget/hourglass.h @@ -33,6 +33,8 @@ CHourglass shows only a timer controlled image chain, CHourglassProc will run an additional process. */ +#define HG_AUTO_PAINT_INTERVAL -1 + class CHourGlass : public CComponentsShapeSquare { private: @@ -61,7 +63,7 @@ class CHourGlass : public CComponentsShapeSquare * The max count of images are defined in MAX_IMAGES. * Images must be stored as usual inside the defined icon directories. * @param[in] interval - * @li optional: expects type int64_t, defines paint interval, default = 84ms + * @li optional: expects type int64_t, defines paint interval in milliseconds, default = HG_AUTO_PAINT_INTERVAL (cycle 1000ms / count of images) * @param[in] parent * @li optional: expects type CComponentsForm, as a parent container in which this object is embedded, default = NULL (stand alone) * @param[in] shadow_mode @@ -81,7 +83,7 @@ class CHourGlass : public CComponentsShapeSquare const int w = 48, const int h = 48, const std::string& image_basename = "hourglass", - const int64_t& interval = 84, + const int64_t& interval = HG_AUTO_PAINT_INTERVAL, CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_FRAME_PLUS_0, @@ -122,7 +124,7 @@ class CHourGlassProc : public CHourGlass const int w = 48, const int h = 48, const std::string& image_basename = "hourglass", - const int64_t& interval = 84, + const int64_t& interval = HG_AUTO_PAINT_INTERVAL, CComponentsForm *parent = NULL, int shadow_mode = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_FRAME_PLUS_0,