Skip to content

Commit

Permalink
OpenCanopy: Reset label scrolling when TAB focus changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mhaeuser committed Mar 27, 2021
1 parent eb8691c commit 5837fbd
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 35 deletions.
82 changes: 50 additions & 32 deletions Platform/OpenCanopy/Views/BootPicker.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,46 @@ STATIC GUI_ANIMATION mBootPickerLabelAnimation = {
};

VOID
InternalAnimateSelectedLabel (
IN OUT GUI_DRAWING_CONTEXT *DrawContext
InternalStartAnimateLabel (
IN OUT GUI_DRAWING_CONTEXT *DrawContext,
IN CONST GUI_VOLUME_ENTRY *Entry
)
{
CONST GUI_VOLUME_ENTRY *Entry;
ASSERT (!IsNodeInList (&DrawContext->Animations, &mBootPickerLabelAnimation.Link));
//
// Reset the boot entry label scrolling timer.
//
mBootPickerLabelScrollHoldTime = 0;

Entry = InternalGetVolumeEntry (mBootPicker.SelectedIndex);
if (Entry->Label.Width >= Entry->Hdr.Obj.Width) {
if (Entry->Label.Width > Entry->Hdr.Obj.Width) {
//
// Add the animation if the next entry needs scrolling.
//
InsertHeadList (&DrawContext->Animations, &mBootPickerLabelAnimation.Link);
}
}

VOID
InternalStopAnimateLabel (
IN OUT GUI_DRAWING_CONTEXT *DrawContext,
IN OUT GUI_VOLUME_ENTRY *Entry
)
{
if (Entry->Label.Width > Entry->Hdr.Obj.Width) {
//
// Reset the label of the old entry back to its default position.
//
if (Entry->LabelOffset != 0) {
Entry->ShowLeftShadow = FALSE;
Entry->LabelOffset = 0;
InternalRedrawVolumeLabel (DrawContext, Entry);
}

RemoveEntryList (&mBootPickerLabelAnimation.Link);
InitializeListHead (&mBootPickerLabelAnimation.Link);
}
}

VOID
InternalBootPickerSelectEntry (
IN OUT GUI_VOLUME_PICKER *This,
Expand All @@ -174,34 +199,14 @@ InternalBootPickerSelectEntry (
ASSERT_EQUALS (This->Hdr.Obj.Height, mBootPickerSelectorContainer.Obj.OffsetY + mBootPickerSelectorContainer.Obj.Height);

mBootPickerSelectorContainer.Obj.OffsetX = mBootPicker.Hdr.Obj.OffsetX + NewEntry->Hdr.Obj.OffsetX - (mBootPickerSelectorContainer.Obj.Width - NewEntry->Hdr.Obj.Width) / 2;
//
// Reset the boot entry label scrolling timer.
//
mBootPickerLabelScrollHoldTime = 0;

if (DrawContext != NULL) {
if (OldEntry->Label.Width > OldEntry->Hdr.Obj.Width) {
//
// Reset the label of the old entry back to its default position.
//
if (OldEntry->LabelOffset != 0) {
OldEntry->ShowLeftShadow = FALSE;
OldEntry->LabelOffset = 0;
InternalRedrawVolumeLabel (DrawContext, OldEntry);
}
//
// Remove the animation if the next entry does not need scrolling.
//
if (NewEntry->Label.Width <= NewEntry->Hdr.Obj.Width) {
RemoveEntryList (&mBootPickerLabelAnimation.Link);
InitializeListHead (&mBootPickerLabelAnimation.Link);
}
} else {
//
// Add the animation if the next entry needs scrolling.
//
InternalAnimateSelectedLabel (DrawContext);
ASSERT (IsNodeInList (&DrawContext->Animations, &mBootPickerLabelAnimation.Link));
}

InternalStopAnimateLabel (DrawContext, OldEntry);
InternalStartAnimateLabel (DrawContext, NewEntry);
//
// Set voice timeout to N frames from now.
//
Expand Down Expand Up @@ -1011,6 +1016,9 @@ InternalBootPickerViewKeyEvent (
IN CONST GUI_KEY_EVENT *KeyEvent
)
{
GUI_OBJ *FocusChangedObj;
GUI_VOLUME_ENTRY *Entry;

ASSERT (This != NULL);
ASSERT (DrawContext != NULL);

Expand All @@ -1022,11 +1030,20 @@ InternalBootPickerViewKeyEvent (
return;
}

InternalFocusKeyHandler (
Entry = InternalGetVolumeEntry(mBootPicker.SelectedIndex);

FocusChangedObj = InternalFocusKeyHandler (
DrawContext,
Context,
KeyEvent
);
if (FocusChangedObj == &mBootPicker.Hdr.Obj) {
InternalStartAnimateLabel (DrawContext, Entry);
} else if (FocusChangedObj != NULL) {
if (!IsListEmpty (&mBootPickerLabelAnimation.Link)) {
InternalStopAnimateLabel (DrawContext, Entry);
}
}
}

VOID
Expand Down Expand Up @@ -1891,8 +1908,9 @@ BootPickerViewLateInitialize (
InternalUpdateScrollButtons ();
}
InternalBootPickerSelectEntry (&mBootPicker, NULL, DefaultIndex);
InternalAnimateSelectedLabel (DrawContext);
GuiContext->BootEntry = InternalGetVolumeEntry (DefaultIndex)->Context;
BootEntry = InternalGetVolumeEntry (DefaultIndex);
InternalStartAnimateLabel (DrawContext, BootEntry);
GuiContext->BootEntry = BootEntry->Context;
}

VOID
Expand Down
12 changes: 10 additions & 2 deletions Platform/OpenCanopy/Views/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ GuiClickableIsHit (
return Image->Buffer[(UINT32) OffsetY * Image->Width + (UINT32) OffsetX].Reserved > 0;
}

VOID
GUI_OBJ *
InternalFocusKeyHandler (
IN OUT GUI_DRAWING_CONTEXT *DrawContext,
IN BOOT_PICKER_GUI_CONTEXT *Context,
IN CONST GUI_KEY_EVENT *KeyEvent
)
{
UINT8 CommonFocusState;
UINT8 CommonFocusState;
GUI_OBJ *FocusChangedObj;

if (KeyEvent->OcKeyCode == OC_INPUT_SWITCH_CONTEXT) {
mCommonFocusList[mCommonFocusState]->Focus (
mCommonFocusList[mCommonFocusState],
Expand All @@ -136,14 +138,20 @@ InternalFocusKeyHandler (
DrawContext,
TRUE
);

FocusChangedObj = mCommonFocusList[CommonFocusState];
} else {
mCommonFocusList[mCommonFocusState]->KeyEvent (
mCommonFocusList[mCommonFocusState],
DrawContext,
Context,
KeyEvent
);

FocusChangedObj = NULL;
}

return FocusChangedObj;
}

VOID
Expand Down
2 changes: 1 addition & 1 deletion Platform/OpenCanopy/Views/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GuiClickableIsHit (
IN INT64 OffsetY
);

VOID
GUI_OBJ *
InternalFocusKeyHandler (
IN OUT GUI_DRAWING_CONTEXT *DrawContext,
IN BOOT_PICKER_GUI_CONTEXT *Context,
Expand Down

0 comments on commit 5837fbd

Please sign in to comment.