From 5837fbd28c56252df2443042dbe95c8b6b7e7dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20H=C3=A4user?= <8659494+mhaeuser@users.noreply.github.com> Date: Sat, 27 Mar 2021 11:43:22 +0100 Subject: [PATCH] OpenCanopy: Reset label scrolling when TAB focus changes --- Platform/OpenCanopy/Views/BootPicker.c | 82 ++++++++++++++++---------- Platform/OpenCanopy/Views/Common.c | 12 +++- Platform/OpenCanopy/Views/Common.h | 2 +- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/Platform/OpenCanopy/Views/BootPicker.c b/Platform/OpenCanopy/Views/BootPicker.c index 0abcd78b..08086462 100644 --- a/Platform/OpenCanopy/Views/BootPicker.c +++ b/Platform/OpenCanopy/Views/BootPicker.c @@ -138,14 +138,18 @@ 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. // @@ -153,6 +157,27 @@ InternalAnimateSelectedLabel ( } } +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, @@ -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. // @@ -1011,6 +1016,9 @@ InternalBootPickerViewKeyEvent ( IN CONST GUI_KEY_EVENT *KeyEvent ) { + GUI_OBJ *FocusChangedObj; + GUI_VOLUME_ENTRY *Entry; + ASSERT (This != NULL); ASSERT (DrawContext != NULL); @@ -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 @@ -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 diff --git a/Platform/OpenCanopy/Views/Common.c b/Platform/OpenCanopy/Views/Common.c index 4d76573c..ad33200e 100644 --- a/Platform/OpenCanopy/Views/Common.c +++ b/Platform/OpenCanopy/Views/Common.c @@ -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], @@ -136,6 +138,8 @@ InternalFocusKeyHandler ( DrawContext, TRUE ); + + FocusChangedObj = mCommonFocusList[CommonFocusState]; } else { mCommonFocusList[mCommonFocusState]->KeyEvent ( mCommonFocusList[mCommonFocusState], @@ -143,7 +147,11 @@ InternalFocusKeyHandler ( Context, KeyEvent ); + + FocusChangedObj = NULL; } + + return FocusChangedObj; } VOID diff --git a/Platform/OpenCanopy/Views/Common.h b/Platform/OpenCanopy/Views/Common.h index f75cf4bc..ced3e044 100644 --- a/Platform/OpenCanopy/Views/Common.h +++ b/Platform/OpenCanopy/Views/Common.h @@ -31,7 +31,7 @@ GuiClickableIsHit ( IN INT64 OffsetY ); -VOID +GUI_OBJ * InternalFocusKeyHandler ( IN OUT GUI_DRAWING_CONTEXT *DrawContext, IN BOOT_PICKER_GUI_CONTEXT *Context,