Skip to content

Commit

Permalink
add api for get the indicator region
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Nov 24, 2024
1 parent 0f0c758 commit 60ad7d5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ARM.Arm-2D.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
</RTE_Components_h>
</component>

<component Cclass="Acceleration" Cgroup="Arm-2D Helper" Csub="PFB" Cversion="2.4.0" condition="Arm-2D-CORE">
<component Cclass="Acceleration" Cgroup="Arm-2D Helper" Csub="PFB" Cversion="2.4.1" condition="Arm-2D-CORE">
<description>Helper services for LCD adaptor(s), e.g. Generic Partial Framebuffer, Scene Player etc.</description>
<files>
<file category="include" name="Helper/Include/" />
Expand Down
20 changes: 17 additions & 3 deletions Helper/Include/arm_2d_helper_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Description: Public header file for list core related services
*
* $Date: 24. Nov 2024
* $Revision: V.2.0.0
* $Revision: V.2.1.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -272,6 +272,7 @@ ARM_PROTECTED(
int32_t nOffset; /*!< list offset */
int32_t nStartOffset; /*!< the start offset */
int32_t nTargetOffset; /*!< the target list offset */
arm_2d_region_t tRegion;
} Selection;

uint16_t hwSelection; /*!< item selection */
Expand Down Expand Up @@ -401,16 +402,29 @@ ARM_NONNULL(1,2)
arm_2d_err_t __arm_2d_list_core_init( __arm_2d_list_core_t *ptThis,
__arm_2d_list_core_cfg_t *ptCFG);

extern
ARM_NONNULL(1)
/*!
* \brief get the size of the target list
*
* \param[in] ptThis the target list core object
* \return arm_2d_size_t the list size
*/
extern
ARM_NONNULL(1)
arm_2d_size_t __arm_2d_list_core_get_list_size(__arm_2d_list_core_t *ptThis);

/*!
* \brief get the region for drawing the item selection indicator
*
* \param[in] ptThis the target list core object
* \param[in] ptRegionBuffer a region object for reading the result
* \return arm_2d_region_t* the address of the region buffer
*/
extern
ARM_NONNULL(1,2)
arm_2d_region_t *__arm_2d_list_core_get_selection_region(
__arm_2d_list_core_t *ptThis,
arm_2d_region_t *ptRegionBuffer);

/*!
* \brief show a given list core
* \param[in] ptThis the target list core object
Expand Down
71 changes: 50 additions & 21 deletions Helper/Source/arm_2d_helper_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Description: Public header file for list core related services
*
* $Date: 24. Nov 2024
* $Revision: V.2.0.0
* $Revision: V.2.1.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -59,6 +59,7 @@
# pragma clang diagnostic ignored "-Wcovered-switch-default"
# pragma clang diagnostic ignored "-Wswitch-enum"
# pragma clang diagnostic ignored "-Wswitch-default"
# pragma clang diagnostic ignored "-Wtautological-pointer-compare"
#elif __IS_COMPILER_ARM_COMPILER_5__
# pragma diag_suppress 188,546
#elif defined(__IS_COMPILER_GCC__)
Expand Down Expand Up @@ -1124,7 +1125,7 @@ bool __arm_2d_list_core_update_fixed_size_no_status_check(

static
ARM_NONNULL(1,2,3)
arm_2d_err_t __calculator_normal_offset_update( __arm_2d_list_core_t *ptThis,
arm_2d_err_t __calculator_offset_update( __arm_2d_list_core_t *ptThis,
__arm_2d_list_item_iterator *fnIterator,
int32_t *pnOffset)
{
Expand All @@ -1146,6 +1147,21 @@ arm_2d_err_t __calculator_normal_offset_update( __arm_2d_list_core_t *ptThis,
nVisualWindowStart = __arm_2d_list_safe_mod(nVisualWindowStart, this.tCFG.nTotalLength, false);
}

/* move to the first item */
arm_2d_list_item_t *ptItem = __arm_2d_list_core_get_item(
ptThis,
fnIterator,
__ARM_2D_LIST_GET_ITEM_WITH_ID_WITHOUT_MOVE_POINTER,
this.Runtime.hwSelection,
true,
false);
if (NULL == ptItem) {
/* no valid item, return NULL */
return ARM_2D_ERR_NOT_AVAILABLE;
}

this.Runtime.Selection.tRegion.tSize = ptItem->tSize;

