From d11be2a7a99caad18dbd994633bc0b0deaf2bdf5 Mon Sep 17 00:00:00 2001 From: Gabriel Wang Date: Thu, 19 Oct 2023 15:46:14 +0100 Subject: [PATCH] improve the progress_bar_drill --- ARM.Arm-2D.pdsc | 2 +- examples/common/controls/progress_bar_drill.c | 13 ++++-- examples/common/controls/progress_bar_drill.h | 44 ++++++++++++++++++- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/ARM.Arm-2D.pdsc b/ARM.Arm-2D.pdsc index e3cfbf2de..73ae6e228 100644 --- a/ARM.Arm-2D.pdsc +++ b/ARM.Arm-2D.pdsc @@ -336,7 +336,7 @@ - + A set of example controls, e.g. round-corner-box, spinning-wheels etc diff --git a/examples/common/controls/progress_bar_drill.c b/examples/common/controls/progress_bar_drill.c index 33e42884e..3b1be616d 100644 --- a/examples/common/controls/progress_bar_drill.c +++ b/examples/common/controls/progress_bar_drill.c @@ -91,7 +91,8 @@ void progress_bar_drill_init(void) s_wUnit = PROGRESS_BAR_DRILL_SPEED; } -void progress_bar_drill_show( const arm_2d_tile_t *ptTarget, +void __progress_bar_drill_show( const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion, int_fast16_t iProgress, bool bIsNewFrame) { @@ -101,11 +102,15 @@ void progress_bar_drill_show( const arm_2d_tile_t *ptTarget, if (iProgress > 1000) { iProgress = 0; } - + arm_2d_region_t tTargetRegion = {.tSize = ptTarget->tRegion.tSize,}; + if (NULL == ptRegion) { + ptRegion = &tTargetRegion; + } + arm_2d_region_t tBarRegion = { .tLocation = { - .iX = (ptTarget->tRegion.tSize.iWidth - (int16_t)iWidth) / 2, - .iY = (ptTarget->tRegion.tSize.iHeight - c_tileBlueSlash.tRegion.tSize.iHeight) / (int16_t)2, + .iX = (ptRegion->tSize.iWidth - (int16_t)iWidth) / 2, + .iY = (ptRegion->tSize.iHeight - c_tileBlueSlash.tRegion.tSize.iHeight) / (int16_t)2, }, .tSize = { .iWidth = (int16_t)iWidth, diff --git a/examples/common/controls/progress_bar_drill.h b/examples/common/controls/progress_bar_drill.h index c2670b9ba..0d2e40b54 100644 --- a/examples/common/controls/progress_bar_drill.h +++ b/examples/common/controls/progress_bar_drill.h @@ -28,6 +28,47 @@ extern "C" { /*============================ MACROS ========================================*/ /*============================ MACROFIED FUNCTIONS ===========================*/ + +#define progress_bar_drill_show4( __target_ptr, \ + __region_ptr, \ + __progress, \ + __is_new_frame) \ + __progress_bar_drill_show( (__target_ptr), \ + (__region_ptr), \ + (int_fast16_t)(__progress), \ + (__is_new_frame)) + +#define progress_bar_drill_show3( __target_ptr, \ + __progress, \ + __is_new_frame) \ + progress_bar_drill_show4( (__target_ptr), \ + NULL, \ + (int_fast16_t)(__progress), \ + (__is_new_frame)) + +#define progress_bar_drill_show2( __target_ptr, \ + __progress) \ + progress_bar_drill_show4( (__target_ptr), \ + NULL, \ + (int_fast16_t)(__progress), \ + (true)) + +#define progress_bar_drill_show1( __progress) \ + progress_bar_drill_show4( ((const arm_2d_tile_t *ptTarget)(-1))), \ + NULL, \ + (int_fast16_t)(__progress), \ + (true)) + +#define progress_bar_drill_show0() \ + progress_bar_drill_show4( ((const arm_2d_tile_t *ptTarget)(-1))), \ + NULL, \ + (-1), \ + (true)) + +#define progress_bar_drill_show(...) \ + ARM_CONNECT2( progress_bar_drill_show, \ + __ARM_VA_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__) + /*============================ TYPES =========================================*/ /*============================ GLOBAL VARIABLES ==============================*/ /*============================ PROTOTYPES ====================================*/ @@ -36,7 +77,8 @@ extern void progress_bar_drill_init(void); extern -void progress_bar_drill_show( const arm_2d_tile_t *ptTarget, +void __progress_bar_drill_show( const arm_2d_tile_t *ptTarget, + const arm_2d_region_t *ptRegion, int_fast16_t iProgress, bool bIsNewFrame);