Skip to content

Commit

Permalink
Move Skip to a function
Browse files Browse the repository at this point in the history
  • Loading branch information
asizon committed Jan 28, 2020
1 parent 6a53ee5 commit 6061e4e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/main/cms/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,23 @@ STATIC_UNIT_TESTED const void *cmsMenuBack(displayPort_t *pDisplay)
return NULL;
}

// Skip read-only entries
static bool rowIsSkippable(const OSD_Entry *row)
{
if (row->type == OME_Label) {
return true;
}

if (row->type == OME_String) {
return true;
}

if ((row->type == OME_UINT16 || row->type == OME_INT16) && row->flags == DYNAMIC) {
return true;
}
return false;
}

static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
{
if (!pageTop || !cmsInMenu) {
Expand Down Expand Up @@ -612,7 +629,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)

// Cursor manipulation

while ((pageTop + currentCtx.cursorRow)->type == OME_Label || (pageTop + currentCtx.cursorRow)->type == OME_String || (((pageTop + currentCtx.cursorRow)->type == OME_UINT16 || (pageTop + currentCtx.cursorRow)->type == OME_INT16) && (pageTop + currentCtx.cursorRow)->flags == DYNAMIC)) { // skip labels, strings and dynamic info entries
while (rowIsSkippable(pageTop + currentCtx.cursorRow)) { // skip labels, strings and dynamic read-only entries
currentCtx.cursorRow++;
}

Expand Down Expand Up @@ -902,8 +919,8 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, cms_key_e key)
if ((key == CMS_KEY_UP) && (!osdElementEditing)) {
currentCtx.cursorRow--;

// Skip non-title labels, strings and dynamic info entries
while (((pageTop + currentCtx.cursorRow)->type == OME_Label || (pageTop + currentCtx.cursorRow)->type == OME_String || (((pageTop + currentCtx.cursorRow)->type == OME_UINT16 || (pageTop + currentCtx.cursorRow)->type == OME_INT16) && (pageTop + currentCtx.cursorRow)->flags == DYNAMIC)) && currentCtx.cursorRow > 0) {
// Skip non-title labels, strings and dynamic read-only entries
while ((rowIsSkippable(pageTop + currentCtx.cursorRow)) && currentCtx.cursorRow > 0) {
currentCtx.cursorRow--;
}
if (currentCtx.cursorRow == -1 || (pageTop + currentCtx.cursorRow)->type == OME_Label) {
Expand Down

0 comments on commit 6061e4e

Please sign in to comment.