if (nSelectionOffset < nVisualWindowStart) {
/* move visual window */
int32_t nDelta = nVisualWindowStart - nSelectionOffset;
Expand All @@ -1155,19 +1171,6 @@ arm_2d_err_t __calculator_normal_offset_update( __arm_2d_list_core_t *ptThis,
nOffset += nDelta;
} else {

/* move to the first item */
arm_2d_list_item_t *ptItem = __arm_2d_list_core_get_item(
ptThis,
fnIterator,
__ARM_2D_LIST_GET_ITEM_WITH_ID_WITHOUT_MOVE_POINTER,
this.Runtime.hwSelection,
true,
false);
if (NULL == ptItem) {
/* no valid item, return NULL */
return ARM_2D_ERR_NOT_AVAILABLE;
}

int16_t iItemSize = 0;
int16_t iListRegionSize = 0;

Expand All @@ -1179,9 +1182,9 @@ arm_2d_err_t __calculator_normal_offset_update( __arm_2d_list_core_t *ptThis,
iListRegionSize = this.Runtime.tileList.tRegion.tSize.iHeight;
}

int16_t iItemActualHeight = iItemSize + ptItem->Padding.chPrevious;
int16_t iItemActualSize = iItemSize + ptItem->Padding.chPrevious;

int16_t iItemBottomBoarder = nSelectionOffset + iItemActualHeight - 1;
int16_t iItemBottomBoarder = nSelectionOffset + iItemActualSize - 1;

int16_t iVisualWindowBottomBoarder = nVisualWindowStart + iListRegionSize - 1;
if (iItemBottomBoarder > iVisualWindowBottomBoarder) {
Expand All @@ -1194,11 +1197,37 @@ arm_2d_err_t __calculator_normal_offset_update( __arm_2d_list_core_t *ptThis,
}
}

if (this.Runtime.tWorkingArea.tDirection == ARM_2D_LIST_HORIZONTAL) {
this.Runtime.Selection.tRegion.tLocation.iX = nSelectionOffset - nVisualWindowStart;
this.Runtime.Selection.tRegion.tLocation.iY = 0;
} else {
this.Runtime.Selection.tRegion.tLocation.iX = 0;
this.Runtime.Selection.tRegion.tLocation.iY = nSelectionOffset - nVisualWindowStart;
}

(*pnOffset) = nOffset;

return ARM_2D_ERR_NONE;
}

ARM_NONNULL(1,2)
arm_2d_region_t *__arm_2d_list_core_get_selection_region(__arm_2d_list_core_t *ptThis,
arm_2d_region_t *ptRegionBuffer)
{
assert(NULL != ptThis);

do {
if (NULL == ptRegionBuffer) {
break;
}

*ptRegionBuffer = this.Runtime.Selection.tRegion;
} while(0);

return ptRegionBuffer;
}


static
__arm_2d_list_work_area_t * __calculator_vertical (
__arm_2d_list_core_t *ptThis,
Expand Down Expand Up @@ -1236,7 +1265,7 @@ ARM_PT_BEGIN(this.chState)
}

if (!bMidAligned) {
if (ARM_2D_ERR_NONE != __calculator_normal_offset_update(ptThis, fnIterator, &nOffset)) {
if (ARM_2D_ERR_NONE != __calculator_offset_update(ptThis, fnIterator, &nOffset)) {
/* no valid item, return NULL */
ARM_PT_RETURN(NULL)
}
Expand Down Expand Up @@ -1705,7 +1734,7 @@ ARM_PT_BEGIN(this.chState)
}

if (!bMidAligned) {
if (ARM_2D_ERR_NONE != __calculator_normal_offset_update(ptThis, fnIterator, &nOffset)) {
if (ARM_2D_ERR_NONE != __calculator_offset_update(ptThis, fnIterator, &nOffset)) {
/* no valid item, return NULL */
ARM_PT_RETURN(NULL)
}
Expand Down Expand Up @@ -2176,7 +2205,7 @@ ARM_PT_BEGIN(this.chState)
}

if (!bMidAligned) {
if (ARM_2D_ERR_NONE != __calculator_normal_offset_update(ptThis, fnIterator, &nOffset)) {
if (ARM_2D_ERR_NONE != __calculator_offset_update(ptThis, fnIterator, &nOffset)) {
/* no valid item, return NULL */
ARM_PT_RETURN(NULL)
}
Expand Down Expand Up @@ -2668,7 +2697,7 @@ ARM_PT_BEGIN(this.chState)
}

if (!bMidAligned) {
if (ARM_2D_ERR_NONE != __calculator_normal_offset_update(ptThis, fnIterator, &nOffset)) {
if (ARM_2D_ERR_NONE != __calculator_offset_update(ptThis, fnIterator, &nOffset)) {
/* no valid item, return NULL */
ARM_PT_RETURN(NULL)
}
Expand Down

0 comments on commit 60ad7d5

Please sign in to comment.