Skip to content

Commit

Permalink
improve the progress_bar_drill
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Oct 19, 2023
1 parent 341eea6 commit d11be2a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ARM.Arm-2D.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
</RTE_Components_h>
</component>

<component Cclass="Acceleration" Cgroup="Arm-2D Extras" Csub="Controls" Cversion="1.5.0" condition="Arm-2D-EXTRA">
<component Cclass="Acceleration" Cgroup="Arm-2D Extras" Csub="Controls" Cversion="1.5.1" condition="Arm-2D-EXTRA">
<description>A set of example controls, e.g. round-corner-box, spinning-wheels etc</description>
<files>
<file category="include" name="examples/common/controls/" />
Expand Down
13 changes: 9 additions & 4 deletions examples/common/controls/progress_bar_drill.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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,
Expand Down
44 changes: 43 additions & 1 deletion examples/common/controls/progress_bar_drill.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ====================================*/
Expand All @@ -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);

Expand Down

0 comments on commit d11be2a

Please sign in to comment.